[SOLVED] Grafana issue

Hi,

I followed this guide and I have configured influxdb + Grafana. Creating and manipulating a chart containing sensors temperature through Grafana server (openhab:3000) was as easy as it could be :grinning:

In the next step I have tried to include a graph in my sitemap, example taken here.

       Text item=Charts icon="calendar"{
            Webview url="http://MYIP:3000/static/chartsDay.html" height=33 
    } 

However, the OpenHAB does not open any chart but a blank window with the message

{message:“Invalid username or password”}

This is the corresponding log

2020-02-11 22:44:50.958 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item ‘Charts’ for widget org.eclipse.smarthome.model.sitemap.sitemap.
2020-02-11 22:44:50.960 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item ‘Charts’ for widget org.eclipse.smarthome.model.sitemap.sitemap.Text
2020-02-11 22:44:50.964 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.sitemap.Text
2020-02-11 22:44:50.966 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.sitemap.Text
2020-02-11 22:44:51.842 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.sitemap.Text
2020-02-11 22:44:52.013 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item ‘Charts’ for widget org.eclipse.smarthome.model.sitemap.sitemap.Text
2020-02-11 22:44:52.019 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item ‘Charts’ for widget org.eclipse.smarthome.model.sitemap.sitemap.Text
2020-02-11 22:44:52.025 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.sitemap.Text
2020-02-11 22:44:52.030 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

Please note I have enabled the anonymous access in /etc/grafana/grafana.ini

#################################### Anonymous Auth ######################
[auth.anonymous]
enabled = true

Anything obvious I might have missed?

Thanks
Max

I think Grafana also has a setting to allow embedding charts in other websites that needs to be set. I don’t embed directly so can’t say what it is but this should give you enough to search on.

The embedding is mentioned in this post, but it looks like there may be other issues based on the log above.

[security]
allow_embedding=true

That’s in /etc/grafana/grafana.ini, and grafana will need to be restarted after the change is made.

As mentioned, make sure you’ve restarted Grafana after the ini updates.

Also, the logs appear to show that you don’t have an appropriate item called “Charts” in your items file which makes me wonder if you might have an issue in the sitemap file.

Have you tried using the webview with just Webview url="/static/chartsDay.html" part called out like in the example?

What a helpful community :slightly_smiling_face:

Some steps done

  • all settings adjusted, full (windows-style :wink:) system restart

  • sitemap reduced to

sitemap home label="Home" {
    Frame {
            Webview url="http://192.168.178.56:3000/static/chartsDay.html" height=33 
          }
}

Now grafana is loaded - I see the “sun” spinning and jumping around while loading the page, then a nice version of the classic “404 Page not found” appears :rofl: - see below.

The log does not show any error anymore
Max

Wait, that URL doesn’t make sense. If you are following Paul’s approach you need to create chartsDay.html and put that in $OH_CONF/html/chartsDay.html. That HTML file has the links to your Grafana charts. On your sitemap you put

http://<IP of your OH instance>:8080/static/chartsDay.html

I highly recommend returning to Paul’s post and reread how it is supposed to work.

What is in your chartsDay.html file?

Fair point, I misunderstood the snipped needed for the Android workaround

Webview url="http://YOURIP:YOURPORT/static/chartsHour.html" height=33 visibility=[weatherChartPeriod=="0"]

It is now solved when

  • I put the right port in the sitemap
  • I use in both the html and in the sitemap the FQN of the OH server (openhab).

Thanks all, I have learned something more!
Max

Next step - try to reproduce what @pahansen did in his original post.

Now sitemap contains

    Frame {
    Text item=Charts icon="calendar"{
        Switch item=weatherChartPeriod label="Chart Period" mappings=[0="Hour", 1="Day", 2="Week"]
        Webview url="http://openhab:8080/static/chartsHour.html" height=33 visibility=[weatherChartPeriod=="0"]
        Webview url="http://openhab:8080/static/chartsDay.html" height=33 visibility=[weatherChartPeriod=="1"]
        Webview url="http://openhab:8080/static/chartsWeek.html" height=33 visibility=[weatherChartPeriod=="2"]
        }
    }

with chart.items simply (I might have missed something here, but I could not find any hint in the original post)

Switch weatherChartPeriod "Chart Period"
String Charts "Charts"

All files are loaded w/o issues, but when I try to access the charts the log shows

2020-02-12 23:26:22.951 [WARN ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at 'items/weatherChartPeriod' with an invalid status value '1'.

with the ‘1’ actually being ‘0’, ‘1’ or ‘2’ according to the clicked mapping.

Be kind with me, I am not a Web frontend expert :wink:

Thanks
Max

String weatherChartPeriod "Chart Period"