State before Trigger Event

Hi,

Parameters:

  • Homematic Switch HM-LC-Sw1PBU-FM
  • Possibility to Push the Switch Up and Down

Only the Event “received update” is fired when i push the Switch Up and the Light is still on.

so i Need a trigger with the Event “reveived update ON”.

In this trigger the state gives always “on”;
but i Need the state before i push the Switch
it can be “on”, when the light was still on OR “on” when the light was “off” an turned to “on”

rule xxx
when
Item sw received update ON
==> sw.state
then

Any Idea how i can get the state of the Switch it was before entering the trigger?

regards jay

Buzzwords : implicit variables, previouState.

https://docs.openhab.org/configuration/rules-dsl.html#implicit-variables

but the “previousState” is only available in status change event trigger
i have “received update” not “changed from x to y”

As I know for this there is no real solution for this. We have to wait for a PR which I requested that previousState of item really reflects this state. At the moment mostly it is the same as the current state

See:

Right. My bad.

The light does not change when it is turned on again by the switch.

Maybe this works

rule "Switch"
when
    Item WallSwitch received update 
then
    logInfo("Test Switch", "Item:\"" + triggeringItem.name + "\" state:\"" +  triggeringItem.state)
    logInfo("Test Switch", "Item:\"" + Light.name + "\" state:\"" +  Light.state)

    if( Light.state == triggeringItem.state ){
        if(triggeringItem.state == ON) Light.sendCommand(OFF) else Light.sendCommand(ON)
    }else
    {
        Light.sendCommand(OFtriggeringItem.state) 
    }
end

@Josar
In my case the Item in the When Condition is the same like the Light.
My Switch controls the ligt.
So i cannot compare two different states

The switch can be programmed to always toggle.

Please describe your setup and what you want to achieve. Maybe the solution is different from what you have as idea to realize your goal.

Command to program the switch to toggle.

set HM-LC-Sw1PBU-FM regSet intKeyVisib visib
set HM-LC-Sw1PBU-FM getConfig
set HM-LC-Sw1PBU-FM regSet shActionType  jmpToTarget self01
set HM-LC-Sw1PBU-FM regSet shSwJtOn      dlyOff      self01
set HM-LC-Sw1PBU-FM regSet shSwJtOff     dlyOn       self01
set HM-LC-Sw1PBU-FM regSet shSwJtDlyOn   on          self01
set HM-LC-Sw1PBU-FM regSet shSwJtDlyOff  off         self01
set HM-LC-Sw1PBU-FM regSet shActionType  jmpToTarget self02
set HM-LC-Sw1PBU-FM regSet shSwJtOn      dlyOff      self02
set HM-LC-Sw1PBU-FM regSet shSwJtOff     dlyOn       self02
set HM-LC-Sw1PBU-FM regSet shSwJtDlyOn   on          self02
set HM-LC-Sw1PBU-FM regSet shSwJtDlyOff  off         self02

Set back to default.

set <device> regSet shSwJtOn      dlyOff     self01
set <device> regSet shSwJtOff     off        self01
set <device> regSet shSwJtDlyOn   off        self01
set <device> regSet shSwJtDlyOff  off        self01
set <device> regSet shSwJtOn      on         self02
set <device> regSet shSwJtOff     dlyOn      self02
set <device> regSet shSwJtDlyOn   on         self02
set <device> regSet shSwJtDlyOff  on         self02

Found here

Hi @Josar

wowo; this is exactly what i want:

"Schalter immer toggeln lassen"
Im Werkszustand schaltet die Wippe bei Druck auf der einen Seite ein, auf der anderen Seite aus. Möchte man, dass bei jedem Tastendruck einfach der Zustand geändert wird, kann man das wie folgt erreichen (unten nur für den kurzen Tastendruck dargestellt): "

Do you have an idea, how or where to execute the set Statements?

I don’t own fhem devices but it sounds as you can do this in FHEMWEB / PGM2.