A graph widget for HADashboard

This widget is similar to the influxdb graph widget that I posted earlier but this one reads the data directly from the Home Assistant database, so no need for influxdb. Compared to the influxdb graph widget, this one is a bit more limited and you cannot write custom SQL queries (not yet anyway).

You can find the widget here:
Graph widget

@ReneTode, let me know if the name clashes with your widget and I will rename it so both can be used in the same setup.


i dont have a graph yet, so there is no problem there.
can you make the history optional?

preferably so that setting the path and token to HA will give the history and when not set then it will work without history.

even more perfect it would be if it was 1 widget for both the influx and the ha version.
and there would be a setting
history_type: HA|influx|none

it would make a great addition to dashboard and we would love to integrate it.

if you would create it that way i would like a few minor changes

rename hagraph_path to ha_url
rename hagraph_token to ha_token

use for the widget base and yaml graph.

thx for the efford you are making.

I considered this, but the code is quite different for the two widgets, but I’ll give it a try. The reason is that the influxdb widget uses the OnStateAvailable event to start plotting, while the hagraph has to open a websocket to get something called “signed paths” to access the REST API so everything is async. I’ll have to figure out how to solve this. Possibly I could use different callbacks based on if it reads from HA or influxdb.

1 Like

It’s not clear to me what you want the widget to display when you chose “None” as history_type. What data should it plot then?

the data from the entity that i chose from the moment i start the graph.
so just the incoming data.

the reason why i ask is that i like the widget as general as possible. so even usefull when i got no history db at all.

Ok, I got it. That would be easy.

1 Like

and indeed the best way is just to put in both codeblocks as they are and in the beginning based on the type decide which callbacks to use.

we could later on then even consider adding other possible data inputs

Yes, I read data from a few other sources also and then use just a simple sqlite3 library to connect.

great i look forward to the changes.

and thanks for doing this.
if you have any questions or want to talk things over, please contact me on discord

Have a look at this dev version as per your suggestions. Some fixes are needed.
Dev Graph widget

sorry i dont understand what you are asking to look for :wink:
do i need to look at the read me or the js?

in the readme i see you still use
hagraph_path: http://path_to_your_home_assistance_instance:8123 # will change name to base_url or similar
hagraph_token: YOUR_LONG_LIVED_ACCESS_TOKEN # Can be created through the Home Assistant front end.
instead off ha_url and ha_token

in the examples i see you use hagraph (and not graph)
and the needed options are not in the example (url and token)

i also see that you say: example dashboards for …
that should be example widget definitions

i see your description to add other DBs. nice.
i think we will have to add an url to your readme after we have it in AD, because what you got in the readme is to extensive for the docs from AD at this point.

we would need a description in this style when it is implemented:


A widget to monitor and activate a lock

Note that unlike HASS, Dashboard regards an unlocked lock as active. By contrast, the HASS UI shows a locked lock as “on”. Since the purpose of the dashboard is to alert at a glance on anything that is unusual, I chose to make the unlocked state “active” which means in the default skin it is shown as red, wheras a locked icon is shown as gray. You can easily change this behavior by setting active and inactive styles if you prefer.

Mandatory Arguments

  • entity - the entity_id of the lock

Optional Arguments:

  • title - the title displayed on the tile
  • title2 - a second line of title text
  • state_text
  • state_map

Cosmetic Arguments

  • icon_on
  • icon_off
  • widget_style
  • icon_style_active
  • icon_style_inactive
  • title_style
  • title2_style

Yes Rene, those were the comments I needed, no need to look at the code :slight_smile:
I’ll use ha_url and ha_token and I guess graph is a suitable name for the widget. I’ll take some time to also read what the docs says about contributing widgets.

1 Like

if you find something in the docs about contributing widgets i like to know where, because then it needs to be removed :wink:

the plan is to create a git collection for custom widgets/skins/apps/plugins, but that needs a little time.

as soon as you have some more ready just say so and ill take a look (and give it a test)

Ok, I think I saw something written about this, but that might have been a post by Andrew or you in the forum. I github collection for the custom widgets makes sense.

1 Like

I’m not capable of running the widget.
This is the error that the console tells me:

WebSocket connection to ‘ws://’ failed: Connection closed before receiving a handshake response

If I try to access https://HA_URL:8123/api/websocket from the browser I get the following message:

No WebSocket UPGRADE hdr: None
 Can "Upgrade" only to "WebSocket".

Any suggestions?

Please post your widget definition.

I’ve got everything just like the example. The only thing different is the sensor

    widget_type: hagraph
      - sensor.temperatura_tendedero  # The entity_id to be plotted.
    units:  "°C"   # The unit_of_measurement for your sensors/entities
      - "Indoor temperature" # Title of the trace.
    time: 24h   # Time interval to plot. you can combine w, d, h and m as 2w1d3h20m (This would be 2 weeks, 1 day, 3 hours and 20 minutes)
    title: "Temperatures"  # Widget title
    value_in_legend: 1
    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
    log: 1
    # which is used for the first trace. If more than 12 traces/entities are specified, the colors are rotated.

Please also post the entries in the skin.

There’s not much change either.

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_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_degrees_celsius_text: "Grados Celsius"  # Adjust to your own language
graph_degrees_fahrenheit_text: "Grados Fahrenheit"  # Adjust to your own language
graph_percent_text: "Porcentaje"  # Adjust to your own language
hagraph_path:  # Adjust the port if needed.
hagraph_token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJjYzY5NDI0NmY5YmM0ZTEwOGFjNzU0YTUzZDc5Zjg0MyIsImV4cCI6MTg2MjE3MzA4NiwiaWF0IjoxNTQ2ODEzMDg2fQ.KszD2dLsD_7LfNFi7X2LQyJq2Qv8kGEqCNUdLs2Xcae

OK, everything looks ok. I think it’s an issue with ssl since you are using https. I don’t use https so I can’t try it now but if you want, you can try changing line 375 in basehagraph.js from

var url = "http://" + BASE_URL + path + filter


var url = "https://" + BASE_URL + path + filter

And see if it helps. It will not solve the websocket issue but it will solve another error you would receive once the websocket connecttion is working.

To fix the websocket issue you can try adding your network to trusted networks in your configuration.yaml for Home Assistant.


You would then need to add this to the auth_providers section in configuration.yaml

   - type: homeassistant
   - type: trusted_networks