Graph widget for influxdb

I have a hass.io install on Ubuntu running in docker for SSL i am using the let’s encrypt add-on. I will look into this as i thought this might be the case but wasn’t positive. Just hard to edit anything directly for the docker containers for the add-ons

Looks like the InfluxDB add-on for Hass.io doesn’t support SSL for the database connection. I opened a issue up for the add-on we will have to see what they can do. Thanks @tjntomas

There seems to be an option to enable SSL on the influxdb web interface which should be enough.
https://github.com/hassio-addons/addon-influxdb

Did you try that?

Hmm, might only be for the management interface after reading a bit more.

Thanks but it is only for the management interface and this is what the developer said when i created a issue for the SSL problem even though I linked the web page that you mentioned above as well.

“As mentioned in the documentation, it is not available due to technical issues in the InfluxData software.
There is nowhere I can go with this issue.”

the best way to go is to forget about SSL in dashboard, influx and home assistant.

if you want to use homeassistant outside your network then create a proxyserver for the SSL, then you can remove it in all other programs.

i always try to let people see it like this.

if you see your network as your house then you now have a lock on your livingroomdoor (homeassistant port) bedroomdoor(appdaemon) and bathroomdoor(influx) and you need that because everyone can go through your hallway.
like in your house that situation unwanted. so you create a frontdoor with a lock (proxyserver)
from that moment on you can unlock you other doors and walk freely though your house.

Hello,

I’m new to HA :slight_smile: I found this discussion about graphs - the usage of plotly is what I’m looking 4 to show highly configurable history graphs in HA.

With respect to this just one (probably stupid) question:

Can I use this widget in a lovelace card?

Thanks a lot for help - maybe somebody can point me to the right discussion or solution…

Chris

widgets in the HADashboard section are created for HADashboard, which is a part from appdaemon
https://appdaemon.readthedocs.io/en/dev/index.html

there are not usefull for anything else.
if you want to work with lovelace cards and graphs, you need to look in the frontend section from the forum.

thanks a lot for your quick answer !

How can I define the name written on Y axis?

Also I’m using this as a Panel, I would like to show two another sensor for the outdoor_humidity but I think I can’t define multiple SQLs. How would I do this?

indoor_humidity:
  widget_type: graph
  entities:
    - 'sensor.indoor_humidity'
  influxdb_units:
    - 'humidity'
  titles:
    - "Indoor humidity"
  time: 24h
  title: "Humidity"
  fill: "tozeroy"
  colorIndex: 0
  log: 1
  sql: "select mean(value) from humidity where entity_id='indoor_humidity' and time > now() - 24h GROUP BY time(15m) fill(previous)"
  max: 100
  time_zone: "America/Sao_Paulo"

btw: is it possible to define a fixed Y max? As it is humidity it could be from 0 to 120 and it would show on the graph the higher value being 120? I tried with max: but it doesn’t seem to work

Try defining both min and max and it should work. This is a bug so I will fix it so it works with either max, min or both defined.

The unit on the y-axis is taken from the units_of_measurement attribute of the entity. I can add a setting to overide this in the widget.

As for multiple custom sql queries, I didn’t implement this, but I will have a look at it. Should be fairly simple to add.

I am trying to use this custom widget, however I get the following error:

2020-04-01 15:01:44.167061 WARNING AppDaemon: Error in widget definition ‘%s’:
2020-04-01 15:01:44.167954 WARNING AppDaemon: parser says
2020-04-01 15:01:44.168612 WARNING AppDaemon: in “”, line 115, column 71:
… r-bar top-0 left-0" style=“width: 0%;”>
^
2020-04-01 15:01:44.169472 WARNING AppDaemon: mapping values are not allowed here

I have influxDB installed as add-on to Hassio on my RPI.
Any help is welcome.

Thanks

C

Please post any error you get in the browser javascript console.Just presss F12 in Chrome to open the console or Option + ⌘ + C for Safari.
Please also post the widget config and the entries you added to the skin file variables.yaml so I can have a look. Looks like a problem in the variables.yaml file.

you are quick! Thanks for the reply. Here are the info:

Widget config (as your example):
mvp:
widget_type: graph
entities:
- sensor.corona_virus_florida # The entity_id to be plotted.
influxdb_units:
- “°C” # The unit_of_measurement attribute for the entity.
titles:
- “Indoor temperature” # Title of the trace.
time: 24h # Time interval to plot. You can use “m” for minutes, “h” for hours, “d” for days and “w” for weeks.
title: “Temperatures” # Widget title
fill: “tozeroy” # options are “none” | “tozeroy” | “tozerox” | “tonexty” | “tonextx” | “toself”
colorIndex: 0 # A number between 0 and 11. 12 colors for the traces are predefined and the colorIndex defines

which is used for the first trace. If more than 12 traces/entities are specified, the colors are rotated.

