Trigger http update by a rule

I am using OH3 with the http binding. I use it to send command via an optical interface to by heater.
Unfortunately that fails now and again so I thought I could do a write - read back operation.

like e.g.

I know delays are evil, but the pseudo code of the intended function is:

while ( heaterstatus != "automatic) {

Is there a way to initiate a http channel update (like triggerUpdate) from a rule ?

Just send the right command. :slight_smile:

The while loop is a bad idea though. It can cause the rule to completely stop working.

Well, that was pseudo code. The problem is, that the heater sometimes does not receive the command and therefore I need to implement some verification.

Is there something like



No, there is no triggerUpdate() command, just a sendCommand(). You have to send the command over and over again until it is executed correctly.

a rule for that issue:

var Timer tHeatSwitch = 0
var strHeatCommand = "none"

rule "set heater reliably"
    Item heater received command
    strHeatCommand = receivedCommand.toString
    tHeatSwitch = createTimer(now.plusSeconds(10),[|
        if(heaterstatus.state.toString != strHeatCommand)

If command and resulting status are different, you have to incorporate that in an appropriate way, e.g. a hashmap to get the expected status for the received command.

Some additional info:

  • As it’s http, please keep in mind that it takes some time to send and receive. There is a timeout parameter, the timer loop should be at least twice as long as the timeout.
  • This rule will trigger itself, so no need to do it via rescheduling the timer.
  • If done correctly, you will only need one rule for all commands to this item.
  • If you are using more than one of this items, it’s possible to create a rule which will take care of all of them, but it will be way more complex, so if you don’t use a mass of them, just create one rule for each item of that kind.