Momentary Button state

a simple cheap Chinese relay, 240V coil wired across the end lighting circuit. You do need some contact type binary input to OpenHAB for each channel - a spare GPIO pin, or in my case Modbus discrete inputs.
Some impulse relays have a spare pole that could be used.

If you don’t provide some kind of feedback like this, OpenHAB can never be sure if the lights are on or off to begin with.

A bonus is that I can detect when an impulse relay has been activated by a wall button, rather than by Openhab. So OH can detect when a user is making manual changes and use that in rules i.e. set occupancy (someone is there, because they are pressing buttons), perhaps turning off automatic light for a while (the user has made a choice with the button, and probably does not want OH ‘help’).

Items

Switch myLight "Lighting" { bound to circuit monitor hardware, autoupdate=false }
Switch myPulse "Pulse output" { bound to output pin for impulse relay }

Only put myLight on your Sitemap, as a Switch

rule "Master light control"
when
   Item myLight received command     // from a Rule or the UI
then
   if(receivedCommand == ON && mylight.state == OFF) {
      myPulse.sendCommand(ON)
   } else if (receivedCommand == OFF && mylight.state == ON) {
      myPulse.sendCommand(ON)
   }        // else already in requested state
end

rule "light feedback monitor"
when
   Item myLight received update     // from hardware monitor
then
   if(myPulse.state == ON) {    // this was an automated change
      myPulse.sendCommand(OFF)    // we don't time the pulse, simply stop when it has worked
      logInfo("lights", "auto change complete")
   } else {
      // this was a manual change by wallswitch, we can do something else
      logInfo("lights", "user pressing buttons")
   }
end
2 Likes