eclipse-archived / smarthome

Eclipse SmartHome™ project
https://www.eclipse.org/smarthome/
Eclipse Public License 2.0
862 stars 783 forks source link

Basic UI: Group state is not updated #6179

Open alazzari74 opened 6 years ago

alazzari74 commented 6 years ago

If I put a group in sitemap when the state of items change, the group is not updated. If I take a look into openhab log, the state of the group change.

I've tried with HabPanel and it's working fine. A deep analysis with developer tools of chrome I see that the UI create a subcription for the widget map and inside the channel there are no event about groups. If I enter in the group, the UI change subscription events and the event come from server. In HabPanel, the UI subscribe for all events and it works.

Here the sitemap: sitemap myhouse2 label="My house" { Frame label="Living" { Group item=Livingroom label="Lights" icon="light" } }

Here the Items Group House // Location perspective Group GroundFloor (House) Group:Switch:OR(ON,OFF) Livingroom "Luci [%d]" (GroundFloor)

Switch Light0 "Sala - Tavolo" (Livingroom) { binding...} Switch Light1 "Sala" (Livingroom) { binding...} Switch Light2 "Cucina" (Livingroom) { binding...}

Chrome DEBUG: MAIN SUBCRIPTION this is the websocket opened rest/sitemaps/events/e34c0437-164e-4802-a3b4-807e18273cd2?sitemap=myhouse2&pageid=myhouse2

SUBSCRIPTION this is the event subscription when I click on Group basicui/app?w=0000&sitemap=myhouse2&subscriptionId=e34c0437-164e-4802-a3b4-807e18273cd2&__async=true

SUBSCRIPTION this is the Event subscription when come back on the main view /basicui/app?w=myhouse2&sitemap=myhouse2&subscriptionId=e34c0437-164e-4802-a3b4-807e18273cd2&__async=true

if I stay in main view (subscription 1 and 3 ) and activate Switch, no events are notified If I click on group, the UI create the subscription 2 and when Activate a Switch in a group the events are notified:

Switch EVENT event {"widgetId":"Light0","label":"Sala - Tavolo","visibility":true,"item":{"state":"ON","type":"Switch","name":"Light0","label":"Sala - Tavolo","tags":[],"groupNames":["Livingroom"]},"sitemapName":"myhouse2","pageId":"0000"} 11:03:56.803

GROUP Event event {"widgetId":"0000","label":"Luci [1]","visibility":true,"item":{"members":[],"groupType":"Switch","function":{"name":"OR","params":["ON","OFF"]},"state":"ON","stateDescription":{"pattern":"%d","readOnly":false,"options":[]},"type":"Group","name":"Livingroom","label":"Lights","tags":[],"groupNames":["GroundFloor"]},"sitemapName":"myhouse2","pageId":"0000"} 11:03:56.806

htreu commented 6 years ago

Thanks for the report and analysis @alazzari74. @resetnow or @lolodomo please have a look at this.

lolodomo commented 6 years ago

As it is a part of the code I have often checked (or even slightly enhanced), I could have a look. My first hypothesis is that it is due to the kind of the widget (Group). @alazzari74 : could you please try to replace in your sitemap

Group item=Livingroom label="Lights" icon="light"

by

Switch item=Livingroom label="Lights" icon="light"

and tells me if widget is then updated ?

alazzari74 commented 6 years ago

I follow your suggestion and I've converted "Group" in "Swicth" and it works, but obviously, I cannot access to the switch inside the group. switchinsteadofgroup But the very "strange" behaviour is that when I rollback from "Switch" to "Group" in sitemap, and reload the page the UI works and the group state is updated!

Then I added a second Frame to the map with another kind of grouping method and it stop to works again

Frame label="Svago" {

Text item=LightSvagoState label="Luci" icon="light"{
Switch item=Light10 icon="light" label="Studio" Switch item=Light11 icon="light" label="Libreria" Switch item=Light12 icon="light" label="Lettura" Switch item=Light13 icon="light" label="Palestra" } }

