安裝 configurator,這個方便可以直接線上修改相關的設定。
安裝方式很簡單,依照下面步驟:
1. Supervisor -> ADD-ON Store
2. Search 輸入 Configurator
3. 點擊 Configurator,再點擊 INSTALL
4. 安裝完畢,勾選 Show in sidebar,這樣左側選單就會出現 Configurator 快捷按鈕
5. 點擊 START
這樣就安裝完畢了。
建議安裝完 Hass.io 後可以先安裝這個插件。
安裝 configurator,這個方便可以直接線上修改相關的設定。
安裝方式很簡單,依照下面步驟:
1. Supervisor -> ADD-ON Store
2. Search 輸入 Configurator
3. 點擊 Configurator,再點擊 INSTALL
4. 安裝完畢,勾選 Show in sidebar,這樣左側選單就會出現 Configurator 快捷按鈕
5. 點擊 START
這樣就安裝完畢了。
建議安裝完 Hass.io 後可以先安裝這個插件。
Let’s Encrypt 可對 domain 做憑證以便後續的功能使用以及遠端登入可以提供更加的安全性。
如果沒有自己的 domain name,可以至 duckdns 免費申請。
Let’s Encrypt 有一個限制就是至少每 30-40 天必須更新憑證。
因此如果所使用的 domain 是從 duckdns 申請的,可以考慮安裝另外一個 addon - Duck Dns
這邊我只安裝 Let’s Encrypt 來做 domain 的憑證。domain 的部份則交由我另外一個地方的主機來做更新。
安裝 Let’s Encrypt
1. Supervisor -> ADD-ON STORE
2. Search Let’s 找到後點進去並點擊 INSTALL
3. 安裝完畢,不要勾選 Start on boot
4. config 依照實際需求修改,設定好後點擊右下 Save
email: abc@example.com
domains:
- test.duckdns.org
certfile: fullchanin.pem # 不要修改
keyfile: privkey.pem # 不要修改
challenge: http # 依照需求可改成 dns,這邊我是使用 http
dns: {} # 依照需求修改
申請成功後,開啟 configuration.yaml,加上以下的部份。
http: base_url: test.duckdns.org:8123 ssl_certificate: /ssl/fullchain.pem ssl_key: /ssl/privkey.pem
重啟 hass,這樣就可以使用 https 連線了,且也不能再使用 http 連線了。
遠端連線方式變成: https://test.duckdns.org:8123
本地端連線就要改成: https://本地端IP:8123
另外建議備份 config/addons/data/ 裡面的 core_letsencrypt 這個目錄,裡面有相關的憑證以及認證訊息。
這個可以在重新安裝時直接把這些資料覆蓋回去,這樣就不用重新申請憑證。
太頻繁申請憑證會暫時無法申請。
由於 Let’s encrypt 只用於申請憑證並沒有定時自己更新的功能。
因此需要加上自動更新的功能。
開啟 automations.yaml,加上以下的部份。
這會定期在每天晚上 11 點重新做憑證更新的動作。
憑證更新的部份會先檢查是否需要更新,如果有需要才會更新,
沒有需要則直接結束。
- id: 'system_lets_encrypt_renewal'
alias: "[ System ] Let's Encrypt Renewal"
trigger:
- platform: time
at: '23:00:00'
action:
- service: hassio.addon_restart
data:
addon: core_letsencrypt
Hass 重啟後,發現部份 automation 會被觸發。
比如當某人到某個區域時會自動送訊息給我。
automation:
- id: 'notify_me_when_someone_is_arrived_at'
alias: 'notify_me_someone_is_arrived'
description: ''
trigger:
- platform: state
entity_id: device_tracker.someone
to: 'Work'
acton:
- service: notify.mobile_app_me_mobile
data_template:
message: 'Someone is arrived'
看起來很正常。
但是在以下狀況卻會發生問題。
如果 someone 已經在 Work 這個地方,當我重啟 Hass 則會再觸發一次這個 automation。
原因是當重啟時,Hass 會重新設定這個 device_track 的狀態,導致就觸發了這個 automation。
解決方式如下
automation:
- id: 'notify_me_when_someone_is_arrived_at'
alias: 'notify_me_someone_is_arrived'
description: ''
trigger:
- platform: state
entity_id: device_tracker.someone
to: 'Work'
condition:
- condition: template
value_template: '{{ true if trigger.from_state is not None else false }}'
acton:
- service: notify.mobile_app_me_mobile
data_template:
message: 'Someone is arrived'
–
參考連結
Based on these posts:
目前我安裝 raspbian os 在 Raspberry Pi 3 B+,並且在此之上再安裝 hass.io。
不直接使用 hass.io 的原因是 raspbian 本身是 debian base,平常我電腦也是使用 debian,
這樣對我來說操作彈性更大。
以下是安裝方式:
安裝基本環境,這邊要特別注意的是 network-manager 預設會使用 wifi 動態來連線,所以如果有使用 router 鎖 mac 或者把 mac 綁在某個固定 IP 的記得參考此篇。
sudo -i apt-get install software-properties-common apt-get update apt-get install -y apparmor-utils apt-transport-https \ avahi-daemon ca-certificates curl dbus \ jq network-manager socat systemctl disable ModemManager # ModemManager 會對 Z-wave 和 Zigbee 影響,因此關閉也可以移除。 curl -fsSL get.docker.com | sh
以下 script 會需要使用到 root 權限,建議先切換至 root 後再執行。-d 後面是 hass.io 儲存資料的位置,建議選擇自己容易備份的地方。
curl -o hassio_install.sh -sL "https://raw.githubusercontent.com/home-assistant/hassio-installer/master/hassio_install.sh" chmod +x hassio_install.sh ./hassio_install.sh -m raspberrypi3 -d /home/me/hassio_data
安裝完畢後,輸入網址 http://[hostip]:8123,然後等待建置完畢後就可以建立帳號登入了。hostip 是安裝設備的 IP。
Based on these posts:
Hass.io 支援 google assistant 有兩種方式
這邊我採用手動加入的方式。以下為手動加入步驟。(使用手動加入前提是必須可使用 hostname 和有效的 ssl 憑證,這部分可以使用 duckdns addon 達成)
至 Actions on Google console 建立專案。
點擊 New Project。Project Name 則輸入你想要的英文名稱,再設定語言跟所在國家或地區。然後點擊 Create Project。
點擊 Smart Home,並且再點擊 Smart Home Recommended。
點擊 Build your Action 再點擊 Add Actions(s)
填入以下資訊
點擊 Setup account linking 連結帳號以便 google home 可以連結到你設定的專案。
勾選 No, I only want to allow account creation on my website,點擊 Next。
Select linking type 選擇 OAuth,Select grant type 選擇 Authorization code。點擊 Next。
填入以下資訊
Scopes 輸入 name 再點擊 Add scope,然後再輸入 email 再點擊 Add scope。記得確認 Google to transmit clientID and secret via HTTP basic auth header 不可勾選,然後點擊 Next。
Testing instructions 可隨便輸入。 然後點擊右下角 Save。
點擊上方 Develop,Display name 輸入你想要看到在 Google Home 做第三方連結時的名稱。然後點擊右上方 Save。
點擊上方 Test,這會產生一個測試的 app 版本,這可以讓我們從 Google Home 連結。
至 Google Could Console 建立服務帳號,這在 Home assistant 設定時會使用到。
上方選取專案。選擇前面所建立的專案。
點擊左方憑證。點擊建立憑證後再選取服務帳戶金鑰。
服務帳戶設定如下:
啟用 HomeGraph API。
開啟 configuration.yaml。設定範例如下,仔細設定可參考 configuration。
google_assistant:
project_id: YOUR_PROJECT_ID
service_account: !include SERVICE_ACCOUNT.JSON
report_state: true
expose_by_default: false
entity_config:
light.living_room:
expose: true
aliases:
- LIGHT
開啟 Google Home,點擊左上角 +,
開啟 google assistant 輸入或說出 sync my devices。
開啟 Google Home 就可以看到所增加的物件了。
File “/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/letsencrypt/storage.py”, line 273, in _check_symlinks
“expected {0} to be a symlink”.format(link))
CertStorageError: expected /etc/letsencrypt/live/example.org/cert.pem to be a symlink
這原因是當 Let's Encrypt 更新憑證時,會將 live/example.org/cert.pem 做 symbolic link 到 archive/example.org 裡面 certX.pem (x 表示數字,越大越新)。rm -f live/example.org/*.pem ln -sf archive/example.org/certX.pem live/example.org/cert.pem ln -sf archive/example.org/chainX.pem live/example.org/chain.pem ln -sf archive/example.org/fullchainX.pem live/example.org/fullchain.pem ln -sf archive/example.org/privkeyX.pem live/example.org/privkey.pem
device_tracker:
- platform: nmap_tracker
# global config
interval_seconds: 15
consider_home: 180
new_device_defaults:
track_new_devices: false
hide_if_away: false
# config for nmap_tracker
hosts: # network address to scan
- 192.168.1.1/24
home_interval: 10 # if it is home, not scan this device at least 10 mins
exclude: # not to scan this device
- 192.168.1.1
2. restart hass.io11_22_33_44_55_66: hide_if_away: false icon: mac: 11:22:33:44:55:66 name: 11 22 33 44 55 66 picture: track: false 22_22_33_44_55_66: hide_if_away: false icon: mac: 22:22:33:44:55:66 name: 22 22 33 44 55 66 picture: track: false
me: hide_if_away: false icon: mac: 11:22:33:44:55:66 name: me picture: track: true her: hide_if_away: false icon: mac: 22:22:33:44:55:66 name: her picture: track: true4. go Configuration -> Persons, Click on the account, and select Track Device, in this case, choose device_tracker.me
person:
- name: Her
id: her1224 # this must be unique.
device_trackers:
- device_tracker.her
6. go Configuration -> Persons to check if add successfully.