[SOLVED]triggeringItem.state return reverse state of that Item

Hello everyone,i have a problem with “triggeringItem.state”
In my rules, some time triggeringItem.state return reverse state of that Item.
Example: I have Switch Item, It is in the OFF state. When I turn ON that Item, in my rules, i use “Member of Control received command” in When ( Item in Control group)
and in Then, i use “triggeringItem.state”
Its true value of “state” must be "ON, but some time, value is “OFF”.That lead to my rules being wrong.
Is there any way to troubleshoot it? Sorry for my bad english

Please be aware that received command has nothing to do with a state.
A rule which triggers from a received command will provide an implicit var receivedCommand which gives the received command.
There may be Items which use identical commands and states (for example ON/OFF for a switch), but there are others which don’t (ON/OFF for a dimmer Item will result in a state 100 or 0)

And as a command is sent, it will take some time for the item to change its state, maybe the state will be set from a binding.
command -> communication with hardware -> command is executed by hardware -> new state provided by hardware -> openHAB receives state update -> state change.

So either change the trigger to

Member of Control changed

or change the rule to use the command rather than the state

val command = receivedCommand

(but of course you won’t need a val for that job :wink: )

1 Like

that’s good idea,

My system has worked very smoothly