I’m trying to get a better display for my next trash collection event.
What I have is a helper entity defined like this:
{% set attr = state_attr('calendar.abfallnavi_regioit_de', 'start_time') %}
{% set parsed = strptime(attr, '%Y-%m-%d %H:%M:%S', now()) %}
{% set now = now().replace(tzinfo=None) %}
{% set day_until = parsed.date() - now.date() %}
{% set days_until_trash = days_until.days %}
{% set trashcan = state_attr('calendar.abfallnavi_regioit_de', 'message') %}
{% if days_until_trash == 0 %}
{{ trashcan }} today
{% elif days_until_trash == 1 %}
{{ trashcan }} tomorrow
{% else %}
{{ trashcan }} in {{days_until_trash }} days
{% endif %}
However, I don’t really want the “today” case at all because if there are collections two days in a row, it will show me the one collected today, but I want to show the one collected tomorrow (chances are the one today has already been collected so it’s not the next); something I figure would look like {{ state_attr('calendar.abfallnavi_regioit_de', 'event_list')[1].message }}
.
From browsing the forum, I gathered that I need to call the calendar service in this case, like shown here, which would get me a result list I could index. However since I’m in a helper rather than a script I don’t see how to translate the solution given there.
Is this not possible at all? If not, what other way could I use? I’d really like to have this helper entity, can I set its value from a script, and how would that look? Or is there a better way I haven’t thought of?