Variables (as your example):
graph_style: “border-radius: 0px; background-color: rgba(30,30,30,0.45 );” # Change to whichever css you like.
graph_legend_text_color: “#888888
graph_grid_color: “#888
graph_title_color: “#cccccc
graph_x_axis_text_color: “#cccccc
graph_y_axis_legend_color: “#cccccc
graph_y_axis_text_color: “#cccccc
graph_influxdb_path: http://192.168.2.199:8086 # Example: 192.168.1.20:8086 or http://www.mydomain.com:8086
graph_influxdb_path_local: “http://192.168.2.199:8086
graph_widget_style: “border-bottom-left-radius: 10px;border-bottom-right-radius: 10px;border-top-left-radius: 10px;border-top-right-radius: 10px;”
graph_trace_colors: “1” # Set the opacity for the trace colors.
graph_fill_colors: “1” # Set the opacity for the fill colors.
graph_bar_colors: “1” # Set the opacity for the bar colors.
graph_bar_multi: “1” # Leave this as is
graph_user: XXX # ONLY INCLUDE THIS LINE IF AUTHENTICATION IS ENABLED FOR INFLUXDB
graph_password: XXX # ONLY INCLUDE THIS LINE IF AUTHENTICATION IS ENABLED FOR INFLUXDB
graph_degrees_celsius_text: “Degrees Celsius” # Adjust to your own language
graph_degrees_fahrenheit_text: “Degrees Fahrenheit” # Adjust to your own language
graph_percent_text: “Percent” # Adjust to your own language
value_in_legend: 1 # If this parameter is present, the current value for each trace is displayed in the legend section.

Below is the error give in the javascript console:

Please use code formatting when posting so that the code is readable. Its imposssible to see if anything is wrong without code formatting. From the console error, it looks like there is an error in the variables.yaml file, but you need to post using code formatting so I can find it.
You format code by entering four ` characters before and after your code blocks or by selcting the code block and pressing the </> icon in the editor. Its says “Preformatted text” if you hover over it. Or press CTRL Shift C and paste the code.

Also, you need to use the correct unit of measurement for the sensor you are using. You have kept Degrees Celcius from my example which is obviously not the unit of measurement for your corona sensor. Might be easier to debug the widget with a temperature sensor entity unitl we have sorted things out.

Ok, now I have formatted it properly and I went back to a temperature sensor

Widget configuration:

  widget_type: graph
  entities:
    - sensor.cpu_temperature  # The entity_id to be plotted.
  influxdb_units: 
    - "°C"   # The unit_of_measurement attribute for the entity.
  titles:
    - "Indoor temperature" # Title of the trace.
  time: 24h   # Time interval to plot. You can use "m" for minutes, "h" for hours, "d" for days and "w" for weeks.
  title: "Temperatures"  # Widget title
  fill: "tozeroy" # options are  "none" | "tozeroy" | "tozerox" | "tonexty" | "tonextx" | "toself" 
  colorIndex: 0   # A number between 0 and 11. 12 colors for the traces are predefined and the colorIndex defines 
  # which is used for the first trace. If more than 12 traces/entities are specified, the colors are rotated. 

Variables:

graph_style: "border-radius: 0px; background-color: rgba(30,30,30,0.45 );"  # Change to whichever css you like.
graph_legend_text_color: "#888888"
graph_grid_color: "#888"
graph_title_color: "#cccccc"
graph_x_axis_text_color: "#cccccc"
graph_y_axis_legend_color: "#cccccc"
graph_y_axis_text_color: "#cccccc"
graph_influxdb_path: http://192.168.2.199:8086 # Example: 192.168.1.20:8086  or http://www.mydomain.com:8086
graph_influxdb_path_local: "http://192.168.2.199:8086"
graph_widget_style: "border-bottom-left-radius: 10px;border-bottom-right-radius: 10px;border-top-left-radius: 10px;border-top-right-radius: 10px;"
graph_trace_colors: "1"  # Set the opacity for the trace colors.
graph_fill_colors: "1"   # Set the opacity for the fill colors.
graph_bar_colors: "1"    # Set the opacity for the bar colors.
graph_bar_multi: "1"     # Leave this as is
graph_user: XXX # ONLY INCLUDE THIS LINE IF AUTHENTICATION IS ENABLED FOR INFLUXDB
graph_password: XXX # ONLY INCLUDE THIS LINE IF AUTHENTICATION IS ENABLED FOR INFLUXDB
graph_degrees_celsius_text: "Degrees Celsius"  # Adjust to your own language
graph_degrees_fahrenheit_text: "Degrees Fahrenheit"  # Adjust to your own language
graph_percent_text: "Percent"  # Adjust to your own language
value_in_legend: 1 # If this parameter is present, the current value for each trace is displayed in the legend section.````

Ok, all looks good. I noticed an error in my instructions. The

value_in_legend: 1

should be in the widget definition, not in variables.yaml so please move it there. It is however likely not the cause of the problem.

  1. Does the console error remain the same after changing the sensor entity?
  2. In the console error, it says "SyntaxError: Unexpected token ‘<’. Please click on the line below where it says application.js:2858. This should show you the actual offending javascript code.

And add:

log: 1

to the widget config so your config will be as below: EDITED A BIT:

mvp:
  widget_type: graph
  entities:
    - sensor.cpu_temperature 
  influxdb_units: 
    - "°C"  
  titles:
    - "Indoor temperature" 
  time: 24h   
  title: "Temperatures" 
  fill: "tozeroy" 
  colorIndex: 0
  value_in_legend: 1
  log: 1

It will then output some more debug info in the console.

1 changing the sensor did not impact the issue
2 the first time I load the dashboard I obtain this without errors in the console:

3 the second time I load it and get the error in console that I showed before, when I click on it: