Hi everybody,
I am trying to send a notification the evening before different garbage bins will be picked up at our house. Can you please help me achieve this?
What I did so far
- install ics_calender via HACS
- add my garbage collection
.ics
calendar toics_calendar
- create the calendar entities by
calendar:
- platform: ics
calendars:
- name: "AWSH"
url: "https://www.awsh.de/api_v2/collection_dates/1/ort/83/strasse/590/hausnummern/0/abfallarten/R02-B02-D02-P04/kalender.ics"
includeAllDay: true
That will create these entities:
Those are sensor.abholtermine_event_<n>
, where n
is 0 - 4
; so I got five upcoming events. Unfortunately (for me), these events all start at 00:00:00
, which means that the eta
state attribute will also always change at midnight. So triggering it then will do me no good!
Problem
I thought I could use platform: time
in my automation (below) to “fix” this; however, while I can do this in theory, it will not allow me to use trigger.to_state.name
(or anything related to trigger.
), so I cannot notify us which bin is being collected.
Those are different garbage bins in one file, so in this case, sensor.abholtermine_event_0
is for regular trash, sensor.abholtermine_event_2
is for compost / garden trash, and so on. However, once on of those events has passed, sensor.abholtermine_event_2
might be for something other than compost, so I cannot use the _<n>
as an indicator which event is for which kind of garbage collection.
Automation
automation:
- alias: "[Notify] AWSH Abholtermine"
trigger:
- platform: time
at: "17:00:00"
condition:
condition: template
value_template: >
{% set awsh = ['sensor.abholtermine_event_0', 'sensor.abholtermine_event_1', 'sensor.abholtermine_event_2', 'sensor.abholtermine_event_3', 'sensor.abholtermine_event_4'] %}
{% for each in awsh %}
{{ state_attr(each, 'eta') < 3 }}
{% endfor %}
action:
- service: notify.me
data_template:
message: >
Trash Pickup (this is where I'd need to use trigger.to_state.name or similar)
Potential solutions (all of which I don’t 100% agree with)
Idea 1
- create
template_sensor
s for each of those events - when either of their
eta
values change to< 3
, trigger the automation
=> that would allow me to usetrigger.to_state.name
- action would first start a delay for x hours (for example,
17:00:00
if I want the notification at 5pm the next day), then trigger the notification
Downside: if I have to restart Home Assistant in the meantime, I will not be notified as the delay
from the automation would not “survive” this restart.
idea 2
pretty much the same as above, but use a timer
instead of the delay; I am not sure whether or not a timer will “survive” the restart. Also, I don’t know if it is even possible to pass on the trigger.to_state.name
to the timer, or rather to that automation that will notify me once the timer runs out.
idea 3
Just after typing all this, I realized that I could manually download the .ics
file, then splitting it into one file per type of garbage pickup; then I could push those separate files to my local webserver and have Home Assistant subscribe to one file per type of pickup. While this would allow me to always know which entity would trigger which type (so that I could include the type in the Telegram notification), it seems a hassle!
I am currently doing something similar already, where I download the file, change the notification time, then push it to my Nextcloud calendar and notify us via the calendar app. It is automated (curl
the calendar file, awk
the reminder time, scp
it to the local webserver), but it is a bit hacky and if I have to resort to something equally hacky to use Home Assistant instead of the calendar app, I might as well just stick with the current solution.
Final question
Is there something essential that I have missed and that would allow me to do what I need to without so much hassle on the side?
Thank you for your ideas