Group switch not updating

Off the wall suggestion, based on assumed iterative calculation of Group state (maybe only for OR function even)
When a member changes, it fires a process to step through all candidate members, first setting the group state to the default. If there’s no match to the OR condition, it stays default. If there is match, it changes again.

Seems mad but this behaviour can be deduced from rule trigger firings.

I’d guess the first change event i.e. from NULL to X, is suppressed.

You might be onto something.

Fun fact, there seems to be some test cases for this scenario here:

That is correct.

@ysc I can confirm your observations. Did it myself in a test setup. This leaded me to another question I wanted to test: Which event will we see when we have a group containing only one member:

Group:Switch:OR(ON,OFF) gTESTSWITCHES1 "Test Switches 1"
Switch testSwitch1 "Test Switch 1" (gTESTSWITCHES1)

Initial situation: state of Switch and Group are both ON.

1st try: Sending OFF to Switch:

openhab> smarthome:send testSwitch1 OFF
Command has been sent successfully.
event: message
data: {"topic":"smarthome/items/testSwitch1/statechanged","payload":"{\"type\":\"OnOff\",\"value\":\"OFF\",\"oldType\":\"OnOff\",\"oldValue\":\"ON\"}","type":"ItemStateChangedEvent"}

event: message
data: {"topic":"smarthome/items/gTESTSWITCHES1/testSwitch1/statechanged","payload":"{\"type\":\"OnOff\",\"value\":\"OFF\",\"oldType\":\"OnOff\",\"oldValue\":\"ON\"}","type":"GroupItemStateChangedEvent"}

:+1: working

2nd try: Sending ON to Switch:

openhab> smarthome:send testSwitch1 ON
Command has been sent successfully.
event: message
data: {"topic":"smarthome/items/testSwitch1/statechanged","payload":"{\"type\":\"OnOff\",\"value\":\"ON\",\"oldType\":\"OnOff\",\"oldValue\":\"OFF\"}","type":"ItemStateChangedEvent"}

event: message
data: {"topic":"smarthome/items/gTESTSWITCHES1/testSwitch1/statechanged","payload":"{\"type\":\"OnOff\",\"value\":\"ON\",\"oldType\":\"OnOff\",\"oldValue\":\"OFF\"}","type":"GroupItemStateChangedEvent"}

:+1: again working

3rd try: Sending OFF to Group:

openhab> smarthome:send gTESTSWITCHES1 OFF
Command has been sent successfully.
event: message
data: {"topic":"smarthome/items/testSwitch1/statechanged","payload":"{\"type\":\"OnOff\",\"value\":\"OFF\",\"oldType\":\"OnOff\",\"oldValue\":\"ON\"}","type":"ItemStateChangedEvent"}

:interrobang: Outch, failing - GroupItemStateChangedEvent is missing.

4th try: Sending ON to Group:

openhab> smarthome:send gTESTSWITCHES1 ON
Command has been sent successfully.
event: message
data: {"topic":"smarthome/items/testSwitch1/statechanged","payload":"{\"type\":\"OnOff\",\"value\":\"ON\",\"oldType\":\"OnOff\",\"oldValue\":\"OFF\"}","type":"ItemStateChangedEvent"}

:interrobang: Outch, again failing - GroupItemStateChangedEvent is missing.

I did the same tests with a group containing two members. Ping me if you ate interested in the results. // EDIT: I added them below. They reflect your findings.

Summary
Group:Switch:OR(ON,OFF) gTESTSWITCHES2 "Test Switches 2"
Switch testSwitch1 "Test Switch 1" (gTESTSWITCHES2)
Switch testSwitch2 "Test Switch 2" (gTESTSWITCHES2)

Initial situation: state of both Switches and Group are ON.

1st try: Sending OFF to Switch 1 and Switch 2:

openhab> smarthome:send testSwitch1 OFF
Command has been sent successfully.
event: message
data: {"topic":"smarthome/items/testSwitch1/statechanged","payload":"{\"type\":\"OnOff\",\"value\":\"OFF\",\"oldType\":\"OnOff\",\"oldValue\":\"ON\"}","type":"ItemStateChangedEvent"}
openhab> smarthome:send testSwitch2 OFF
Command has been sent successfully.
event: message
data: {"topic":"smarthome/items/testSwitch2/statechanged","payload":"{\"type\":\"OnOff\",\"value\":\"OFF\",\"oldType\":\"OnOff\",\"oldValue\":\"ON\"}","type":"ItemStateChangedEvent"}

