Hello everyone,
I’m trying to run Home Assistant as a system service on macOS using a LaunchDaemon (homeAssistantAutoLaunch.plist). However, I keep encountering permission errors and BTM policy issues.
Setup Details:
• macOS version: Sequoia 15.3
• Home Assistant installed in: /Users/homeassistant/homeassistant/
• Start script: /Users/homeassistant/homeassistant/start_homeassistant.sh
start_homeassistant.sh:
source /Users/homeassistant/homeassistant/bin/activate
exec hass --debug -v
• LaunchDaemon location: /Library/LaunchDaemons/com.homeassistant.plist
• Main issue: I log in with an administrator account and want to autolaunch the script under homeassistant user.
Errors Encountered:
-
When starting via launchctl (as a daemon) :
Service could not initialize: posix_spawn(/Users/homeassistant/homeassistant/start_homeassistant.sh), error 0xd - Permission denied -
When running manually as homeassistant :
sudo -u homeassistant /Users/homeassistant/homeassistant/start_homeassistant.sh
PermissionError: [Errno 13] Permission denied: ‘/Users/myuser/.homeassistant/home-assistant.log.fault’ -
Previous error when plist was in LaunchAgents :
Service could not initialize: Unable to verify trusted spawn(…), error 0xa1 - Service cannot be launched because of BTM policy
What I’ve Tried:
• Moved plist from LaunchAgents to LaunchDaemons.
• Checked permissions:
sudo chown -R homeassistant:staff /Users/homeassistant/homeassistant
sudo chmod -R 755 /Users/homeassistant/homeassistant
Questions:
-
How can I fix the Permission denied error when running Home Assistant as homeassistant?
-
How do I resolve the BTM policy issue when using launchctl?
-
Is there a recommended way to properly set up Home Assistant as a system service on macOS when launching under a different user?
When I launch all command manually from termianl it works fine.
How to replace the command: sudo -u homeassistant -H -s in plist or in the script?