Graph widget for influxdb

There’s only one sample on entering MultiPlot. WHere is the dataseries read?

dataseries

Hmm, try adding

samples: 100

to the widget definition.

yep, that did it :sunglasses:

FYI before adding samples: 100 I traced back to the data fetch in InfluxDB_Data and all 50 records are returned, so it loses them after that. I wondered if it was because I don’t have many samples yet, I only created everything mid-morning.

Thanks for your quick support, and even more for the widget

John

Glad you got it working, but this means that there is a bug in the downsample section since you should not need to specify “samples”. I’ll make “samples” a mandatory argument in the docs until I have corrected the bug.

I guess the home assistant version has the same problem. There is also a dev version available that can read data both from the home assistant db and from influx. https://github.com/tjntomas/Dev-Graph-Widget

I found that as long as I include sample: , even with a value of 1, it works.
Final quick question: how do I control the x-axis legend - I’m getting too many labels and they are all full date & time. I couldn’t find that in the docs yet.

I’ll have to look in the plot.ly docs and see what options exists for the x-axis legend. I think the x-axis will look better when you have more data though and this might be the reason why I haven’t noticed this.

And this solves the issue of fixing the code. I will just set samples to 1 if not specified.

I’ll leave it running for a couple of days and see how things change.

I played around with the time zone and locale settings here:

self.TIME_ZONE = Settings(self, ‘time_zone’,‘Europe/Stockholm’)
self.LOCALE = Settings(self, ‘locale’,‘sv’)

The ‘default’ Swedish settings result in a nice display - date & time at the first point then 00:00, and time HH:MM at 06:00, 12:00, 18:00. If I try any other settings I get full date + time ‘dd-mm-yyy hh:mm:ss’ every 2 hours. I can live with Swedish for this :wink:

deleted, wrong post, sorry

Ok, That should be easy to fix, I’ll have a look at it.

Ok, it looks like the plotly library ignores timezones, see here https://github.com/plotly/plotly.js/issues/1532

A workaround seems to be to keep “sv” as locale and use for instance “Europe/London” (-1 h from Stockholm) or “Europe/Athens” ( +1 h from Stockholm) as timezone. This gives the correct time when I try it out.

You can also define the locale and timezone in the widget definition instead of changing the code:

time_zone: Europe/London
locale: sv

Yes, that works, thanks again

Hi tjntomas

Is there any plans on getting the HTTPS SSL working? Ran into another widget I am trying to play with but it requires HADashboard to be setup with SSL but this breaks your nice graphs.

I now have HADasboard setup with SSL and the graph widget works fine. Can you post your appdaemon.yaml perhaps?

Here is my appdaemon.yaml config minus the token

secrets: /config/secrets.yaml
log:
logfile: STDOUT
errorfile: STDERR
appdaemon:
threads: 20
app_dir: /config/appdaemon/apps
plugins:
HASS:
type: hass
ha_url: http://hassio/homeassistant
token: XXX
hadashboard:
dash_url: https://127.0.0.1:5050
dash_dir: /config/appdaemon/dashboards
dash_ssl_certificate: /ssl/fullchain.pem
dash_ssl_key: /ssl/privkey.pem

Here is the error i am getting in the debug for Chrome.

application.js:3025 Uncaught DOMException: Failed to execute ‘send’ on ‘XMLHttpRequest’: Failed to load ‘http://192.168.169.135:8086/query?db=home_assistant&data=urlencode&pretty=false&q=SELECT%20first(value)%20FROM%20"°F"%20WHERE%20entity_id%20=%20’office_temperature_2’%20AND%20time%20>%20now()%20-1d%20group%20by%20time(1h)%20fill(linear)&u=homeassistant&p=XXXX’.
at InfluxDB_Data (https://hassio.1mrb.com:5050/compiled_javascript/application.js:3025:8)
at draw (https://hassio.1mrb.com:5050/compiled_javascript/application.js:3099:20)
at Object.OnStateAvailable [as initial] (https://hassio.1mrb.com:5050/compiled_javascript/application.js:2787:3)
at Object.success (https://hassio.1mrb.com:5050/javascript/dashboard.js:219:36)
at i (https://hassio.1mrb.com:5050/javascript/jquery-3.1.1.min.js:2:27983)
at Object.fireWith [as resolveWith] (https://hassio.1mrb.com:5050/javascript/jquery-3.1.1.min.js:2:28749)
at A (https://hassio.1mrb.com:5050/javascript/jquery-3.1.1.min.js:4:14203)
at XMLHttpRequest. (https://hassio.1mrb.com:5050/javascript/jquery-3.1.1.min.js:4:16491)

10Mixed Content: The page at ‘’ was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint ‘’. This request has been blocked; the content must be served over HTTPS.

Ok, you need to expose the influxdb also over SSL and pass the inluxdb url as https://. As far as I know, there is no other work-around like changing the code etc. Are you using nginx for SSL? If so, it should be easy.

See more here: https://docs.influxdata.com/influxdb/v1.7/administration/https_setup/