Hello good folks!
After messing around with this for more then two days I’ve decided to ask the experts.
I’m retrieving a datetime object from a JSON Url. The return is quite simple and standard:
2023-09-26T00:00:00Z
It’s the date when the garbage is collected and us being all ADHD want to get notified. Anyway, I’ve added the following Rest sensor to the configuration.yaml:
rest:
- resource: https://www.rova.nl/api/waste-calendar/upcoming?postalcode=<My postal code>&houseNumber=<my housenumber>&addition=
scan_interval: 600
sensor:
- name: "Ophaaldatum"
#state: '{{ as_timestamp(value_json[0].date) | timestamp_custom("%A %-d %B") }}'
#device_class: timestamp
unique_id: rovasensorophaaldatum
value_template: '{{ ((value_json[0].date)|as_datetime).strftime("%A %-d %B") }}'
- name: "Afvaltype"
unique_id: rovasensorafvaltype
value_template: '{{ value_json[0].garbageType }}'
But whatever I do, I cannot get the returned date to be an actual date to use in the Trigger using a “Time” based trigger (e.g. One day in advanced send a message or whatever).
How do I turn this returned JSON object in a usuable time/date object? Thanks!