Hi Guys,
I’m trying to configure a Restful sensor and extract multiple nested JSON values and am struggling with the value_template ( I think )
I can successfully configure and extract one value at a time, but one hit to the same URL for every sensor might make my electricity provider cranky
My sensor config throws no errors, it just doesn’t populate.
I’m trying to return values nested under the “results” tag from the sample JSON output below.
- platform: rest
name: JSON elec
resource: https://xxxxxxx/uat/private/current/portal/dashboard/month/current
username: xxxxxxx
password: xxxxxxxx
authentication: basic
json_attributes:
- DayNumber
- TotalBillingDays
value_template: '{{ value_json.results[0] }}'
headers:
Content-Type: application/json
User-Agent: Home Assistant REST sensor
Sample JSON output to be parsed
{
"service": "Dashboard Data",
"status": "ok",
"results": {
"LatestBillingStartDate": "2017-05-06",
"LatestBillingEndDate": "2017-06-05",
"LatestReadDate": "2017-06-03",
"DayNumber": 29,
"TotalBillingDays": 31,
"MonthlyTotalUsage": 321.45,
"MonthlyTotalSpend": 123.54,
"MonthlyTotalGeneration": 0,
"MonthlyTotalSolarCredit": 0,
"ForecastSpend": 154.32,
"LatestBills": [
{
"InvoiceNumber": 99998,
"AmountDue": 123.45,
"DueDate": "2017-06-13 00:00:00",
"AmountPaid": 0,
"AccountNumber": "610130000000",
"InvoiceDate": "2017-05-23 16:15:55",
"TotalAmountDue": 123.45,
"TotalUsage": 543.21,
"BillEndDate": "2017-05-05 00:00:00"
},
{
"InvoiceNumber": 99997,
"AmountDue": 123.45,
"DueDate": "2017-05-18 00:00:00",
"AmountPaid": 123.45,
"AccountNumber": "610130000000",
"InvoiceDate": "2017-04-28 16:36:32",
"TotalAmountDue": 123.45,
"TotalUsage": 432.10,
"BillEndDate": "2017-04-05 00:00:00"
}
]
},
"agent": {
"device": "Other 0.0.0",
"platform": "Windows 10 0.0.0",
"browser": "Chrome 58.0.3029",
"remote_addr": "14.200.52.132"
}
}
TIA for any help