dawnlord
(Christer)
February 11, 2018, 11:04pm
1
This is the data to be used
- Temperature
- Humidity
- SolarInsolation
- AirPressure
- AirQuality
- WindSpeed
- NO2
- SO2
- O3
- PM10
- CO
- NOx
- PM2_5
From:
{“StartTime”:"/Date(1518368400000+0100)/",“StopTime”:"/Date(1518372000000+0100)/",“Weather”:{“Temperature”:{“Value”:0.96,“Unit”:“°C”},“Humidity”:{“Value”:90.9,“Unit”:"%"},“SolarInsolation”:{“Value”:-0.28,“Unit”:“W/m2”},“AirPressure”:{“Value”:988.71,“Unit”:“hPa”},“WindSpeed”:{“Value”:5.98,“Unit”:“m/s”},“WindDirection”:{“Value”:121.54,“Unit”:“°”},“RainFall”:{“Value”:0.4,“Unit”:“mm”}},“AirQuality”:{“TotalIndex”:0.73,“NO2”:{“Value”:12.15,“Unit”:“ppb”,“Index”:0.3},“SO2”:{“Value”:4.58,“Unit”:“ppb”,“Index”:0.09},“O3”:{“Value”:43.2,“Unit”:“ppb”,“Index”:0.54},“PM10”:{“Value”:36.43,“Unit”:“µg/m3”,“Index”:0.73},“NOx”:{“Value”:11.85,“Unit”:“ppb”,“Index”:0.04},“PM2_5”:{“Value”:29.82,“Unit”:“µg/m3”,“Index”:1.19}}}
This is how i try to get the data:
Bookmarking as I have a similar problem getting data from my elec supplier.
The rest sensor allows you to import the entire json set to the sensor which can then be extracted out as attributes, but has a limit of 255 characters which falls well short of the 400 or so that I need.
dawnlord
(Christer)
February 12, 2018, 6:40pm
3
Is there any other way to get the data?
arsaboo
(Arsaboo)
February 12, 2018, 7:05pm
4
Here’s something that you can use. It works in the template editor for me.
{%set value_json = {
"StartTime": " / Date(1518368400000 + 0100) / ",
"StopTime": " / Date(1518372000000 + 0100) / ",
"Weather": {
"Temperature ": {
"Value ": 0.96,
"Unit": "°C"
},
"Humidity": {
"Value": 90.9,
"Unit": "%"
},
"SolarInsolation": {
"Value ": -0.28,
"Unit": "W / m2"
},
"AirPressure": {
"Value ": 988.71,
"Unit": "hPa"
},
"WindSpeed": {
"Value ": 5.98,
"Unit": "m / s"
},
"WindDirection": {
"Value ": 121.54,
"Unit": "°"
},
"RainFall": {
"Value": 0.4,
"Unit ": "mm "
}
},
"AirQuality": {
"TotalIndex ": 0.73,
"NO2": {
"Value ": 12.15,
"Unit": "ppb",
"Index": 0.3
},
"SO2": {
"Value": 4.58,
"Unit": "ppb",
"Index": 0.09
},
"O3": {
"Value": 43.2,
"Unit": "ppb",
"Index": 0.54
},
"PM10 ": {
"Value ": 36.43,
"Unit": "µg / m3",
"Index": 0.73
},
"NOx": {
"Value": 11.85,
"Unit": "ppb",
"Index": 0.04
},
"PM2_5": {
"Value": 29.82,
"Unit": "µg / m3",
"Index": 1.19
}
}
} %}
{{ value_json.AirQuality.NO2['Value '] }}
dawnlord
(Christer)
February 12, 2018, 7:25pm
5
Since i am new to this i feel stupid.
How to handle the non-static data from the API?
arsaboo
(Arsaboo)
February 12, 2018, 8:43pm
6
dawnlord
(Christer)
February 12, 2018, 9:43pm
7
I appreciate your pointing in the right direction, but I need some more anyway. In your example you have taken a value. How do I get on with units as well as how I get more values?
dawnlord
(Christer)
February 12, 2018, 9:54pm
8
Oh now i think (hope) i get it.
- platform: rest
name: NO2
resource: http://data.goteborg.se/AirQualityService/v1.0/LatestMeasurement/XXX?format=json
method: GET
value_template: {{ value_json.AirQuality.NO2['Value '] }}
unit_of_measurement: "ppb"
arsaboo
(Arsaboo)
February 12, 2018, 9:56pm
9
You will also have to add resource
where you can include the URL