Install NetDaemon runtime
There are several ways to deploy your apps:
- Using a Home Assistant add-on
- In the NetDaemon Docker container
- Or using the template as base to deploy your own setup
Deploy as Home Assistant add-on
Once added to Home Assistant, select one of the V3 versions. If you feel you always want the latest and greatest changes you can choose the dev build but be prepare that things can break!
-
Make a folder structure under your Home Assistant configuration directory to use for NetDaemon apps.
/config/netdaemon4
-
Add the
https://github.com/net-daemon/homeassistant-addon
inAdd new repository URL
to the add-on store. -
Add the NetDaemon add-on.
todo: add new image
- Deploy your apps and
.yaml
files in the folder/config/netdaemon4
.
Deploy compiled assemblies and configurations
Copy your published files from dotnet publish -c Release -o [outputdir]
to /config/netdaemon4
. All the binaries and configuration should be copied.
See also tutorial Publish NetDeamon apps with Powershell.
In the add-on config, specify the app_assembly
setting to point to the assembly relative to your /config/netdaemon4
folder. This assembly should be the entry assembly (dll) from your project template. You can also add a path to the configuration folder separately. This is an example of how the configuration should appear using the default template:
The name of the assembly may be different.
To use Visual Studio's publish feature first install & configure the Samba share Home Assistant addon, then configure your VS publish options:
Now you can publish to quickly deploy files, and restart NetDaemon to run them.
Deploy source files and configurations
Copy the .cs
and .yaml
files to /config/netdaemon4
folder from the apps
folder using the template project and start/restart the NetDaemon add-on.
Install as a Docker container
If you are using Home Assistant Core and do not have the possibility to run add-ons, using the Docker container is a convenient way to run NetDaemon apps.
Always use specific versioning tags of Docker containers (not latest or dev) cause these are constantly getting new versions and things could break You can always find the latest stable version here
Example Docker run configuration
docker run -d \
--name netdaemon4 \
--restart=always \
-e HomeAssistant__Host=192.168.1.4 \
-e HomeAssistant__Token=XXXXX \
-e NetDaemon__ApplicationAssembly=NetDaemonApps.dll \
-e Logging__LogLevel__Default=Information \
-e TZ=Europe/Stockholm \
-v ~/netdaemon_config:/data \
netdaemon/netdaemon4
Example using docker-compose.yaml for
version: '3.7'
services:
netdaemon:
image: netdaemon/netdaemon4 # use netdaemon/netdaemon4:ver
# for specific version
container_name: netdaemon4
restart: always
environment:
- HomeAssistant__Host=your_ip_or_hostname # use host.docker.internal if HA in container (see section below)
- HomeAssistant__Token=your_token
- NetDaemon__ApplicationAssembly=NetDaemonApps.dll
- Logging__LogLevel__Default=Information # use Information/Debug/Trace/Warning/Error
- TZ=Etc/UTC # Set your current timezone
volumes:
- /config/netdaemon:/data # replace /config/netdaemon
# to your local folder
# extra_hosts: # Enable if HA in
# - "host.docker.internal:host-gateway" # container
Environment variables
The Docker container needs these environment variables to run properly.
ENV | Description |
---|---|
HomeAssistant__Host | The host that is running Home Assistant (defaults to localhost ) |
HomeAssistant__Port | The port Home Assistant is running on (default to 8123 ) |
HomeAssistant__Ssl | Set to True if SSL is used to access Home Assistant. |
HomeAssistant__Token | A Long Lived Access Token(LLAT) that NetDaemon can use for the communication with Home Assistant. |
HomeAssistant__InsecureBypassCertificateErrors | Ignores certificate errors. Please use at own risk. |
NetDaemon__ApplicationAssembly | Use this for the Deploy compiled assemblies option. Set to {your_assembly}.dll . For source deployment you should not set this setting! |
Logging__LogLevel__Default | Defaults to Information, values are (Trace, Debug, Information, Warning, Error) |
TZ | You will need to set container time zone to make the scheduler work properly |
NetDaemon__ApplicationConfigurationFolder | If you want to select another folder for your YAML configurations. Standard is /data |
Volumes
Vol | Description |
---|---|
/data | The volume of the NetDaemon folder should be mapped to /data See how to setup the correct folder here |
Folder structure and where to map the Docker volume
The ~/netdaemon_config
needs to point to a local folder. See image below where the local folder is named netdaemon4
and should be mapped as volume to the /data
!
You can use any folder name you like to use.
Reaching Home Assistant container
If you are trying trying to reach HA from the NodeDaemon container, localhost
will not resolve to the actual host machines loopback ip, but rather the NodeDaemons containers internal loopback ip.
If home assistant is running either directly on the host or in a container using network_mode: host
you will have to configure your NodeDaemon container to resolve the actual ip.
This can be achieved by setting the HomeAssistant__Host
environment variable to host.docker.internal
(and if on Linux, adding the field extra_hosts with the value host.docker.internal:host-gateway
)
For more info, see this post on Stack Overflow.
If home assistant is not using host mode networking, then the previous method should work, but you can also set the HomeAssistant__Host
variable to the name of the HA container instead, without adding the extra_hosts
field.