So I’ve set up an Air Quality sensor using the REST platform to pull data from EPA Victoria (https://www.epa.vic.gov.au/) and it’s working well. However, I’d like it to take on a few more attributes which I can’t workout how to do.
The JSON data supplied by the link for the sensor I use is as follows:
{
"siteID" : "4afe6adc-cbac-4bf1-afbe-ff98d59564f9",
"siteName" : "Melbourne CBD",
"siteType" : "Standard",
"geometry" : {
"type" : "Point",
"coordinates" : [
-37.8073959,
144.97
]
},
"siteHealthAdvices" : [
{
"since" : "2020-01-05T11:00:00Z",
"until" : "2020-01-05T12:00:00Z",
"healthParameter" : "PM2.5",
"averageValue" : 1.8,
"unit" : "µg/m³",
"healthAdvice" : "Good",
"healthAdviceColor" : "#64A13C",
"healthCode" : "1021"
}
],
"parameters" : [
{
"name" : "PM2.5",
"timeSeriesReadings" : [
{
"timeSeriesName" : "1HR_AV",
"readings" : [
{
"since" : "2020-01-05T11:00:00Z",
"until" : "2020-01-05T12:00:00Z",
"averageValue" : 1.8,
"unit" : "µg/m³",
"confidence" : 91.67,
"totalSample" : 12,
"healthAdvice" : "Good",
"healthAdviceColor" : "#64A13C",
"healthCode" : "1021"
}
]
},
{
"timeSeriesName" : "24HR_AV",
"readings" : [
{
"since" : "2020-01-04T12:00:00Z",
"until" : "2020-01-05T12:00:00Z",
"averageValue" : 4.6,
"unit" : "µg/m³",
"confidence" : 95.49,
"totalSample" : 288,
"healthAdvice" : "Good",
"healthAdviceColor" : "#64A13C",
"healthCode" : "1029"
}
]
}
]
}
]
}
The sensor set up is as follows:
- platform: rest
resource: "https://gateway.api.epa.vic.gov.au/environmentMonitoring/v1/sites/4afe6adc-cbac-4bf1-afbe-ff98d59564f9/parameters?X-API-Key=sekritkey"
name: Melbourne Air Quality
json_attributes:
- siteName
value_template: '{{ value_json["siteHealthAdvices"][0]["healthAdvice"].title() }}'
headers:
User-Agent: Home Assistant
Content-Type: application/json
And I get the following:
How am I able to include few of the other data fields as attributes? Mainly the “averageValue” that’s under “siteHealthAdvices”.
Cheers!