Habpanel event subscription bug?

Hello,

before I create a pull request to fix a bug, I want to discuss if this is really a bug or If I made a configuration mistake.

Currently I have the following scenario.

Group:Switch:OR(ON, OFF) gGF_Corridor_Lights    "Flurlicht"          <selflight>
Switch pGF_Corridor_Light_Ceiling_Powered              "Deckenlicht"        <selflight> (gGF_Corridor_Lights) { channel="knx:device:bridge:lights_ff:floorCeiling" }

If I send the command ON to pGF_Corridor_Light_Ceiling_Powered I get the following events

event: message
data: {"topic":"smarthome/items/pGF_Corridor_Light_Ceiling_Powered/statepredicted","payload":"{\"predictedType\":\"OnOff\",\"predictedValue\":\"ON\",\"isConfirmation\":false}","type":"ItemStatePredictedEvent"}

event: message
data: {"topic":"smarthome/items/pGF_Corridor_Light_Ceiling_Powered/state","payload":"{\"type\":\"OnOff\",\"value\":\"ON\"}","type":"ItemStateEvent"}

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

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

event: message
data: {"topic":"smarthome/items/pGF_Corridor_Light_Ceiling_Powered/state","payload":"{\"type\":\"OnOff\",\"value\":\"ON\"}","type":"ItemStateEvent"}

so, everything looks fine, as habpanel is getting notified about group and item changes. Because both are getting a statechanged event.

Now, If I send the command OFF to gGF_Corridor_Lights I get the following events

event: message
data: {"topic":"smarthome/items/gGF_Corridor_Lights/state","payload":"{\"type\":\"OnOff\",\"value\":\"OFF\"}","type":"ItemStateEvent"}

event: message
data: {"topic":"smarthome/items/pGF_Corridor_Light_Ceiling_Powered/statepredicted","payload":"{\"predictedType\":\"OnOff\",\"predictedValue\":\"OFF\",\"isConfirmation\":false}","type":"ItemStatePredictedEvent"}

event: message
data: {"topic":"smarthome/items/pGF_Corridor_Light_Ceiling_Powered/state","payload":"{\"type\":\"OnOff\",\"value\":\"OFF\"}","type":"ItemStateEvent"}

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

everything looks fine again, except that the Group item is not getting a statechanged event. The normal “state” event is not received by habpanel, because the subscription sayes only “statechanged” events.

you can see the changes which introduced this behavior in this pull request

Later in the same file you can see that habpanel is processing

if (evtdata.type === 'ItemStateEvent' || evtdata.type === 'ItemStateChangedEvent' || evtdata.type === 'GroupItemStateChangedEvent') 

but this will never work because the first type “ItemStateEvent” will never arrive habpanel.

So my recommendation is to fix this bug by changing the subscription from

var source = new EventSource('/rest/events?topics=smarthome/items/*/statechanged,smarthome/items/*/*/statechanged,smarthome/webaudio/playurl');

to

var source = new EventSource('/rest/events?topics=smarthome/items/*/state*,smarthome/items/*/*/state*,smarthome/webaudio/playurl');

has anyone any feedback or ideas how to fix it in a better way? Maybe the author @ysc of the original pull request.

I added a bug ticket

and a pull request

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.