Install "Home Assistant" as Windows service
Home Assistant is automation platform for home written on Python. It allows to connect a whole bunch of devices and create rules to perform automated tasks.
For Mac OS and Linux there are instruction on how to daemonize (autostart) the platform. So, here are the missing for Windows.
There numerous way to run a Python script as Windows Service, including the accepted answer on StackOverflow, but IMHO a much simpler approach is by using NSSM.
Download and extract NSSM from here
Run from command line
\win64\nssm.exe install HomeAssistant
which will launch configuration UI for serviceIn this example I installed “Home Assistant” under Python Virtual Environment located at
C:\hass-env\
, which places executable atC:\hass-env\Scripts\hass.exe
. The configuration folder is located in%appdata%\.homeassistant\
, hence will pass it location via argument-c
:I’m running it with
Local System
account (this is why I needed to specify configuration folder in step #3 to my%appdata%
):To catch log information written to console I defined I/O redirection to custom log file:
You can define file rotation in case output file growths fast as following:
At this stage you should be now able to start, stop and restart the service. If error thrown during startup, the service won’t start and you can check the log file for details.