本帖最后由 kmule 于 2024-8-15 01:42 编辑
目前浴室有两个人体存在传感器,买的传感器是个自制牌子,通过xiaomi gateway3接入,显示是两个开关,有人就开没人就关。目前都装在卫生间(由于卫生间形状奇怪需要两个传感器前两个是传感器,后两个是灯):
现在想写一个自动化流程,两个传感器都关闭才关灯,写成这样,单个传感器关闭后,且的条件根本不判断就直接关灯了,求助应该如何判断另一个开关目前状态呢?谢谢大佬。
description: ""
trigger:
- platform: device
type: turned_off
device_id: 6f44168d1434fcbf5aef5c1289c27a4a
entity_id: 3388d14fb3e19ad05729e8c3fcbd9abb
domain: switch
condition:
- condition: device
type: is_off
device_id: c8d360e12573b220a0edd5d6b815434c
entity_id: 52d7c2789d53cbc3d2f7e1ef7252cfe9
domain: switch
action:
- type: turn_off
device_id: ae714c6e592daa77166e549b5a229839
entity_id: 9df03046bf240d362b5a4fe518ad4c2f
domain: switch
mode: single
以下是另一种写法,也不行:
description: ""
trigger:
- platform: device
type: turned_off
device_id: 6f44168d1434fcbf5aef5c1289c27a4a
entity_id: 3388d14fb3e19ad05729e8c3fcbd9abb
domain: switch
condition:
- condition: state
state: "off"
entity_id: select.7cc2944ea15e_command
action:
- type: turn_off
device_id: ae714c6e592daa77166e549b5a229839
entity_id: 9df03046bf240d362b5a4fe518ad4c2f
domain: switch
mode: single
已解决,不能用command,要直接用设备状态:如下段:
alias: 新建自动化
description: ""
trigger:
- platform: device
type: turned_off
device_id: 6f44168d1434fcbf5aef5c1289c27a4a
entity_id: 3388d14fb3e19ad05729e8c3fcbd9abb
domain: switch
condition:
- condition: state
state: "off"
entity_id: switch.7cc2944ea15e_switch
action:
- type: turn_off
device_id: ae714c6e592daa77166e549b5a229839
entity_id: 9df03046bf240d362b5a4fe518ad4c2f
domain: switch
mode: single
|