Bokeh plots in Home-Assistant

Whilst exploring alternatives to Grafana plots, I’ve discovered that Bokeh plots can be displayed in HA with this workflow.

  1. Generate a Bokeh plot, this produces a .html file, lets call ours graph.html
  2. Put the graph.html file in the www folder in the config directory (you will have to create if it doesn’t exist)
  3. Restart and check that you can view the plot on localhost:8123/local/graph.html
  4. Configure a panel iframe to display it on the HA front end

I will investigate if a script could be used to periodically regenerate the plot. For slow changing data (e.g. hourly/daily) this would be a very low overhead.
Cheers

5 Likes

Was contemplating trying this out, too, sometime. This might become a good alternative to the “history” view. Menus to choose which sensor data to plot over which period of time would be good, maybe then the data can be loaded dynamically?

Sure, use a shell command to run the python script which generates the plot file :slight_smile:

I don’t know if this also applies to Jupyter, but at work I mainly use Apache Zeppelin. There it is possible to share single pragraphs via HTML. Theoretically these can be integrated into an iframe. There you then could also use z.input or other dynamic variables for a user defined calculation and display.
…just an quick idea on the fly.

…::edit::…
Oh, I just realized this post is almost 2 years old :smiley:

1 Like

How do you move the *.html to the www folder? I cannot find the file I create with the bokeh ‘save(…)’ command.

EDIT: okay, I managed to find the files by connecting via ssh to the host

ssh [email protected] -p 22222

and then starting a bash in the appdaemon container

docker exec -it addon_a0d7b954_appdaemon bash

From the host I can also copy the file from the appdaemon container

docker cp addon_a0d7b954_appdaemon:/run/s6/services/appdaemon/bokeh_plot.html /tmp

and then copy it to the homeassistant container

 docker cp /tmp/bokeh_plot.html homeassistant:/config/www/

Have you found a way to have this run automatically?

you could use folder_watcher integration with a shell command

Thanks for the suggestion! I’ll give it a try, when I find the time.

1 Like