homeassistant & esphome setup

homeassistant & esphome setup


zypper ref
zypper install -y --type pattern devel_basis
zypper in -y python310 python310-base python310-curses python310-devel python310-setuptools python310-pip
python3.10 -m pip install -U wheel
python3.10 -m pip install -U homeassistant esphome

cat <<EOF >> /etc/systemd/system/esphome.service
[Unit]
Description=esphome
After=network.target

[Service]
Type=simple
ExecStartPre=/usr/bin/sleep 30
ExecStartPre=/usr/bin/python3.10 -m pip install -U esphome
ExecStart=/usr/bin/python3.10 /usr/local/bin/esphome dashboard "/root/.esphome"

[Install]
WantedBy=multi-user.target

EOF


cat <<EOF >> /etc/systemd/system/hass.service
[Unit]
Description=Home Assistant
After=network-online.target
Requires=network-online.target

[Service]
Type=notify
Environment=WATCHDOG_USEC=5000000
ExecStartPre=/usr/bin/sleep 30
ExecStartPre=/usr/bin/python3.10 -m pip install -U homeassistant
ExecStart=/usr/bin/python3.10 /usr/local/bin/hass
ExecStop=/usr/bin/kill $MAINPID
WatchdogSec=20
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

EOF

systemctl daemon-reload
systemctl enable --now hass.service esphome.service

On the first run, you should replace Type=notify with Type=simple, then install HACS, and from HACS you should install the “systemd notifier” integrations. Then change back Type=simple to Type=notify and execute systemctl daemon-reload and systemctl restart hass.service.

Содержание