Turn Hue Lights via Modbus on/off

Hi!

I am trying to turn my Hue Lights on/off via my Wago SPS 750-881 via Modbus that i can use my pysical buttons in my House and don´t have to use the remotes from phillips (not wife friendly :wink: )

I am already able to turn the Lights on with this rule:

rule "Wohnzimmer Taster Hue Licht"
when 
    Item Wohnzimmer_Taster changed from OFF to ON
then
    Wohnzimmer.sendCommand(ON)
end

But the physical switch on my Wall is only a single Button and the Bit witch i set with this button is going to true as long i press this button… when i release the button than the bit is falling back to false.

When i press the button again then the rule is not working, because the lights are already turned on.

I hope i explained it good enough to understand.

Is it possible in some way to turn the lights on witch a simple press of this phyical button and turn them of when i press again?

Maybe to look for the status of the lamps and turn them on or off depending on the status of the bulbs?
How should the rule than look like?

Thank you and BR!

if the lights are ON
then turn them OFF
else
turn them ON

great! i understand… but i need some help with the syntax or how to set it up the best way.

For explenation:
I have 9 Hue bulbs configured Wz1, Wz2, Wz3… up to Wz9.
They all are in the group “Wohnzimmer”

I think in this case it is the best way to check the status of a single bulb and send this then to all bulbs in the group… because i have some scenes where not all of the bulbs are on…hmm… if i check the status of all bulbs then they are on turn off and the other way…

The syntax is not that difficult and you’d learn from doing, but more important is figuring out what you want first.

That’s a decision for you to make. What do you want to happen when you press the button?

By default, when you send a command to a group that command gets passed to all its members.
For example, if you send ON when some members are on and some off, all will receive the ON.

The “state” of a group depends both on the states of its members, and what you have chosen for its aggregation function, if anything.
Typically for lights people will choose an OR function so that the group is ON when any of its members are ON.
But again, it’s up to you.

oh… you are right… it is possible to send on or off… i don´t think of that.

I would like to turn off or on all 9 bulbs in my livingroom.
But it is not so important if one or more bulbs are off at the moment (because an scene is active) to press the button to turn all on and then all off. do you know what i mean?

It is ok for me to bring all bulbs to the same state (for example all to ON) to turm them all OFF with a second press.

i tried this rule and it seems to work (what i can see in the logfiles - because i am not at home at the moment :wink: )

rule "Wohnzimmer Taster Hue Licht"
when 
    Item Wohnzimmer_Taster changed from OFF to ON
then
logInfo("Wohnzimmerlicht ist", Wz3.state.toString)
    if (Wz3.getStateAs(OnOffType) == ON) 
        Wohnzimmer.sendCommand(OFF)
    else 
        Wohnzimmer.sendCommand(ON)
end

So here i check bulb “Wz3” if it is on or off and send then to the group on or off.