I can't undestand my rules behavior

Hello!
I am trying to control some lights with a push button.
My rule does not work if itry to address a specific item. using a group does work.

This ist my rule using the item:
> rule “Lampe im Sidebord im Wintergarten soll auf Taster reagieren”
> when
> Item EG_WG_Taster_1_PressShort changed from OFF to ON
> then
> if (EG_WG_Sidebord_State == OFF) EG_WG_Sidebord_State.sendCommand(ON)
> else EG_WG_Sidebord_State.sendCommand(OFF)
> end
This rule does not work. This is the log entry:

2020-04-03 08:58:24.482 [vent.ItemStateChangedEvent] - EG_WG_Taster_1_PressShort changed from OFF to ON

2020-04-03 08:58:24.485 [vent.ChannelTriggeredEvent] - homematic:HG-HM-PB-2-WM55-2:143f612d:LEQ1058808:1#BUTTON triggered SHORT_PRESSED

2020-04-03 08:58:24.498 [ome.event.ItemCommandEvent] - Item ‘gLichtWG’ received command OFF

2020-04-03 08:58:24.533 [ome.event.ItemCommandEvent] - Item ‘EG_WG_Sidebord_State’ received command OFF

2020-04-03 08:58:24.536 [nt.ItemStatePredictedEvent] - EG_WG_Sidebord_State predicted to become OFF

2020-04-03 08:58:26.484 [vent.ItemStateChangedEvent] - EG_WG_Taster_1_PressShort changed from ON to OFF

This is nearly the same rule using a group in another room:
> rule “Lampen im WZ sollen auf Taster reagieren”
> when
> Item EG_WZ_Taster_1_PressShort changed from OFF to ON
> then
> if (EG_WZ_Akt_Stehlampe_State.state == OFF) gLichtWZ.sendCommand(ON)
> else gLichtWZ.sendCommand(OFF)
> end

This ist the log entry:

2020-04-03 08:55:47.756 [ome.event.ItemCommandEvent] - Item ‘gLichtWZ’ received command ON

2020-04-03 08:55:47.784 [ome.event.ItemCommandEvent] - Item ‘EG_WZ_Akt_Stehlampe_State’ received command ON

2020-04-03 08:55:47.805 [ome.event.ItemCommandEvent] - Item ‘EG_WZ_FernseherLampe_State’ received command ON

2020-04-03 08:55:47.828 [ome.event.ItemCommandEvent] - Item ‘EG_WZ_VitrineLampe_State’ received command ON

2020-04-03 08:55:47.849 [ome.event.ItemCommandEvent] - Item ‘EG_WZ_KameraLampe_State’ received command ON

2020-04-03 08:55:47.852 [nt.ItemStatePredictedEvent] - EG_WZ_Akt_Stehlampe_State predicted to become ON

2020-04-03 08:55:47.871 [nt.ItemStatePredictedEvent] - EG_WZ_FernseherLampe_State predicted to become ON

2020-04-03 08:55:47.883 [nt.ItemStatePredictedEvent] - EG_WZ_VitrineLampe_State predicted to become ON

2020-04-03 08:55:47.898 [nt.ItemStatePredictedEvent] - EG_WZ_KameraLampe_State predicted to become ON

2020-04-03 08:55:47.911 [GroupItemStateChangedEvent] - gLicht changed from OFF to ON through EG_WZ_Akt_Stehlampe_State

2020-04-03 08:55:47.914 [vent.ItemStateChangedEvent] - EG_WZ_Akt_Stehlampe_State changed from OFF to ON

2020-04-03 08:55:47.916 [vent.ItemStateChangedEvent] - EG_WZ_FernseherLampe_State changed from OFF to ON

2020-04-03 08:55:47.919 [vent.ItemStateChangedEvent] - EG_WZ_VitrineLampe_State changed from OFF to ON

2020-04-03 08:55:47.921 [vent.ItemStateChangedEvent] - EG_WZ_KameraLampe_State changed from OFF to ON

2020-04-03 08:55:49.241 [vent.ItemStateChangedEvent] - EG_WZ_Taster_1_PressShort changed from ON to OFF

I have used FHEM before. so I am not experienced with openhab.
i already read the tutorials, but these could not help me.

I don’t know if it is important for you, but I am using HomeMatic devices.

Thank you for your answers.

Christian

  • Platform information:
    • Hardware: Rasberry Pi 3
    • OS: Openhabian
    • Java Runtime Environment:
    • openHAB version:

Hi, please fuse code fences for your code. That makes it much more readable. Are you saying, that the second rule works, but the first not?
But definitely you should change

 if (EG_WG_Sidebord_State == OFF)

to

 if (EG_WG_Sidebord_State.state == OFF)

I think your syntax might be wrong too

rule “Lampen im WZ sollen auf Taster reagieren”
when
Item EG_WZ_Taster_1_PressShort changed from OFF to ON
then
if (EG_WZ_Akt_Stehlampe_State.state == OFF) 
{
gLichtWZ.sendCommand(ON)

}
else 
{
gLichtWZ.sendCommand(OFF)
}


 EG_WZ_Taster_1_PressShort.sendCommand(OFF) // I only added this add an example
end

ooohhh I am soooo stupid. thank you very much. It is working now!

great!

i will use fences now. you are right.