A friendly alert. Your grafana_graphs.py script is not working. The service is not registering,
A lot of problems with the indentation.
Any thoughts about contributing this to the core distribution? I think it would be really helpful.
Hi,
I followed up exactly what you write, but keep getting the following error in the logs:
Could not read camera image from file: downloads/grafana_graphs/xxxx
Changed a lot in indentation in your python scripts. Scripts does not give any errors now, but not grapsh shown in the folder.
Could you help?
Thanks
The offical downloader component now allows to specify a filename and whether to overwrite the file or not. Have a look at https://home-assistant.io/components/downloader/.
You therefore no longer have to create a custom component like in step 2 shown.
If you created a custom component as described in step 2 in the original post you can delete your [configdir]/custom_components/grafana_graphs.py
.
Your python_script [configdir]/python_scripts/retrieve_grafana.py
now should look like:
"""
Download a rendered png from a panel in grafana into a subdirectory.
"""
subdir_name = 'grafana_graphs'
# example parameters for downloader component
data = {
'url': 'http://[User]:[Password]@[IP or hostname of grafana]:3000/render/dashboard-solo/db/aussenbedingungen?orgId=2&panelId=1&theme=light&width=500&height=250',
'subdir': subdir_name,
'filename': 'aussenbedingungen_2_1',
'overwrite': True
}
# call downloader component to save the file
hass.services.call('downloader', 'download_file', data)
Please be sure to replace [User], [Password] and [IP or hostname of grafana] to your need.
In the script you can see that a filename can be specified e.g. 'filename': 'aussenbedingungen_2_1'
and the option 'overwrite': True
can be specified to overwrite the file if existing.
Other than in step 3 you have to put
downloader:
download_dir: downloads
in your configuration.yaml.
That’s it.
Thanks for your quick response! Did what you said, but i keep getting in the log:
2017-12-19 23:40:00 WARNING (MainThread) [homeassistant.core] Unable to find service python_script/retrieve_grafana
Also running downloader.download_file from the HA page does not work. Also errors that the camera file cannot be found.
It looks like the error message indicates that there is no file/script retrieve_grafana.
Please check whether your script
retrieve_grafana.py
is in your
python_scripts
directory?
And check whether
python_scripts
directory is in the folder where your
configuration.yaml
is.
Yes, this is both the case. Checked double.
Chmod 777 on the file and dir gives no result either.
Can it possibly be that you didn’t enable pyhton_scripts in your configuration.yaml?
# Allow to use python_scripts
python_script:
Can’t imaging that i overlooked this setting. The error 'cannot find service ’ didn’t triggered me. Thanks !!!
it is working like a charme now.
How did you get this to work? Grafana says there is no url based authentication. How to auth via browser URL without enabling anonymous? · Issue #2729 · grafana/grafana · GitHub
I am also not able to get the image on the URL unless I enter the username/password again
http://[User]:[Password]@192.168.2.113:3000/render/dashboard-solo/db/home-assistant?refresh=5s&panelId=1&orgId=1&from=1517756914526&to=1517778514526&width=1000&height=500&tz=UTC-05%3A00
When I paste the URL in Firefox, I see the message:
You are about to log in to the site “192.168.2.113” with the username “root”, but the website does not require authentication. This may be an attempt to trick you.
Is “192.168.2.113” the site you want to visit?
Looks like we need to use API keys to get the images. See here.
Now, we need to figure out how to save the file in the download directory.
Please look at http://docs.grafana.org/http_api/auth/ under “Basic Auth” an be aware that a browser is handling the auth for security reasons different then e.g. curl or a python script. For example see “Access using credentials in the URL” under https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication.
oh okay, thanks for the link, that explains it pretty well. will definitely try over the weekend.
Agreed!! Ll
I have problem with render this image in Home Assistant.
retrieve_grafana.py create file but it’s not png file.
So in HA i have (image not available)
In webbrowser link work.
So i need use link with login and password in ha but in webbrowser it’s not needed?
Hi all, I’m using Grafana and Influx db as addon on hassio running directly on rpi b 3+, created graphs for rpi cpu temp and 3 graphs for temp, humidity and pressure of a zigbee aqara sensor connected with cc2531 dongle, is it right that in Lovelace iframe card I don’t see updated graphs of the sensor aqara? I used embed link (not pgn method) but it doesn’t refresh the graphs, only cpu temp is updated. I don’t know how to retrieve data in order to display updated graphs, how can I do it?
I can also use another method if it can refresh the graphs, I have sensor in the recorder and I purge db every 3 days, if I don’t have storic longer than 3 days is not important, I will fix that later, for now I would like to have refreshed up to date graphs in lovelace
You should add refresh
parameter to your grafana url. More details you can find in my blog post: https://dummylabs.com/post/2019-01-13-influxdb-part1/
You will want “Refresh Interval for Embedded Diagrams” section.