openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.86k stars 3.57k forks source link

REST API always returning state NULL for Group Item #1921

Closed GrimmiMeloni closed 7 years ago

GrimmiMeloni commented 7 years ago

Situation: State of a Group Item of type Contact is requested via Rest API, e.g. http://<SERVER>:8080/rest/items/<GroupItemName>/state

Problem: state is always returned as NULL, no matter what the actual value (either CLOSED or OPEN) as reported in event log is.

Expected Behavior: actual state should be returned from REST API

Details: The group Item 'GrpWohnzimmerFenster' is setup as follows:

Group:Contact:AND(CLOSED,OPEN) GrpWohnzimmerFenster "Wohnzimmer Fenster"

Several window contacts have been added to the group via PaperUI. Eventlog entries emitted by a group member changing its state indicate that things work:

2017-02-19 19:41:06.719 [ItemStateChangedEvent ] - Fenster1_1_State changed from OPEN to CLOSED 2017-02-19 19:41:06.720 [GroupItemStateChangedEvent] - GrpWohnzimmerFenster changed from OPEN to CLOSED through Fenster1_1_State 2017-02-19 19:41:06.722 [GroupItemStateChangedEvent] - GrpWohnzimmerFenster changed from OPEN to CLOSED through Fenster1_1_State 2017-02-19 19:41:06.723 [GroupItemStateChangedEvent] - GrpWohnzimmerFenster changed from OPEN to CLOSED through Fenster1_1_State

It seems however impossible to explicitly request the current state of the group via the REST API, as it always returns NULL. This is problematic for REST clients when pulling the initial state, in my case HabPanel reloading in a fresh browser window. The client side information will be inaccurate until the first change event fires.

Additional question: According to the above event log excerpt, a a single change of state of one of the group members causes three GroupItemStateChange events to be fired. Shouldn't this only be one as well?

kaikreuzer commented 7 years ago

Could you please report this at https://github.com/eclipse/smarthome/issues, since the REST API (and the whole core framework) is at ESH? Thanks!