Home Assistant Operation System(簡稱HAOS),是Home Assistant四種安裝方式中功能最完整、對系統的保護性最好但操作上自由度也相對較低的安裝方式。
HAOS將Home Assistant、Supervisor及各種附加元件用docker的方式安裝,例如
➜ ~ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
92b305d9a1dc ghcr.io/hassio-addons/ssh/amd64:17.1.1 "/init" 18 minutes ago Up 18 minutes addon_a0d7b954_ssh
2cf2321d27ce ghcr.io/hassio-addons/phpmyadmin/amd64:0.9.1 "/init" 2 days ago Up 2 days addon_a0d7b954_phpmyadmin
f858b410ef9b thomasmauerer/samba-backup-amd64:5.2.0 "/init /run.sh" 2 days ago Up 2 days addon_15d21743_samba_backup
e4ea11c3e26e smeagolworms4/mqtt-explorer:browser-1.0.3 "/entrypoint.sh /bin…" 2 days ago Up 2 days 4000/tcp addon_9cf1ea8f_mqtt_explorer
a112e0fb87d8 ccab4aaf/amd64-addon-frigate-proxy:1.4 "/init" 2 days ago Up 2 days 0.0.0.0:5000->5000/tcp, :::5000->5000/tcp addon_ccab4aaf_frigate-proxy
d057882e1c4c esphome/esphome-hassio-amd64:2022.3.1 "/init" 2 days ago Up 2 days addon_a0d7b954_esphome
32bf27cf4a02 ghcr.io/hassio-addons/vscode/amd64:5.15.0 "/init" 2 days ago Up 2 days (healthy) addon_a0d7b954_vscode
0437f94dbed6 homeassistant/amd64-addon-samba:12.3.0 "/init" 2 days ago Up 2 days (healthy) addon_core_samba
0ec70eb5b797 homeassistant/amd64-addon-rpc_shutdown:2.4 "/init /run.sh" 2 days ago Up 2 days addon_core_rpc_shutdown
a7529f2e7de4 ghcr.io/hassio-addons/ftp/amd64:5.0.1 "/init" 2 days ago Up 2 days addon_a0d7b954_ftp
3577fafe6e7b homeassistant/amd64-addon-mariadb:2.6.1 "/init" 2 days ago Up 2 days addon_core_mariadb
3bde1413e977 homeassistant/amd64-addon-mosquitto:6.4.0 "/init" 2 days ago Up 2 days 0.0.0.0:1883-1884->1883-1884/tcp, :::1883-1884->1883-1884/tcp, 0.0.0.0:8883-8884->8883-8884/tcp, :::8883-8884->8883-8884/tcp addon_core_mosquitto
459891dfd7e9 ghcr.io/home-assistant/amd64-hassio-multicast:2023.06.2 "/init" 2 days ago Up 2 days hassio_multicast
d90f09c639ed ghcr.io/home-assistant/amd64-hassio-audio:2023.12.0 "/init" 2 days ago Up 2 days hassio_audio
a00f282985a3 ghcr.io/home-assistant/amd64-hassio-dns:2023.06.2 "/init" 2 days ago Up 2 days hassio_dns
8c02786b45ba ghcr.io/home-assistant/amd64-hassio-cli:2023.11.0 "/init" 2 days ago Up 2 days hassio_cli
497477a99115 ghcr.io/home-assistant/qemux86-64-homeassistant:2024.2.3 "/init" 2 days ago Up 2 days homeassistant
c3dabcf308c3 ghcr.io/home-assistant/amd64-hassio-supervisor:latest "/init" 5 days ago Up 2 days hassio_supervisor
9437b6fc3d8c ghcr.io/home-assistant/amd64-hassio-observer:2023.06.0 "/usr/bin/observer" 2 months ago Up 2 days 0.0.0.0:4357->80/tcp, :::4357->80/tcp hassio_observer
這次是在Home Assistant 2024.2版本將python升到3.12版本後,遇到python的construct套件有相容性的問題,部分有使用到construct套件的例如miioprotocol.py會直接報錯如下
ModuleNotFoundError: No module named 'imp'
Home Assistant的python是在container內執行的,我研究了一下想在container內將套件升級,但因為每次重啟就會重新編譯一次container,所以就算是升級了套件,但只要重啟就會回到原來的版本。雖說徒勞無功,但還是記錄一下。
建立SSH連線
安裝官方提供的Advanced SSH & Web Terminal附加元件,只能是Advanced SSH & Web Terminal而不是Terminal & SSH。
裝好後到Advanced SSH & Web Terminal附加元件的設定頁面中填好SSH帳號與密碼,填完後儲存。
回到Advanced SSH & Web Terminal附加元件的資訊頁面,關閉保護模式後啟動附加元件。
SSH連線到HAOS
此時可以透過SSH的軟體(例如Putty或是Powershell之類的)來連線到HAOS,使用者帳號密碼就是在Advanced SSH & Web Terminal附加元件的設定頁面中填好的那一組。
如果在附加元件中有關閉保護模式,執行
$ docker exec -it homeassistant /bin/bash
就可以進入Home Assistant Container了。