Home Assistant on M1 Mac is not well documented. I hope we can change that.
Please criticize and improve this method.
No warranties, make backups, expect everything.
My user is called “server”, change accordingly.
Why this method
- Docker on macOS can’t use USB/Serial devices.
- M1 Macs use virtual machines in emulation mode which is not efficient (25 % CPU with UTM on idle)
- Raspberry Pi and similar devices can’t offer the flexibility and power of an existing Mac.
Install Node.JS LTS for macOS
Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install Python3 on macOS
brew install python3
Install libjpeg-turbo
brew install jpeg-turbo
Install make - required since 2023.12 uses make to install zlib-ng
brew install make
Install python virtual environment (venv) and Home Assistant
pip3 install virtualenv
cd ~/
python3 -m venv homeassistant
source homeassistant/bin/activate
pip3 install homeassistant
deactivate
Config is saved in ~/.homeassistant
Install Yarn compiler
npm install --global yarn
Compile ZWaveJS2MQTT for M1
git clone https://github.com/zwave-js/zwavejs2mqtt
cd zwavejs2mqtt
yarn install
yarn run build
Manual start or restart (optional)
cd ~/zwavejs2mqtt
yarn start
source ~/homeassistant/bin/activate
~/homeassistant/bin/hass
Run Home Assistant and ZWaveJS2MQTT as services at startup
start service
launchctl load /Users/server/Library/LaunchAgents/org.homeassistant.plist
launchctl load /Users/server/Library/LaunchAgents/org.zwavejs2mqtt.plist
stop service
launchctl unload /Users/server/Library/LaunchAgents/org.homeassistant.plist
launchctl unload /Users/server/Library/LaunchAgents/org.zwavejs2mqtt.plist
manual start
launchctl start org.homeassistant
launchctl start org.zwavejs2mqtt
manual stop
launchctl stop org.homeassistant
launchctl stop org.zwavejs2mqtt
Make
~/Library/LaunchAgents/org.homeassistant.plist
<?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:/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/server/.homeassistant/scripts/ha_agent.sh</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Make
~/Library/LaunchAgents/org.zwavejs2mqtt.plist
<?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.zwavejs2mqtt</string>
<key>ProgramArguments</key>
<array>
<string>bash</string>
<string>-c</string>
<string>cd /Users/server/zwavejs2mqtt; yarn start</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Make
~/.homeassistant/scripts/ha_agent.sh
#!/bin/bash
sleep 60
source /Users/server/homeassistant/bin/activate
/Users/server/homeassistant/bin/hass
Make it executable:
chmod 711 ~/.homeassistant/scripts/ha_agent.sh
Backup procedure
Make sure to backup these folders regularly:
~/.homeassistant
~/homeassistant
~/zwavejs2mqtt
Or automate it:
caffeinate rsync -E -a --delete "/Users/server/homeassistant" "/Volumes/Backup/server"
caffeinate rsync -E -a --delete "/Users/server/.homeassistant" "/Volumes/Backup/server"
caffeinate rsync -E -a --delete "/Users/server/zwavejs2mqtt" "/Volumes/Backup/server"
Update procedures
Update Homebrew and all its packages (including Python3) and clean caches
brew update
brew upgrade
brew autoremove
brew cleanup --prune=all
Update Node.JS and npm
sudo npm install --global yarn
sudo npm install -g npm@latest
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
Stop services
launchctl stop org.homeassistant
Update Python virtual environment (venv)
pip3 install --upgrade pip
pip3 install virtualenv
python3 -m venv ~/homeassistant
Install Home Assistant Core
rm -rf ~/homeassistant_old
mv ~/homeassistant ~/homeassistant_old
cd ~/
python3 -m venv homeassistant
source homeassistant/bin/activate
pip3 install --upgrade pip
pip3 install homeassistant
deactivate
Update ZWaveJsMQTT
rm -rf ~/zwavejs2mqtt_old
cp ~/zwavejs2mqtt ~/zwavejs2mqtt_old
cd ~/
#sudo npm install --global yarn
git clone https://github.com/zwave-js/zwavejs2mqtt
cd ~/zwavejs2mqtt
yarn install
yarn run build
Update custom addons
~/.homeassistant/custom_components
Automation example - be very careful and adapt
rm -rf ~/Desktop/tmp
mkdir ~/Desktop/tmp
cd ~/Desktop/tmp
curl -L "https://github.com/USER/REPOSITORY/archive/refs/heads/NAME.zip" >file.zip
unzip file.zip
rm file.zip
mv * git_tmp
mv git_tmp/custom_components/*/ ~/Desktop/ha_tmp
rm -rf ~/Desktop/tmp
rm -rf ~/.homeassistant/custom_components/REPOSITORY
mv ~/Desktop/ha_tmp/* ~/.homeassistant/custom_components
rm -rf ~/Desktop/ha_tmp
Restart Services after update or restart macOS
launchctl stop org.homeassistant
launchctl start org.homeassistant
launchctl stop org.zwavejs2mqtt
launchctl start org.zwavejs2mqtt
Quirks with macOS
Add this code to configuration YAML for video support on HomeKit
ffmpeg:
ffmpeg_bin: /opt/homebrew/bin/ffmpeg
PLEASE report any bugs or improvements that I could do. I will add all improvements to this page.