其实我还是没有搞清楚你到底什么要求 我加上注释了 你自己看着理解吧
binary_sensor:
- platform: gpio
pin:
number: 14
mode: INPUT_PULLUP
name: "SWITCHguodao"
id: kaiguan
on_state:
- if:
condition: #检查条件
and:
- binary_sensor.is_on: pir501
- binary_sensor.is_on: kaiguan
then: #id为pir501和kaiguan同时状态为on的时候 执行发布id为trigger的传感器状态为on
- binary_sensor.template.publish:
id: trigger
state: on
else: #id为pir501和kaiguan没有同时状态为on的时候 执行发布id为trigger的传感器状态为off
- binary_sensor.template.publish:
id: trigger
state: off
- platform: gpio
pin:
number: 12
mode: INPUT_PULLUP
name: "erlouganyingqi"
device_class: motion
id: pir501
filters:
- delayed_off: 10s #延迟10秒发布状态为off
on_press: #按下时 对id为trigger的传感器发布状态on
then:
- logger.log: "Detected somebody activity"
- binary_sensor.template.publish:
id: trigger
state: on
on_release: #松开时 对id为trigger的传感器发布状态off
- logger.log: "There is no one around"
- binary_sensor.template.publish:
id: trigger
state: on
- platform: template
name: "Infrared sensor"
id: trigger
device_class: motion
on_press:
- switch.turn_on: relay
on_release:
- switch.turn_off: relay
switch:
- platform: gpio
name: "SWITCHguodao"
pin: GPIO4
id: relay
|