本帖最后由 余歌唱晚 于 2019-10-17 00:04 编辑
之前看到了raspberry0316 发表的 修改小米网关警戒在home app里的图标 这篇佳作地址:https://bbs.hassbian.com/thread-8156-1-1.html
可以在HomeKit界面同步小米网关警戒开关
受益匪浅……
本着活着就是折腾的精神
查阅群资料,借鉴另一大神 luzai 发布的 set_state 服务插件需要将 domain修改一下 改为 DOMAIN = 'alarm_control_panel'
地址:https://bbs.hassbian.com/thread-3870-1-1.html
通过直接识别及修改alarm_control_panel的state 来达到状态双向控制,根据条件执行在家 外出 夜间 三种警戒模式
示例配置:
configuration.yaml
alarm_control_panel:
- platform: manual
name: home
code: 0369
pending_time: 10
delay_time: 20
trigger_time: 4
disarmed:
trigger_time: 0
armed_home:
pending_time: 0
delay_time: 0
HomeKit如果设置过滤 在 include_domains: 加入alarm_control_panel
自动化设置代码已经OK 之前错误的使用了IOS设备追踪生成的设备 ios设备始终显示home wifi判断错误
现在已经完成正常使用 折腾了好多模板 原来是实体错误
######################################################
#HomeKit警戒同步
# ###HomeKit控制开关小米警戒
- alias: alarm_sync_mi
initial_state: true
trigger:
platform: state
entity_id: alarm_control_panel.home
action:
service_template: >
{% if states.alarm_control_panel.home.state == 'disarmed' %}
switch.turn_off
{% else %}
switch.turn_on
{% endif %}
entity_id: switch.xiaomi_gateway_alarm
##小米网关警戒开关同步HomeKit警戒状态
##关闭警戒
- alias: alarm_close
trigger:
- platform: state
entity_id: switch.xiaomi_gateway_alarm
from: 'on'
to: 'off'
action:
- service: alarm_control_panel.set_state
data:
entity_id: alarm_control_panel.home
state: 'disarmed'
##在家警戒
- alias: alarm_arm_home
trigger:
- platform: state
entity_id: switch.xiaomi_gateway_alarm
from: 'off'
to: 'on'
# for:
# minutes: 2
condition:
condition: and
conditions:
- condition: time
after: '08:00'
before: '21:00'
- condition: or
conditions:
- condition: state
entity_id: device_tracker.*
state: 'home'
- condition: state
entity_id: device_tracker.*
state: 'home'
action:
- service: alarm_control_panel.set_state
data:
entity_id: alarm_control_panel.home
state: 'armed_home'
##夜间警戒
- alias: alarm_arm_night
trigger:
- platform: state
entity_id: switch.xiaomi_gateway_alarm
from: 'off'
to: 'on'
# for:
# minutes: 3
condition:
condition: and
conditions:
- condition: time
after: '21:01'
before: '07:59'
- condition: or
conditions:
- condition: state
entity_id: device_tracker.*
state: 'home'
- condition: state
entity_id: device_tracker.*
state: 'home'
action:
- service: alarm_control_panel.set_state
data:
entity_id: alarm_control_panel.home
state: 'armed_night'
##外出警戒
- alias: alarm_arm_custom_bypass
trigger:
- platform: state
entity_id: switch.xiaomi_gateway_alarm
from: 'off'
to: 'on'
# for:
# minutes: 3
condition:
condition: and
conditions:
# - condition: time
# after: '00:00'
# before: '23:59'
- condition: state
entity_id: device_tracker.*
state: 'not_home'
- condition: state
entity_id: device_tracker.*
state: 'not_home'
action:
- service: alarm_control_panel.set_state
data:
entity_id: alarm_control_panel.home
state: 'armed_away'
|