Hi,
First off, I’m not a programmer so this stuff is copy/paste from other posts. Basically I noticed that someone had a module for Magic Mirror that used my local council’s API to get bin collection dates. I thought I could try get this into my HA setup, so after hours of pouring over his code I found a JSON Post command that I could use to get a JSON response with my bin collection dates BUT I’ve come across the 255 character limit. Looking this up everybody says to use json_attributes to split it up. As I don’t understand this step, I’ve spent hours trying to get it to work but not got anywhere.
My sensor looks like this at the moment:
- platform: rest
name: JSON BINS
resource: https://citizen.westberks.gov.uk/apiserver/ajaxlibrary
method: POST
payload: '{ "jsonrpc" : "2.0" , "id" : "1321456987934464654" , "method" : "veolia.wasteservices.v1.getServicesByUPRN" , "params" : { "uprn" : "XXXXXMYUPRN" } }'
json_attributes:
- Description
- Last
#- Next
#- State
#- TaskType
#value_template: '{{ value_json.value}}'
headers:
Content-Type: application/json
User-Agent: Home Assistant REST sensor
If I POST in Postman I get the following back, which all seems to work, I just can’t figure out a way to capture it. I basically want the below out of the JSON
“ServiceName”: “Domestic Refuse Collection” —> “Next”: “2019-07-30T00:00:00”
“ServiceName”: “Domestic Food and Garden Waste Collection” —> “Next”: “2019-07-23T00:00:00”
{
"jsonrpc": "2.0",
"id": "1321456987934464654",
"result": {
"success": true,
"status": "Success",
"errors": [],
"services": [
{
"Description": "5 HORSE GUARDS WAY, THATCHAM, RG19 4PE",
"EventTypes": null,
"ServiceHeaders": {
"ServiceHeader": {
"ScheduleDescription": null,
"State": null,
"TaskType": null
}
},
"ServiceName": "Bulky Collection"
},
{
"Description": "5 HORSE GUARDS WAY, THATCHAM, RG19 4PE",
"EventTypes": null,
"ServiceHeaders": {
"ServiceHeader": {
"Last": "2019-07-16T07:00:00",
"Next": "2019-07-30T00:00:00",
"ScheduleDescription": "Tuesday every other week",
"State": "Completed",
"TaskType": "Collect Domestic Bin Refuse"
}
},
"ServiceName": "Domestic Refuse Collection"
},
{
"Description": "5 HORSE GUARDS WAY, THATCHAM, RG19 4PE",
"EventTypes": null,
"ServiceHeaders": {
"ServiceHeader": {
"Last": "2019-07-09T07:00:00",
"Next": "2019-07-23T00:00:00",
"ScheduleDescription": "Tuesday every other week",
"State": "Completed",
"TaskType": "Collect Domestic Dry Recycling"
}
},
"ServiceName": "Domestic Dry Recycling Collection"
},
{
"Description": "5 HORSE GUARDS WAY, THATCHAM, RG19 4PE",
"EventTypes": null,
"ServiceHeaders": {
"ServiceHeader": [
{
"Last": "2019-07-09T07:00:00",
"Next": "2019-07-23T00:00:00",
"ScheduleDescription": "Tuesday every other week",
"State": "Completed",
"TaskType": "Collect Domestic Food"
},
{
"Last": "2019-07-09T07:00:00",
"Next": "2019-07-23T00:00:00",
"ScheduleDescription": "Tuesday every other week",
"State": "Completed",
"TaskType": "Collect Domestic Garden"
}
]
},
"ServiceName": "Domestic Food and Garden Waste Collection"
},
{
"Description": "5 HORSE GUARDS WAY, THATCHAM, RG19 4PE",
"EventTypes": null,
"ServiceHeaders": {
"ServiceHeader": {
"ScheduleDescription": null,
"State": null,
"TaskType": null
}
},
"ServiceName": "Container Maintenance"
}
]
}
}
Any Help would be greatly appreciated.
Thanks
Simon