secondframe I commented the Text with the Switch inside leaving switch ungrouped and it come back to work. Frame label="Svago" {

// Text item=LightSvagoState label="Luci" icon="light"{
Switch item=Light10 icon="light" label="Studio" Switch item=Light11 icon="light" label="Libreria" Switch item=Light12 icon="light" label="Lettura" Switch item=Light13 icon="light" label="Palestra" // } } image

Than I restore the Text group and It continue to works. Note that every time I refreshed the browser reloading the page (CTRL+F5 to avoid browser caching)

Last try, I restore with your suggestion (Switch instead of group) and It stop to works even if the events are pushed from server image Come back to group and it doesn't works anymore. image

It seems to be a random issue.

lolodomo commented 6 years ago

All this strange behaviour is probably due to WEB browser caching.

As I supposed, the problem is probably with the use of Group. I will try to investigate when I find time for.

lolodomo commented 6 years ago

For your last tests, try again doing a real full cache cleaning using the browser options rather than a simple Ctrl+F5.

alazzari74 commented 6 years ago

I tried with real full cache cleaning and it's the same, but now I finally create a stable not working situation wrote in the opening description of this issue.

So, now I' have a more rich sitemap and the events are not sent in the channel opened from UI with subscription when I'm in the main page.

The events come only when I enter in the group. Here the screenshots:

  1. In this screenshot, in the left browser there is no events even if I activate the switch with the right browser image image
  2. If I enter in the group, the UI make a new subscription and the event come

SWITCH "Sala Parete" ON image

SWITCH "Sala Parete" OFF image

this is my items file:

Group House // Location perspective Group GroundFloor (House) Group:Switch:OR(ON,OFF) Livingroom "Lights [%d]" (GroundFloor) // Functional perspective Group Sensors (House) Group Switches (House) Group Temperatures (Sensors)

Switch Light0 "Sala - Tavolo" (Livingroom) { binding...} Switch Light1 "Sala" (Livingroom) { binding...} Switch Light2 "Cucina" (Livingroom) { binding...} Switch Light3 { binding...} Switch Light4 { binding...} Switch Light5 { binding...} Switch Light6 { binding...} Switch Light7 { binding...} Switch Light8 { binding...} Switch Light9 { binding...} Switch Light10 "Studio" { binding...} Switch Light11 "Libreria" { binding...} Switch Light12 "Lettura" { binding...} Switch Light13 "Palestra" { binding...} Switch Light14 { binding...} Switch Light15 { binding...} Switch Light16 { binding...}

String LightState "[%s]" { binding...} String LightSvagoState "[MAP(switchstate.map):%s]" { binding...}

Number TempP0Proxy "Cucina [%.1f °C]" Number TempP1Proxy "Lettura [%.1f °C]" Number HumP1Proxy "Lettura [%.1f %%]"

Number TempP0 "[%d]" { binding...} Number TempP1 "[%d]" { binding...} Number HumP1 "[%d]" { binding...}

This is my sitemap file: sitemap myhouse2 label="My house" { Frame label="Svago" {

     Switch item=Light10 icon="light" label="Studio"
     Switch item=Light11 icon="light" label="Libreria"
     Switch item=Light12 icon="light" label="Lettura"
     Switch item=Light13 icon="light" label="Palestra"
     Text item=TempP1Proxy icon="temperature" label="Temperatura"
     Text item=HumP1Proxy icon="rain" label="Umidità"

}
Frame label="Living" {
    Group item=Livingroom label="Luci" icon="light"
     Text item=TempP0Proxy icon="temperature" label="Temperatura"
      }
}

Finally, If I rename the map file and the map name from myhouse2 to myhouse ALL come back to works

Libreria SWITCH ON (switch and Icon change status) image

Sala parete SWITCH ON (Group increase number ) image

lolodomo commented 6 years ago

I updated the demo sitemap to add the Lights group in the first frame, like that:

sitemap demo label="Main Menu"
{
    Frame {
        Group item=gFF label="First Floor" icon="firstfloor"
        Group item=gGF label="Ground Floor" icon="groundfloor"
        Group item=gC label="Cellar" icon="cellar"
        Group item=Garden icon="garden"
        Group item=Lights label="Lights"
    }

Here is the definition of the group:

Group:Switch:OR(ON, OFF)        Lights      "All Lights [(%d)]"

I have the feeling to be exactly in your case.

Now if I open 2 Basic UI, one on the main page and one inside the Lights group, when I switch one light ON or OFF in the second, I can see the number of ON lights updated in the first. So I can't reproduce your problem.