Toggle Switch (Homematic switch)

Hi,
i am using openhab2 and a homematic switch.
Has someone a rule example how i can toggle my switch?
If State is On and i switch up, the light has to go off
If State is On and i switch down, the light has to go off
If State is OFF and i switch up, the light has to go on
If State is OFF and i switch down, the light has to go on
thx
Jay

I don’t get the use case, really… :grin:
If you have Homematic binding correctly configured, you have a switch item, which knows the state of the switch and in basicUI you can turn it on or off?

Please be more specific if this isn’t, what you’d like to achieve - and please post your item definition.

Create an item that uses autoupdate, so that the state will not change and the UI will behave like a toggle…

Switch    Virtual_Switch_1    "Toggle Light"    <switch>    {autoupdate="false"}

Then create a rule like this, but replace the Light item with your Homematic switch…

rule "Toggle light"
when
    Item Virtual_Switch_1 received command
then
    if (Light.state == OFF) {
        Light.sendCommand(ON)
    }
    else {
        Light.sendCommand(OFF)
    }
end

@5iver
Hi,
it doesnt work. When i touch the Switch the event “received command” was not fired.
Only by Event “received Update”.
And i think you have to consider the previous state, do not?

Hi @binderth
i want to fire the Event by the physically Switch.
And then a toogle

Which switch do you use? My understanding is, that the switches directly influence the lights for example? And then, the binding will know which state the switch has?

I have the HM-LC-Sw1PBU-FM
if i press up the firsttime the light should go on; an the second time i press up it should go off

  1. What’s your item and thing definition?
  2. What’s in the logs for the switch?
  3. Homematic 2 binding I guess?

If the Event “received update ON” is fired, the state of the Switch is always on.
How can i get the state of the Switch before i press the Switch up.
i could be Off or ON

In this trigger the state gives always on;
but i Need the state before

rule lichtschalterWippe1
when
Item HM_Funkschalter1 received update ON

   ==> HM_Funkschalter1.state 

then

You’ve probably chosen the wrong rule trigger for what you are trying to do.

How about

when
Item HM_Funkschalter1 changed to ON

The you know it was OFF (or null) beforehand. And you can make another rule for changed to OFF

Hi @rossko57
the Event “changed to ON” is not fired, when the light is still on.

again: the Switch actively reports its state to the binding, doesn’t it? so, if we should help you:

I guess, you avoid posting your configuration.

for the other interested - here’s the new thread on the same issue: