Rule changing/setting a switch is ignored

  • Platform information:

    • Hardware: Raspberry 3B
    • OS: Openhabianpi
    • Java Runtime Environment: openjdk version “1.8.0_265”
    • openHAB version: 2.5.9.-1
  • Issue of the topic: I want to start a PC via Openhab and manually. The script starting the PC via GPIO -> Relais-Module works well. I want the switch to be changed when the PC returns a ping. Therefore I added a first rule with a logging info, but when the Item changes the rule is not entered.

  • Please post configurations (if applicable):

    • Items configuration related to the issue

Switch Cubic “Cubic [%s]”
Switch cubic_Run {channel=“exec:command:cubic:run”, autoupdate=“false”}
String cubic_Args {channel=“exec:command:cubic:input”}
Switch CubicPing { channel=“network:pingdevice:cubic:online” }
Number:Time CubicResponseTime { channel=“network:pingdevice:cubic:latency” }

  • Sitemap configuration related to the issue

sitemap cubic label=“Cubic Buttons”


    Frame {

        Switch item=Cubic

        //Text item=YourNumber


Frame {

    Text item=CubicPing label="ping cubic [%s]"

    Text item=CubicResponseTime label="Cubic Response Time [%s]"



  • Rules code related to the issue

rule “ping state changed”


Item CubicPing changed


if (CubicPing == OFF) 





if (CubicPing == ON) 






  • Services configuration related to the issue
  • If logs where generated please post these here using code fences:

2020-10-18 17:23:22.348 [vent.ItemStateChangedEvent] - CubicPing changed from NULL to ON

2020-10-18 17:23:22.414 [vent.ItemStateChangedEvent] - CubicResponseTime changed from NULL to 21.0 ms

2020-10-18 17:23:53.001 [vent.ItemStateChangedEvent] - CubicResponseTime changed from 21.0 ms to 20.0 ms

2020-10-18 17:24:53.078 [vent.ItemStateChangedEvent] - CubicResponseTime changed from 20.0 ms to 22.0 ms

2020-10-18 17:25:53.155 [vent.ItemStateChangedEvent] - CubicResponseTime changed from 22.0 ms to 24.0 ms

The result is shown in the Screenshot of the Basic-UI. Ping works well but the switch still shows / thinks the PC is off. The switch should also switch to ON if the ping changes to ON. The same with OFF.

I think it has something with the “autoupdate” to do.

Thanks in advance for any hint.

regards Dirk

Hi Dirk,

Autoupdate is not causing your problems (yet!). If you do some testing by putting a call to logInfo in your rule but outside of the if statements, I think you’ll find that your rule is running, it’s just not triggering either of the if statements. That has to do with what you are testing.

CubicPing is an item and as such will never equal ON or OFF (which are states) but is an object with many properties and methods of which state is only one. You want to know if the state of CubicPing is ON or OFF

if (CubicPing.state == OFF)

Once your if statements are formatted correctly, then you might start to see some unusual behavior from the rule due to autoupdate, and you can get around that either by setting autoupdate for CubicPing to false or by using the implicit variables available to you in rules.

receivedCommand is the variable that you would want to use here, so that instead of relying on the timing of CubicPig actually changing state, your if statements can react to what the eventual state of CubicPing will be whenever it gets around to updating.

On a stylistic note: it will be easier for everyone to read your posts and help you if you use code fences on all your logs and configuration text.

1 Like

Thanks for the “Item.state” hint.

And my next topic has Code fences.

regards, Dirk