Item switched autom. after reboot

  • Platform information:
    • Hardware: Pi 4B
    • OS: openhabian
    • openHAB version: OH3

I create a rule to turn my Hue-light-strip on and off by a shelly relay switch.
In OH2.5 it worked fine.

when
         Item Schlafzimmer_Bettlicht_Wandschalter received update
then
    if (Schlafzimmer_Bettlicht.state == ON) {
        Schlafzimmer_Bettlicht.sendCommand(OFF) } else
        Schlafzimmer_Bettlicht.sendCommand(ON)
end

After upgrade to OH3 the light ist turning on after reboot (cron or manuel) by itself.

What i have tried:

  • delete the rule -> solved
  • delete the Item an try it with an Hue Switch (State 4001.0) -> still existing
  • change the values to:
then
    if (Schlafzimmer_Bettlicht.state == OFF) {
        Schlafzimmer_Bettlicht.sendCommand(ON) } else
        Schlafzimmer_Bettlicht.sendCommand(OFF)

-> after reboot the light is still OFF but if its on at reboot it switched OFF

  • change it to:
rule "Bettlicht Wandschalter steuert Bettlicht"
when
    Item Schlafzimmer_Bettlicht_Wandschalter changed from ON to OFF or
    Item Schlafzimmer_Bettlicht_Wandschalter changed from OFF to ON
then
    if (Schlafzimmer_Bettlicht.state == ON) {
        Schlafzimmer_Bettlicht.sendCommand(OFF) } else
        Schlafzimmer_Bettlicht.sendCommand(ON)
end

-> not fixed

  • changed to:
when
         Item Schlafzimmer_Bettlicht_Wandschalter received command
then
    if (Schlafzimmer_Bettlicht.state == ON) {
        Schlafzimmer_Bettlicht.sendCommand(OFF) } else
        Schlafzimmer_Bettlicht.sendCommand(ON)
end

Does anyone know the prob or the solution?

edit: - I tryed to reset the light and connect it new but it doesnt solve the problem. I think the problem is, that OH3 starts the rule after reboot. Why?

  • do you use persistence ? using persistence in your setup it should be possible to get back the latest state of an item
  • in case of your described approach I would add a statement to write debug information to the logfile. Doing that you will get more information about the state of the item after the reboot. Assumed the state is neither ON nor OFF ( UNDEF, NULL ) what do you expect your rules to do then ?
  • After Reboot the first state is NULL and then switched to the state, thet the Shely is sending.
  • i only want do do an action if the state ist changed from ON to OFF or from OFF to ON
when
Item Schlafzimmer_Bettlicht_Wandschalter changed from ON to OFF or
Item Schlafzimmer_Bettlicht_Wandschalter changed from OFF to ON
then

More info here.

i tried this (see initial post) and it doesnt solve the problem.

What about it doesn’t work? Isn’t it exactly

?

No, the Problem is thet the Light ist changing his status after reboot.
The light ist off and the Pie reboot -> the light turns on