event: message
data: {"topic":"smarthome/items/gTESTSWITCHES2/testSwitch2/statechanged","payload":"{\"type\":\"OnOff\",\"value\":\"OFF\",\"oldType\":\"OnOff\",\"oldValue\":\"ON\"}","type":"GroupItemStateChangedEvent"}

:+1: working

2nd try: Sending ON to Switch 1 and Switch 2:

openhab> smarthome:send testSwitch1 ON
Command has been sent successfully.
data: {"topic":"smarthome/items/testSwitch1/statechanged","payload":"{\"type\":\"OnOff\",\"value\":\"ON\",\"oldType\":\"OnOff\",\"oldValue\":\"OFF\"}","type":"ItemStateChangedEvent"}

event: message
data: {"topic":"smarthome/items/gTESTSWITCHES2/testSwitch1/statechanged","payload":"{\"type\":\"OnOff\",\"value\":\"ON\",\"oldType\":\"OnOff\",\"oldValue\":\"OFF\"}","type":"GroupItemStateChangedEvent"}
openhab> smarthome:send testSwitch2 ON
Command has been sent successfully.
event: message
data: {"topic":"smarthome/items/testSwitch2/statechanged","payload":"{\"type\":\"OnOff\",\"value\":\"ON\",\"oldType\":\"OnOff\",\"oldValue\":\"OFF\"}","type":"ItemStateChangedEvent"}

:+1: working

3rd try: Sending OFF to Group:

openhab> smarthome:send gTESTSWITCHES2 OFF
Command has been sent successfully.
event: message
data: {"topic":"smarthome/items/gTESTSWITCHES2/testSwitch1/statechanged","payload":"{\"type\":\"OnOff\",\"value\":\"ON\",\"oldType\":\"OnOff\",\"oldValue\":\"OFF\"}","type":"GroupItemStateChangedEvent"}

event: message
data: {"topic":"smarthome/items/testSwitch1/statechanged","payload":"{\"type\":\"OnOff\",\"value\":\"OFF\",\"oldType\":\"OnOff\",\"oldValue\":\"ON\"}","type":"ItemStateChangedEvent"}

event: message
data: {"topic":"smarthome/items/gTESTSWITCHES2/testSwitch2/statechanged","payload":"{\"type\":\"OnOff\",\"value\":\"OFF\",\"oldType\":\"OnOff\",\"oldValue\":\"ON\"}","type":"GroupItemStateChangedEvent"}

event: message
data: {"topic":"smarthome/items/testSwitch2/statechanged","payload":"{\"type\":\"OnOff\",\"value\":\"OFF\",\"oldType\":\"OnOff\",\"oldValue\":\"ON\"}","type":"ItemStateChangedEvent"}

:interrobang: Outch - two GroupItemStateChangedEvents, one seem to be absolutely wrong - conurrency issue???

4th try: Sending ON to Group:

openhab> smarthome:send gTESTSWITCHES2 ON
Command has been sent successfully.
event: message
data: {"topic":"smarthome/items/testSwitch1/statechanged","payload":"{\"type\":\"OnOff\",\"value\":\"ON\",\"oldType\":\"OnOff\",\"oldValue\":\"OFF\"}","type":"ItemStateChangedEvent"}

event: message
data: {"topic":"smarthome/items/testSwitch2/statechanged","payload":"{\"type\":\"OnOff\",\"value\":\"ON\",\"oldType\":\"OnOff\",\"oldValue\":\"OFF\"}","type":"ItemStateChangedEvent"}

:interrobang: Outch - no GroupItemStateChangedEvent at all

IIRC the unit tests only handle updateState() on items. sendCommand() on groups is NOT covered!

Conclusion: First of all forget about my suggestion to trigger an ItemStateChangedEvent. We do not need it. There is something wrong with the calculation at which time a GroupItemStateChangedEvent will be emitted. Lets open an issue on https://github.com/openhab/openhab-core/issues.

4 Likes

I have noticed a similar problem -> items changing not generating a group event. I can fix it by editing the .items file and saving it which reloads the items. I haven’t had time to dive into this to definitely understand the problem. But, something has changed and events have gone missing…

Revisiting this topic, that we never really never got to the bottom of.

