【问题标题】:Control relay with contact button on Openhab problem在 Openhab 问题上使用接触按钮控制继电器
【发布时间】:2018-10-05 11:39:03
【问题描述】:

喂,

我想用 openHab 中的按钮控制继电器,我想创建一个规则来检查状态是打开还是关闭,然后再做一件事。

我是编码新手,我不知道我做错了什么。

我需要一些帮助。

这是来自 home.items 的代码

    Switch buc1_releu "Bec1" (LivingRoom) { gpio="pin:18 activelow:yes initialValue:high force:true" }
    Contact buc1_intrerupator "Intrerupator [%s]" (LivingRoom) { gpio="pin:23 activelow:yes" }

这就是 home.rules

rule "buc1"
when
    Item buc1_intrerupator changed
then
       if (buc1_releu.state == ON){
        sendCommand(OFF)
    }
    else if (buc1_releu.state == OFF){
        sendCommand(ON)
    }
end

【问题讨论】:

    标签: openhab


    【解决方案1】:

    发现问题,这是正确的代码:D

    rule "buc1"
    when
        Item buc1_intrerupator changed
    then
        if (buc1_releu.state == ON) {
            buc1_releu.sendCommand(OFF)
        }
        else if (buc1_releu.state == OFF) {
            buc1_releu.sendCommand(ON)
        }
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多