I have an API adress with JSON data, and i want to get data from it.
The JSON file contain garbarge pick up days, but i only want the next 2 pickup for each fraction.
the file contain all pickup days for the whole year.
I need help to pick out name, date for all fractions for the next 2 pickups for each fractions.
Can sombody help me with this?
sensor:
- platform: rest
name: garbage
resource: https://TO API
method: GET
scan_interval: 60
value_template: 'OK'
json_attributes:
- name
- date
- fractionId
The API file looks like this: (a little bit of the file, but all the variations)
[
{
"name": "Restavfall",
"date": "2025-12-23",
"fractionId": 9999,
"fractionGuid": "b4bbf08d-30f0-4024-9f53-e42229ec48a6",
"route": 50405,
"routeName": "0504",
"frequency": 2,
"startDay": 2
},
{
"name": "Restavfall",
"date": "2025-03-18",
"fractionId": 9999,
"fractionGuid": "b4bbf08d-30f0-4024-9f53-e42229ec48a6",
"route": 50405,
"routeName": "0504",
"frequency": 2,
"startDay": 2
},
{
"name": "Restavfall",
"date": "2025-04-01",
"fractionId": 9999,
"fractionGuid": "b4bbf08d-30f0-4024-9f53-e42229ec48a6",
"route": 50405,
"routeName": "0504",
"frequency": 2,
"startDay": 2
},
{
"name": "Matavfall",
"date": "2025-03-04",
"fractionId": 2110,
"fractionGuid": "ccdd09f5-3510-43bb-9bb4-2b192230d354",
"route": 50405,
"routeName": "0504",
"frequency": 2,
"startDay": 2
},
{
"name": "Matavfall",
"date": "2025-05-13",
"fractionId": 2110,
"fractionGuid": "ccdd09f5-3510-43bb-9bb4-2b192230d354",
"route": 50405,
"routeName": "0504",
"frequency": 2,
"startDay": 2
},
{
"name": "Matavfall",
"date": "2025-11-11",
"fractionId": 2110,
"fractionGuid": "ccdd09f5-3510-43bb-9bb4-2b192230d354",
"route": 50405,
"routeName": "0504",
"frequency": 2,
"startDay": 2
},
{
"name": "Papir, papp og kartong",
"date": "2025-12-23",
"fractionId": 2400,
"fractionGuid": "8998844f-406e-458c-b8da-8e8249f5c321",
"route": 110403,
"routeName": "1104",
"frequency": 4,
"startDay": 2
},
{
"name": "Glass- og metallemballasje",
"date": "2025-03-04",
"fractionId": 2612,
"fractionGuid": "2627574c-db98-4d6b-94fd-dfb47a64007d",
"route": 162408,
"routeName": "1624",
"frequency": 8,
"startDay": 2
},
{
"name": "Plastemballasje",
"date": "2025-11-25",
"fractionId": 3200,
"fractionGuid": "03fc89dd-accb-4b4f-a6b0-667438975720",
"route": 110403,
"routeName": "1104",
"frequency": 4,
"startDay": 2
},
]