On the face of it, that is a “dumb” thing to do. This Group’s state is calculated by an aggregation function. Sending a direct postUpdate to a Group is an abnormal usage. Having said that, it’s a meaningful test …

If we interpret
ItemStateChangedEvent
as meaning “I have been changed by a postUpdate”
(and I guess an update by binding should do this too)
and
GroupItemStateChangedEvent
as meaning “I have been changed by group member aggregation function only”
In other words, this is a “group” calculated event not an ordinary “real” event

Then Cristoph’s results look to be the intended behaviour ??

If we can establish what expected behaviour is, then we can pick out the unexpected “missing” events.

After upgrading to OH 2.5.0 I’m also experiencing the same behavior in HABPanel as stated in the initial post in this thread. After pressing on a group switch, the status in not updated until a page reload has been done. It worked flawlessly before on 2.4.0. Is there a workaround available? And did someone open an issue for this? I could not find any on GitHub (openhab/openhab-core). Thanks!

Hi,

I just updated from 2.4 to 2.5 and have exactly this same problem.
I had no issues with this before upgrade to 2.5.
Would it be possible to revert only habpanel binding to 2.4? Or any other workaround?
Thanks!

Hi,

same here on 2.5.
Without manual refresh group item sticks to one state and keeps posting same every time I toggle group switch.

Testing scenario:

Group ‘garaz_zew’ containing 3 items (bulbs)
starting state OFF

Test1
Test1 expected result:
When group swith toggled: Group item command = ON
Habpanel switch widget representing status ON
Test1 end result:
Group item received command ON - success :grinning:
Habpanel item status not changed - fail :worried:

Test2
Test2 expected result:
When group swith toggled: Group item command = OFF
Habpanel switch widget representing status OFF
Test2 end result:
Group item received command OFF - fail :worried:
Habpanel item status not changed - fail :worried:

All of the next tryouts gives the same result. ItemCommandEvent keeps sending ON state every time the group swich toggle:

[ome.event.ItemCommandEvent] - Item ‘garaz_zew’ received command ON
[ome.event.ItemCommandEvent] - Item ‘Garaz_zew_S’ received command ON
[ome.event.ItemCommandEvent] - Item ‘Garaz_zew_P’ received command ON
[ome.event.ItemCommandEvent] - Item ‘Garaz_zew_L’ received command ON
[vent.ItemStateChangedEvent] - Garaz_zew_S changed from 0 to 100
[vent.ItemStateChangedEvent] - Garaz_zew_P changed from 0 to 100
[vent.ItemStateChangedEvent] - Garaz_zew_L changed from 0 to 100
[ome.event.ItemCommandEvent] - Item ‘garaz_zew’ received command ON
[ome.event.ItemCommandEvent] - Item ‘Garaz_zew_S’ received command ON
[ome.event.ItemCommandEvent] - Item ‘Garaz_zew_P’ received command ON
[ome.event.ItemCommandEvent] - Item ‘Garaz_zew_L’ received command ON

For non group items all works fine.

Any solution or workaround?

Related reported issue can be found here on openhab/openhab-core:
Group switch update in HABPanel doesn’t work correct

1 Like

If you really need this fixed, you can do this as a workaround:

  1. cd conf/html (or wherever the html folder of your configuration is)
  2. git clone --depth 1 -b 2.5.x https://github.com/openhab/openhab-webui
  3. edit openhab-webui/bundles/org.openhab.ui.habpanel/web/app/services/openhab.service.js and on line 168, change:
    .../rest/events?topics=smarthome/items/*/statechanged,...
    to
    .../rest/events?topics=smarthome/items/*/state*,... (i.e. statechanged => state*)
    This will make HABPanel react to “normally useless” ItemStateEvent (like it used to)
  4. Access your custom version of HABPanel at
    http://openhabip:8080/static/openhab-webui/bundles/org.openhab.ui.habpanel/web/
    It should update the group states reliably because of the change made in 3.
1 Like

Great, this works!

