Use this repository as template when developing apps for NetDaemon. This template is a good starting point for your development environment. It has pre-built structure both for building apps and unit test them. Unit tests fake objects are alpha and the fake API can be changed.
- Make new repository with this repo as template
- RENAME
src/_appsettings.json
tosrc/appsettings.json
. Edit the appsettings.json file to provide details about how to connect to Home Assistant. Token, Host is mandatory. Rest is optional. - Run dotnet restore in the terminal
- Add and edit your apps in the
/src/apps
folder. There are a few code-snippets you can use. - Copy the edited
/src/apps
to the foldernetdaemon/apps
under your Hass.io config folder. See advanced deployment for alternatives. - Install NetDaemon runtime using add-on or run a docker container. Please see https://netdaemon.xyz/docs/started/installation for details how to run the daemon.
For detailed information about using netdaemon please see https://netdaemon.xyz.
You can also setup environment varables for your Home Assistant instance. In that case you just need to rename src/_appsettings.json
to src/appsettings.json
and set corresponding environment vars in your host and rebuild container. The mandantory settings is HOMEASSISTANT__TOKEN
and HOMEASSISTANT__HOST
. All other is optional.
Environment variable | Description |
---|---|
HOMEASSISTANT__TOKEN | Token secret to access the HA instance |
|
| HOMEASSISTANT__HOST | The ip or hostname of HA
| HOMEASSISTANT__PORT | The port of home assistant (defaults to 8123 if not specified) |
| NETDAEMON__GENERATEENTITIES | Generate entities, recommed set false unless debugging|
| NETDAEMON__APPSOURCE | The folder where it will find the NetDaemon runtime and source. If you set a folder
, the deafult dynamically compiled sourc in this folder, if daemonapp.csproj
it will run that project and daemonapp.dll
for published project. These settings only apply in addon/container. For developmen just do not not set or empty ""
.
The recommended way to use this template is to clone new fresh version when you upgrade and copy all .cs and .yaml files from your apps into the ./src/apps folder.
The default behavour of NetDaemon is do dynamically compile all apps in apps folder. If you need to deploy dependencies like custom nuget packages you have two choices, project or publish.
The docs assume you map volyme like:
-v ~/netdaemon:/data
- Project deployment: Copy everything under
./src/*
->~/netdaemon
. The csproj file should be in root of~/netdaemon
. Set theNETDAEMON__APPSOURCE="daemonapp.csproj"
- Published deployment: publish the project by
dotnet publish -c Release ./src.
Copy everything undersrc/bin/Release/net5.0/publish/*
to~/netdaemon
and setNETDAEMON__APPSOURCE="daemonapp.dll"
- Project deployment: Copy everything under
./src/*
->/config/netdaemon
. The csproj file should be in root of~/netdaemon
. Set theAppSource=daemonapp.csproj
in addon settings. - Published deployment: publish the project by
dotnet publish -c Release ./src.
Copy everything undersrc/bin/Release/net5.0/publish/*
to/config/netdaemon
and setAppSource=daemonapp.dll
in addon settings.
Make sure you take security meassures using custom deployments!
Each app should have it´s own subfolder under the apps
folder. So rename the HelloWorld
folder and HelloWorld.cs
and HelloWorld.yaml
according to your app. The class name should also be renamed to the same unique app name. We also recommend using namespaces and fully qualified names like the sample included in the template.
- If you have issues or suggestions of improvements to this template, please add an issue
- If you have issues or suggestions of improvements to NetDaemon, please add an issue
Please join the Discord server to get support or if you want to contribute and help others.
ICON: Attribution: chris 論