binary_sensor:
- platform: gpio
pin:
number: $ld01_pin
mode:
input: true #将引脚配置为输入。
pulldown: true #激活引脚上的内部下拉电阻。
name: "ld01" #有线双鉴人体传感器
id: "ld01"
on_press:
then:
- if:
condition:
- binary_sensor.is_off: statusid #当二进制传感器为off的时候
then:
- if:
condition:
- binary_sensor.is_off: cba #当二进制传感器为off的时候
then:
- binary_sensor.template.publish: #cba传感器发布on
id: cba
state: ON
- platform: gpio
pin:
number: $ld02_pin
mode:
input: true #将引脚配置为输入。
pulldown: true #激活引脚上的内部下拉电阻。
name: "ld02" #有线双鉴人体传感器
id: "ld02"
on_press:
then:
- if:
condition:
- binary_sensor.is_off: statusid #当二进制传感器为off的时候
then:
- if:
condition:
- binary_sensor.is_off: cba #当二进制传感器为off的时候
then:
- binary_sensor.template.publish: #cba传感器发布on
id: cba
state: ON
- platform: gpio
pin:
number: $ld03_pin
mode:
input: true #将引脚配置为输入。
pulldown: true #激活引脚上的内部下拉电阻。
name: "ld03" #有线双鉴人体传感器
id: "ld03"
on_press:
then:
- if:
condition:
- binary_sensor.is_off: statusid #当二进制传感器为off的时候
then:
- if:
condition:
- binary_sensor.is_off: cba #当二进制传感器为off的时候
then:
- binary_sensor.template.publish: #cba传感器发布on
id: cba
state: ON
- platform: gpio
pin:
number: $ld04_pin
mode:
input: true #将引脚配置为输入。
pulldown: true #激活引脚上的内部下拉电阻。
name: "ld04" #有线双鉴人体传感器
id: "ld04"
on_press:
then:
- if:
condition:
- binary_sensor.is_off: statusid #当二进制传感器为off的时候
then:
- if:
condition:
- binary_sensor.is_off: cba #当二进制传感器为off的时候
then:
- binary_sensor.template.publish: #cba传感器发布on
id: cba
state: ON
- platform: status #设备联机状态
name: "status"
id: "statusid"
- platform: template
name: "abc"
id: cba
on_press:
then:
- script.execute: my_script
- delay: 30s
- binary_sensor.template.publish: #30秒后关闭模板传感器
id: cba
state: Off
switch:
- platform: gpio
pin: $relay1_pin
name: "relay1" #继电器
id: "relay1"
script:
- id: my_script
mode: restart #每次执行都是重置的模式
then:
- switch.turn_on: relay1
- delay: 300s
- if:
condition:
- binary_sensor.is_off: statusid #当二进制传感器为off的时候
then:
- switch.turn_off: relay1
|