Autostart on macOS

Tags: #<Tag:0x00007f739f256f60>

:warning: This guide has been migrated from our website and might be outdated. Feel free to edit this guide to update it, and to remove this message after that.

Setting up Home Assistant to run as a background service is simple; macOS will start Home Assistant after the system has booted, the user has logged in, and make sure it’s always running.

To get Home Assistant installed as a background service, run:

$ hass --script macos install

Home Assistant has been installed.         Open it here: http://localhost:8123

Home Assistant will log to ~/Library/Logs/homeassistant.log

Configuration is kept in ~/.homeassistant

To uninstall the service, run:

$ hass --script macos uninstall

Home Assistant has been uninstalled.

Note:
automake is required for hass to start. If you are missing this on your system, you can install this by running:

brew install autoconf

The above may work under certain circumstances, but in my installation on a Mac running Catalina and HA in a VENV, it didn’t (and I’ve seen the same from others in the forums). The updated way to automate jobs on Mac is using launchd; see more at this link (but I will replicate the important parts herein):

In order to use launchd you create a .plist file in the appropriate folder and the system will see it and run the payload, in this case at system startup. If you’ve set things up the way I did with your user as the HA user, you would put the .plist file in /Users/YOURUSERNAME/Library/LaunchAgents; otherwise use the appropriate path for your HA user. That’s it- create the file as below and make sure to proof the paths.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>AbandonProcessGroup</key>
	<false/>
	<key>EnvironmentVariables</key>
	<dict>
		<key>LC_CTYPE</key>
		<string>UTF-8</string>
		<key>PATH</key>
		<string>/usr/local/bin/:/usr/bin:/usr/sbin:/sbin:$PATH</string>
	</dict>
	<key>KeepAlive</key>
	<dict>
		<key>SuccessfulExit</key>
		<false/>
	</dict>
	<key>Label</key>
	<string>org.homeassistant</string>
	<key>Program</key>
	<string>/Users/YOURUSERNAME/homeassistant/bin/hass</string>
	<key>RunAtLoad</key>
	<true/>
	<key>StandardErrorPath</key>
	<string>/Users/YOURUSERNAME/.homeassistant/home-assistant.log</string>
	<key>StandardOutPath</key>
	<string>/Users/YOURUSERNAME/.homeassistant/home-assistant.log</string>
</dict>
</plist>