|
config里面定义两个变量
input_number:
ringalarm:
min: 0
max: 10
step: 1
input_boolean:
kaimen:
initial: off
门开了设置变量kaimen,室内无人加上的话就是从外面开门才报警,里面开门不报警
- alias: open door
initial_state: true
trigger: #开门
- platform: state
entity_id: binary_sensor.door_window_sensor_158dxx
from: 'off'
to: 'on'
# condition:
# condition: state #室内无人
# entity_id: binary_sensor.motion_sensor_158dxx
# state: 'off'
action:
- service: notify.weixin
data: {"title":"门开了。","message":"大门被打开了!"}
- service: input_boolean.turn_on
data:
entity_id: input_boolean.kaimen
kaimen变量on 持续2S 报警 同时把ringalarm设为1
- alias: open door after 2S alarm if cube dont flip90
initial_state: true
trigger:
- platform: state
entity_id: input_boolean.kaimen
from: 'off'
to: 'on'
for:
seconds: 2 #延时可设置
action:
- service: xiaomi_aqara.play_ringtone
data: {"gw_mac":"7C49xx","ringtone_id": "0","ringtone_vol": "100"}
- service: input_number.set_value
data_template:
entity_id: input_number.ringalarm
value: '1'
ringalarm 为1的时候等待8秒(报警声0持续8秒),触发报警声1 并且设定ringalarm 为2
- alias: alarm number alarm
initial_state: true
hide_entity: false
trigger:
- platform: state
entity_id: input_number.ringalarm
to: '1.0'
for:
seconds: 8
action:
- service: xiaomi_aqara.play_ringtone
data: {"gw_mac":"7C49xx","ringtone_id": "1","ringtone_vol": "100"}
- service: input_number.set_value
data_template:
entity_id: input_number.ringalarm
value: '2'
ringalarm 为2的时候等待15秒(报警声1持续15秒),触发报警声2 并且设定ringalarm 为3
- alias: alarm number alarm
initial_state: true
hide_entity: false
trigger:
- platform: state
entity_id: input_number.ringalarm
to: '2.0'
for:
seconds: 15
action:
- service: xiaomi_aqara.play_ringtone
data: {"gw_mac":"7C49xx","ringtone_id": "2","ringtone_vol": "100"}
- service: input_number.set_value
data_template:
entity_id: input_number.ringalarm
value: '3'
ringalarm 为3的时候等待10秒(报警声2持续10秒),触发报警声7 并且设定ringalarm 为1
- alias: alarm number alarm
initial_state: true
hide_entity: false
trigger:
- platform: state
entity_id: input_number.ringalarm
to: '3.0'
for:
seconds: 10
action:
- service: xiaomi_aqara.play_ringtone
data: {"gw_mac":"7C49xx","ringtone_id": "7","ringtone_vol": "100"}
- service: input_number.set_value
data_template:
entity_id: input_number.ringalarm
value: '1'
魔方翻转90度设定 ringalarm为0,停止报警,ringalarm设定多次,是为了确保关闭,另外先翻转再开门可以避免报警
- alias: flip90 disable alarm
initial_state: true
trigger:
- platform: event
event_type: xiaomi_aqara.cube_action
event_data:
entity_id: binary_sensor.cube_158dxx
action_type: flip90
action:
- service: input_boolean.turn_off
data:
entity_id: input_boolean.kaimen
- service: xiaomi_aqara.stop_ringtone
data: {"gw_mac":"7C49xx"}
- service: input_number.set_value
data_template:
entity_id: input_number.ringalarm
value: '0'
- delay: '00:00:02'
- service: xiaomi_aqara.stop_ringtone
data: {"gw_mac":"7C49xx"}
- service: input_number.set_value
data_template:
entity_id: input_number.ringalarm
value: '0'
- delay: '00:00:02'
- service: xiaomi_aqara.stop_ringtone
data: {"gw_mac":"7C49xx"}
- service: input_number.set_value
data_template:
entity_id: input_number.ringalarm
value: '0'
- delay: '00:00:02'
- service: xiaomi_aqara.stop_ringtone
data: {"gw_mac":"7C49xx"}
- service: input_number.set_value
data_template:
entity_id: input_number.ringalarm
value: '0'
|
评分
-
查看全部评分
|