2
30
226
中级会员
使用道具 举报
14
255
2364
金牌会员
switch: - platform: output id: autoopendoorlock name: "自动开锁模式" output: 'autounlock' on_turn_on: - if: condition: lambda: return (id(sounddoor).state)); then: - logger.log: "ON" else: - logger.log: "OFF" - if: condition: binary_sensor.is_on: sounddoor #自动开锁模式开关打开时,if sounddoor触发 then 触发开锁按钮一次 then: button.press: unlockbutton
24
617
3087
论坛元老
switch: - platform: output id: autoopendoorlock name: "自动开锁模式" output: 'autounlock' on_turn_on: if: condition: binary_sensor.is_on: sounddoor #自动开锁模式开关打开时,if sounddoor触发 then 触发开锁按钮一次 then: button.press: unlockbutton
book123 发表于 2024-2-27 16:31 查看binary_sensor的在switch打开时的状态,试试下面代码看看,我没有验证,攻参考: ...
output: - platform: gpio pin: 0 id: 'unlock' #解锁/开锁开关定义位gpio0=继电器 inverted: true #低电平输出 - platform: gpio pin: 2 id: 'autounlock' #解锁/开锁开关定义位gpio2=板载指示灯 inverted: true #低电平输出 switch: - platform: output id: autoopendoorlock name: "自动开锁模式" output: 'autounlock' on_turn_on: then: - delay: 15min - switch.turn_off: autoopendoorlock - logger.log: "打开后计时15min,自动关闭" button: - platform: output id: unlockbutton name: "开锁" icon: "mdi:lock" output: 'unlock' duration: 500ms binary_sensor: #检测单元门呼叫rx引脚 gpio3 - platform: gpio id: sounddoor pin: number: 3 inverted: true mode: input: true pullup: true #内部上拉 name: "响铃" device_class: sound filters: - delayed_on: 500ms #100ms延时滤波 - delayed_off: 300ms on_press: - if: condition: lambda: return id(autoopendoorlock).state; then: lambda: id(unlockbutton).press();
leeh 发表于 2024-2-27 18:15 非常感谢你的帮助,我把逻辑写到sounddoor的传感器里就好了。我一会找cpp文件看下估计就知道什么问题了。 ...
本版积分规则 发表回复 回帖后跳转到最后一页
Archiver|手机版|小黑屋|Hassbian ( 晋ICP备17001384号-1 )
GMT+8, 2025-5-15 09:16 , Processed in 0.751453 second(s), 21 queries .
Powered by Discuz! X3.5
© 2001-2025 Discuz! Team.