*.state.* - can not find anything about it

Hello,
already sorry for a possibly stupid question - I searched for hours for it, but could not really find anything.
I am using the serial binding and in some examples I found the expression “expression.state.toString.trim” for parsing incoming data…

Could someone please give me a hint, what “.state.” does here? Searching in JS Java or Xtend did not give me any insights.

Thanx in advance.
Cal

In openHAB, there are items that represent discrete things, like light switches, door contacts, etc. An item can receive commands, like a light switch can receive ON on OFF, a dimmer can receive a command as a percent, and so on. An item also has a current state, as in, openHAB’s best understanding of whether a switch is on, whether a door is open or closed, the current temperature in the room where the thermostat is, etc.

If you write a rule, you refer to the item with its name, let’s call it LightSwitch, and to know in the rule what the current state of the light switch is, you append .state to the item. For example:

if (LightSwitch.state == ON) {
  StatusDisplay.postUpdate( "please turn off the light" )
}

Thank you so much…I already suspected that it may be that easy… sorry again for the hassle.

cal

1 Like