Webview (Grafana chart) and item selector for timezone not working properly

grafana
Tags: #<Tag:0x00007f1e668e5900>
(Sascha Billian) #1
  • Platform information:
    • Hardware: Raspberry PI 3
    • OS: openhabian 1.4
    • Grafana 5.3.4

I want to display different webviews depending on what time slot i am selecting.
I have four webviews that display the same chart with different times (day, week, month, year):

Webview icon=none url="http://openhabianpi:3000/d/ioB0_uWgk/raumtemperatur?orgId=1&panelId=4&theme=light&kiosk&fullscreen&from=now-1d&to=now"	height=11	visibility=[Proxy_TemperatureGroundFloor_DisplayDay==ON]
Webview icon=none url="http://openhabianpi:3000/d/ioB0_uWgk/raumtemperatur?orgId=1&panelId=4&theme=light&kiosk&fullscreen&from=now%2Fw&to=now"	height=11	visibility=[Proxy_TemperatureGroundFloor_DisplayWeek==ON]
Webview icon=none url="http://openhabianpi:3000/d/ioB0_uWgk/raumtemperatur?orgId=1&panelId=4&theme=light&kiosk&fullscreen&from=now%2FM&to=now"	height=11	visibility=[Proxy_TemperatureGroundFloor_DisplayMonth==ON]
Webview icon=none url="http://openhabianpi:3000/d/ioB0_uWgk/raumtemperatur?orgId=1&panelId=4&theme=light&kiosk&fullscreen&from=now%2Fy&to=now"	height=11	visibility=[Proxy_TemperatureGroundFloor_DisplayYear==ON]

So select the time range, I have a switch item:

Switch item=Proxy_TemperatureGroundFloor_TimeSelection	label="Zeitbereich"	mappings=[0="Tag", 1="Woche", 2="Monat", 3="Jahr"]

and finally a rule that changes the items for visibility:

rule "Display Temperature Ground Floor"
when 
    Item Proxy_TemperatureGroundFloor_TimeSelection received command
then
    switch(receivedCommand)
    {
        case 0:{    //day
            logInfo("Temperature groundfloor", "Day")
            Proxy_TemperatureGroundFloor_DisplayDay.postUpdate(ON)
            Proxy_TemperatureGroundFloor_DisplayWeek.postUpdate(OFF)
            Proxy_TemperatureGroundFloor_DisplayMonth.postUpdate(OFF)
            Proxy_TemperatureGroundFloor_DisplayYear.postUpdate(OFF)
        }
        case 1:{    //week
            logInfo("Temperature groundfloor", "1")
            Proxy_TemperatureGroundFloor_DisplayDay.postUpdate(OFF)
            Proxy_TemperatureGroundFloor_DisplayWeek.postUpdate(ON)
            Proxy_TemperatureGroundFloor_DisplayMonth.postUpdate(OFF)
            Proxy_TemperatureGroundFloor_DisplayYear.postUpdate(OFF)
        }
        case 2:{    //month
            logInfo("Temperature groundfloor", "2")
            Proxy_TemperatureGroundFloor_DisplayDay.postUpdate(OFF)
            Proxy_TemperatureGroundFloor_DisplayWeek.postUpdate(OFF)
            Proxy_TemperatureGroundFloor_DisplayMonth.postUpdate(ON)
            Proxy_TemperatureGroundFloor_DisplayYear.postUpdate(OFF)
        }
        case 3:{    //year
            logInfo("Temperature groundfloor", "3")
            Proxy_TemperatureGroundFloor_DisplayDay.postUpdate(OFF)
            Proxy_TemperatureGroundFloor_DisplayWeek.postUpdate(OFF)
            Proxy_TemperatureGroundFloor_DisplayMonth.postUpdate(OFF)
            Proxy_TemperatureGroundFloor_DisplayYear.postUpdate(ON)
        }
    }
end

The problem is that I am getting an error from grafana that the time zone is invalid when changing e.g. from day to week:


When I hit F5 in the browser the current chart is working again. But switching to another time zone causes the same error again.

My first idea was that grafana does not like it if several charts are loaded at the same time. (The visibility tag just shows/hides an HTML element)
But if I remove the visibility tag from the items in the sitemap, all graphs are shown without issues.

The URLs in the webview show no difference - i’ve doublechecked that with the developer tools from Chrome…

OK: I just realized that is seems to be browser related. Chrome and Edge have the same issue. The Android App is working fine.
So it’s not a real OH (or grafana) problem. But did somebody realize something similiar or did somebody run into the same issues (and maybe has a solution for browsers?)

0 Likes

(Udo Hartmann) #2

You don’t need this rule :wink:

Webview icon=none url="http://openhabianpi:3000/d/ioB0_uWgk/raumtemperatur?orgId=1&panelId=4&theme=light&kiosk&fullscreen&from=now-1d&to=now" height=11 visibility=[Proxy_TemperatureGroundFloor_TimeSelection==0]
Webview icon=none url="http://openhabianpi:3000/d/ioB0_uWgk/raumtemperatur?orgId=1&panelId=4&theme=light&kiosk&fullscreen&from=now%2Fw&to=now" height=11 visibility=[Proxy_TemperatureGroundFloor_TimeSelection==1]
Webview icon=none url="http://openhabianpi:3000/d/ioB0_uWgk/raumtemperatur?orgId=1&panelId=4&theme=light&kiosk&fullscreen&from=now%2FM&to=now" height=11 visibility=[Proxy_TemperatureGroundFloor_TimeSelection==2]
Webview icon=none url="http://openhabianpi:3000/d/ioB0_uWgk/raumtemperatur?orgId=1&panelId=4&theme=light&kiosk&fullscreen&from=now%2Fy&to=now" height=11 visibility=[Proxy_TemperatureGroundFloor_TimeSelection==3]

But this won’t change your problem. Is =now%2Fw&to=now correct?

1 Like

(Sascha Billian) #3

Thanks for the hint with the visibility. Didn’t know that :slight_smile:
The URL is correct:

If I have the error and just reload the browser page, the chart will be displayed without issues…
I will have a closer look this night (when the kids are asleep and I can be at the computer for more than 5mins without being interrupted :wink: )

0 Likes

(Sascha Billian) #4

Damnit - it even fails if i put the same URL for all four webview elements…
I think i give up.
But anyhow. Thanks for reading and helping :wink:

0 Likes

(Ron) #5

Have you tried with the browser in debug mode (F12)? That way you can see what is being sent.

0 Likes