I have some news on this topic. I guess I found something - at least a workaround. The trick seems to be the AutoUpdatePolicy (Thanks to #1330 (comment)). When I add autoupdate="false" to the Group the events will be emitted probably:

Group:Switch:OR(ON,OFF) gTESTSWITCHES1 "Test Switches 1" { autoupdate="false" }

Switch testSwitch1 "Test Switch 1" (gTESTSWITCHES1)

Initial situation: state of Switch and Group are both ON.

1st try: Sending OFF to Switch:

event: message
data: {"topic":"smarthome/items/testSwitch1/statechanged","payload":"{\"type\":\"OnOff\",\"value\":\"OFF\",\"oldType\":\"OnOff\",\"oldValue\":\"ON\"}","type":"ItemStateChangedEvent"}

event: message
data: {"topic":"smarthome/items/gTESTSWITCHES1/testSwitch1/statechanged","payload":"{\"type\":\"OnOff\",\"value\":\"OFF\",\"oldType\":\"OnOff\",\"oldValue\":\"ON\"}","type":"GroupItemStateChangedEvent"}

:+1: working

2nd try: Sending ON to Switch:

data: {"topic":"smarthome/items/testSwitch1/statechanged","payload":"{\"type\":\"OnOff\",\"value\":\"ON\",\"oldType\":\"OnOff\",\"oldValue\":\"OFF\"}","type":"ItemStateChangedEvent"}

event: message
data: {"topic":"smarthome/items/gTESTSWITCHES1/testSwitch1/statechanged","payload":"{\"type\":\"OnOff\",\"value\":\"ON\",\"oldType\":\"OnOff\",\"oldValue\":\"OFF\"}","type":"GroupItemStateChangedEvent"}

:+1: working

3rd try: Sending OFF to Group:

event: message
data: {"topic":"smarthome/items/testSwitch1/statechanged","payload":"{\"type\":\"OnOff\",\"value\":\"OFF\",\"oldType\":\"OnOff\",\"oldValue\":\"ON\"}","type":"ItemStateChangedEvent"}

event: message
data: {"topic":"smarthome/items/gTESTSWITCHES1/testSwitch1/statechanged","payload":"{\"type\":\"OnOff\",\"value\":\"OFF\",\"oldType\":\"OnOff\",\"oldValue\":\"ON\"}","type":"GroupItemStateChangedEvent"}

:+1: working

4th try: Sending ON to Group:

event: message
data: {"topic":"smarthome/items/testSwitch1/statechanged","payload":"{\"type\":\"OnOff\",\"value\":\"ON\",\"oldType\":\"OnOff\",\"oldValue\":\"OFF\"}","type":"ItemStateChangedEvent"}

event: message
data: {"topic":"smarthome/items/gTESTSWITCHES1/testSwitch1/statechanged","payload":"{\"type\":\"OnOff\",\"value\":\"ON\",\"oldType\":\"OnOff\",\"oldValue\":\"OFF\"}","type":"GroupItemStateChangedEvent"}

:+1: working

That is the good news. Now we have to discuss how we can archive the same behavior without adding autoupdate="false" to the Group.

3 Likes

Wow. What is autoupdate even trying to do with a Group? It ought to ignore commands to Group types.

This apperently presents a agreat workaround, thank you very much for spending the time to figure that out. I just wasted some hours wondering what was going on with my HABPanel groups, but thanks to you they now update again. Should be properly fixed, though :slight_smile:

I confirm, it was working on OH 2.4, with 2.5 the workaround is to set autoupdate=false in the group item. I lost more than a couple of hours to get it!
Andrea

1 Like

I tried this with a “Sum” group but the item in habpanel does not update itself unless there is a reload. Group definition is

Group:Number:SUM				gFensterOffen	"offene Fenster [%d]"					<openwindow>	(B17)	{autoupdate="false"}

Version is OH2.5.5.

Any ideas?

Well, works with the workaround described by @ysc.

I am experiencing that problem where group switches are not updating.

I had presence detection with the network binding working for at least a month on 2.5.4. I noticed the detection had stopped working (don’t know if it coincided with implementing 2.5.5 because I didn’t check it at the time). I had also upgraded to 2.5.6, before I observed the problem with the group switch not updating.

I tried adding the autoupdate parameter described above, but it still doesn’t work.

Group:Switch:AND(OFF,ON) Presence_Sensors <present> { autoupdate="false" }

Today I updated to 2.5.7-1. I am running Openhabian on a Pi 4 B.

I am not using HABPanel.

I do also have the same problem running openHAB 2.5.9 on a raspberry 3. I think the autoupdate =“false” parameter is not the solution and I am not sure if the is a “offical” solution for the problem.

Did you try already workaroud described from @ysk already:

Not sure if this is still valid.

Running into the same issue with openHAB 2.5.10-1

Need to reload the HabPanel page to get the group switch status correctly displayed.