I’m trying to receive date via API from my garbage company and would like to have it presented in a sensor in homeassistant, like next date for the garbage truck to arrive.
I have managed to get some information with this setup:
And when i run the HTTP POST command in postman or do a curl i get this JSON output:
Is there some way to create a REST sensor in home assistant that hold the upcoming date from current day?
Great it seems to work!
I receive 2022-05-30 and that’s correct date for next pickup.
Now i just wan’t to understand how it works
Where can i find documentation about this?
It’s Jinja2.
You can find a link in the developer tools:
It loops the array (json_value).
It takes the datetime and makes it UNIX time to compare it with now, and makes sure it’s the first item that is in the future.
If it is, then it takes the first ten characters of the item.date.
Sets found to “found”. Could be anything really, it’s just to make sure the if statement becomes false (ns.found == ‘’).