Multi State Switches

To restate your problem, when the real device bound to OG_Nazar_Licht changes state, but the change wasn’t just commanded by openHAB, you want to take a special action.

But openHAB is event driven, stateless. There is no easy way to remember that it’s just sent a command (also, how long is “just” anyway).

One way is to have two Items - one linked to the real device, and one dummy for rules to send commands to. If the real device changes state to match the dummy, it was an openHAB action.If they don’t match, it was a physical button press.

//Physical Switch
Switch OG_Nazar_Licht 	"Licht Nazar" <light> {channel="zwave:device:3a7e4c2a:node3:switch_binary1"}
//Dummy Switch
Switch OG_Nazar_Licht_Proxy <light> "Licht Nazar proxy"
rule "pass on commands"
when
   Item OG_Nazar_Licht_Proxy changed
then
   if ( OG_Nazar_Licht_Proxy.state != OG_Nazar_Licht.state) {  // if not already as commanded
      OG_Nazar_Licht.sendCommand(OG_Nazar_Licht_Proxy.state) // send command
   }
end

rule "detect physical changes"
when
   Item OG_Nazar_Licht changed
then
   if (OG_Nazar_Licht_Proxy.state != OG_Nazar_Licht.state) {  // unexpected change
      // here do whatever you do for a manual pushbutton
      // then 
      OG_Nazar_Licht_Proxy.postUpdate(OG_Nazar_Licht.state)  // make matching now
   }
end

Have your other rules send commands to the Proxy.
Choose if you want UI commands to act like manual commands, and either put the real or proxy in your sitemap.
Choose which one to link with [tags] in a similar way…

1 Like