Hi everyone,
I tried to make buienradar gspgadget to work in Homeassistant but until now I didn’t manage to make it a succes.
website (https://gpsgadget.buienradar.nl/data/raintext?lat=51.46&lon=3.55)
I’ve got this sensor in my command_line.yaml
- sensor:
name: buienradar_gpsgadget
command: python3 -c "import requests; import json; import random; dataRequest = requests.get('https://gpsgadget.buienradar.nl/data/raintext?lat=51.46&lon=3.56&c='+str(random.randint(0,999999999999999))).text; dataRequest = dataRequest.replace('\r\n',' '); data = '{\"data\":\"'+dataRequest+'\"}'; print(data);"
json_attributes:
- data
value_template: "last_changed: {{states.sensor.weather_buienradar_direct.last_changed | default(now())}}"
scan_interval: 300
I looked around on this forum and found and tweaked a little bit in the template-editor
{% set value = state_attr('sensor.buienradar_gpsgadget','data') %}
{% set data = value.split() %}
{% set value = namespace(list=[]) %}
{% for n in data %}
{% set value.list = value.list + [{ "time": n.split('|')[1], "rain": ( 10** (( n.split('|')[0] | float - 109 ) / 32 )) | round(1) }] %}
{% endfor %}
{% set time = value.list | map(attribute = "time") | list | to_json %}
{% set rain = value.list | map(attribute = "rain") | list | to_json %}
{{ time.replace('"','')}}
{{ rain }}
I got the next result, 2 list array’s
[23:15,23:20,23:25,23:30,23:35,23:40,23:45,23:50,23:55,00:00,00:05,00:10,00:15,00:20,00:25,00:30,00:35,00:40,00:45,00:50,00:55,01:00,01:05,01:10]
[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]
Can anybody help how to go on with this result to make it work in some bar-graph?
Thanks in advance