Multiple calander events to trigger sensors on waste_collection_schedule

Hi all,

I have the waste_collection_schedule installed on my home assistent instance.
and it loads all the garbage collection date’s in my calander, Now i’m trying to create a count down of each container (I got 4)
If i look in the development tool it tells me all the entry’s are called callender.waste_collection_***
In the message it tells me which container is being emptied

message: Groente-, fruit, tuinafval en etensresten
all_day: true
start_time: 2023-06-19 00:00:00
end_time: 2023-06-20 00:00:00
location: 
description:
message: Plastic, blik en drinkpakken
all_day: true
start_time: 2023-06-19 00:00:00
end_time: 2023-06-20 00:00:00
location: 
description:
message: Restafval
all_day: true
start_time: 2023-06-19 00:00:00
end_time: 2023-06-20 00:00:00
location: 
description:
message: Papier en karton
all_day: true
start_time: 2023-06-19 00:00:00
end_time: 2023-06-20 00:00:00
location: 
description:

I found some code witch i’m trying to use:

sensor:
  - platform: time_date
    display_options:
      - 'date'
      
template:
- sensor:
  - name: Restafval
    state: >
      {% set t = now() %}
      {% set midnight = today_at() %}
      {% set event = state_attr('calendar.waste_collection_schedule', 'start_time') | as_datetime | as_local %}
      {% set delta = event - midnight %}
      {% set values = {0: 'Today', 1:'Tomorrow', 2:'Day After Tomorrow'} %}
      {{ values.get(delta.days, 'In %s Days'%delta.days) }}

But i cant get it to work to filter on message names,

any one got some idee’s?

Yep, here is an idea. :slight_smile: Use the sensors provided by the custom_component. :wink:

You can define the values in the sensors from waste_collection_schedule:

sensor:
  - platform: waste_collection_schedule
    name: waste_collection_waste
    details_format: upcoming
    add_days_to: true
    value_template: >-
      {% if value.daysTo == 0 %}
      HEUTE
      {% elif value.daysTo == 1 %}
      MORGEN
      {% else %}
      in {{value.daysTo}} Tagen
      {% endif %} 
    types:
      - Restmuelltonne

And to get the data for that sensor, you need to configure it via the integration:

waste_collection_schedule:
  sources:
    - name: ics
      args:
        url: "https://xmlcall.xxxx
        offset: 0
  fetch_time: "04:23"
  day_switch_time: "09:30"

That gives you nearly endless possibilities to change the value template of the sensor.

Short note at the end: please use for such questions the thread of the custom_component. It is just easier for all of us to keep track of questions and problems. In that thread, the developer is watching, and therefor can help much easier. Not every developer has the time to scroll through the forums and watch for questions regarding his component. Thank you very much! :slight_smile:

Thanks Paddy,

I will try to post in the correct thread!

I’m going to try and use you example

1 Like