使用 HA 的 Alarm 元件, 控制是否啟動告警功能
https://www.home-assistant.io/components/manual/
搭配 HA 自動化, 以小米門窗感應或是人體感應做觸發
(觸發時確認 alarm 元件是否處於 armed_away 狀態)
完成觸發後則控制小米網關告警/開關電燈/發送通知等動作
以下代碼取自上頭的 alarm 元件說明網頁
automation:
- alias: 'Trigger alarm while armed away'
trigger:
- platform: state
entity_id: 小米門窗感應
to: 'on'
- platform: state
entity_id: 小米人體感應
to: 'on'
condition:
- condition: state
entity_id: alarm_control_panel.ha_alarm
state: armed_away
action:
service: alarm_control_panel.alarm_trigger
entity_id: alarm_control_panel.ha_alarm
|