Garbage Collection Card in Home Assistant

āđāļŠāļĢāđŒ
āļāļąāļ‡
  • āđ€āļœāļĒāđāļžāļĢāđˆāđ€āļĄāļ·āđˆāļ­ 9 āļ.āļž. 2025
  • In this video I'll show you how to create a Garbage Collection Card in Home Assistant. A few have been asking about this so I thought it was time to show how I do it. My main problem with this is that I have four sensors for different garbage types, so I had to find a way to only display the one that are being picked up next.
    Get the full code on Gumroad:
    mysmarthome.gu...
    Support the channel:
    / @my_smart_home
    www.buymeacoff...
    Feel free to comment, ask questions, and share your own experiences. Let's learn and grow together!
    Links:
    Waste Collection Schedule: github.com/mam...
    ðŸ•đïļSome of the Tech I use:
    Intel NUC for Home Assistant: amzn.to/4j2XPbH
    Sonoff Motion Sensors: amzn.to/3DLmfpY
    MOES scene switch: amzn.to/3BNE1Zf
    Hue LED bulbs: amzn.to/3BXdpVD
    Indoor AIR quality sensors: amzn.to/40n7lzb
    Sonos ERA 100 speakers: amzn.to/404Ba63
    Reolink Doorbell Camera: amzn.to/408VnrH
    Google Coral: amzn.to/3Wb4feX
    LED strips: amzn.to/4j7cpz6
    #HomeAssistant #SmartHome #LovelaceUI #Dashboard #Tutorial
    I use Elevenlabs to generate my voice over recordings. I do this because I don't have the equipment to record my own voice over. It also lets me be very flexible when creating and writing my videos.
    â„đïļ AFFILIATE LINKS
    If you make a purchase using the links I provide, I may earn a small commission at no additional cost to you.

āļ„āļ§āļēāļĄāļ„āļīāļ”āđ€āļŦāđ‡āļ™ • 26

  • @perchycs
    @perchycs 4 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™ +1

    Your tutorials are always so easy to follow, even if they cover quite complex topics. Thanks to you I've made an amazing custom button card dashboard from previously having a very rudimentary knowledge of jinja and button card in general.

    • @My_Smart_Home
      @My_Smart_Home  4 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

      Great to hear! Thanks for watching!

  • @effocs
    @effocs 4 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™ +1

    Super nice work as always dude tack sÃĨ mycket

    • @My_Smart_Home
      @My_Smart_Home  4 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™ +1

      Takk mann! Hopefully not too many will fall off during that templating section 😅

  • @StefanNaerebout
    @StefanNaerebout 21 āļ§āļąāļ™āļ—āļĩāđˆāļœāđˆāļēāļ™āļĄāļē

    I got the map working, even with an image instead of text, but what I still want to get to work is that tap-action, can you tell me or show me how to get that done?

  • @MSPcraps
    @MSPcraps 12 āļ§āļąāļ™āļ—āļĩāđˆāļœāđˆāļēāļ™āļĄāļē

    Thanks so much for the great content. I've noticed there's a lot of focus on trash collection in HA. Where I live they pick up the same day every week. It's not hard to remember. Is this super complicated in other places or am I missing something?

    • @My_Smart_Home
      @My_Smart_Home  12 āļ§āļąāļ™āļ—āļĩāđˆāļœāđˆāļēāļ™āļĄāļē +1

      Its mostly the same day, but not always. And we have four different bins. Every week they pick up general, but some weeks its plastic and paper as well. Another week its metal and glass. So I need to remember to bring out the correct bin the night before.

  • @piwozniak
    @piwozniak 2 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

    Hi.
    If you could make it to pull data from google calendar that would be amazing. I'm sure i'm not the only one living in a black-hole for which garbage pickup dates aren't available on any of the providers mentioned in Waste Collection Services

    • @Duane_A
      @Duane_A 18 āļ§āļąāļ™āļ—āļĩāđˆāļœāđˆāļēāļ™āļĄāļē

      How to do this is mentioned in the documentation for Waste Collection Services. Among the documention for different provides, look for the section on ICS.

  • @nkolasmaer
    @nkolasmaer 4 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™ +1

    Thank you for sharing your awesome ideas and great tutorials! Unfortunately the template doesn't work for me, the state of sensor.next_collection is always "unavailable". The reason are probably my waste collection sensors. Their state is the correct number of days until the next pickup, yet I think the state attribute isn't correctly assigned. Can you tell me how I can assign them the correct attribute (days_to_pickup)?

    • @SimplifyingChaos
      @SimplifyingChaos 4 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™ +4

      So I have just had the same issue. From the "Waste Collection Schedule", select CONFIGURE and tick "Add New sensor" If you don't have any to modify then click Submit. Create a new sensor for the bin collection you want to monitor, for example: "recycling" Then I chose Generic and ticked "Add Days To" and under "Types" you should enter "RECYCLING" this means it will group all the recycling jobs under this sensor with an Attribute called "daysTo". I know this isn't exactly "days_to_pickup" but this is how I got it to work. You'll need to watch out for the change in the template code, but there is only one reference to swap out.

    • @Backtothecloud
      @Backtothecloud 4 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

      @@SimplifyingChaos where can i find Waste Collection Schedule

  • @itzsnyder7271
    @itzsnyder7271 4 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

    I really enjoyed the video! However, it would be great if the next pickup dates for the different types of waste could be displayed on the far right. Do you have any idea how to do that? I already tried to add a third column but failed.

    • @My_Smart_Home
      @My_Smart_Home  4 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

      Thats a good idea, I'll look into it. Might have to do a similar template so it would be nice if we could somehow do it without so much code.

    • @itzsnyder7271
      @itzsnyder7271 4 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

      @@My_Smart_Home Something like this works for me. but I'm not a designer:
      type: conditional
      conditions:
      - condition: numeric_state
      entity: sensor.wastepickupdays
      below: 10
      card:
      type: custom:button-card
      entity: sensor.wastepickupdays
      show_icon: false
      name: |
      [[[
      if (entity.state == 0) {
      return '';
      } else {
      return states['sensor.wastepickupdays'].state;
      }
      ]]]
      label: |
      [[[
      if (entity.state == 0) {
      return 'Heute wirdabgeholt:';
      } else if (entity.state == 1) {
      return 'Tag bis zurAbholung';
      } else {
      return 'Tage bis zurAbholung';
      }
      ]]]
      show_label: true
      custom_fields:
      type: |
      [[[
      return states['sensor.wastepickuptype'].state;
      ]]]
      next: |
      [[[
      let sensors = [
      'sensor.wastepickup_bio',
      'sensor.wastepickup_restabfall',
      'sensor.wastepickup_plastik',
      'sensor.wastepickup_gartenabfall',
      'sensor.wastepickup_papier'
      ];
      // Funktion, um die Zahl (Tage) aus dem State zu extrahieren
      function extractDays(state) {
      let match = state.match(/: (\d+) Tagen/); // Sucht nach "in X Tagen"
      return match ? parseInt(match[1]) : 0; // Falls keine Zahl gefunden wird, 0 zurÞckgeben
      }
      // Array der Sensoren mit ihren States und extrahierten Tagen
      let sensorStates = sensors.map(sensor => {
      let state = states[sensor].state;
      return { sensor, state, days: extractDays(state) };
      });
      // Sortierung nach den Tagen
      sensorStates.sort((a, b) => a.days - b.days);
      // Den ersten (obersten) Eintrag entfernen
      sensorStates.shift();
      // Die restlichen sortierten States in output speichern
      let output = '';
      sensorStates.forEach(sensorData => {
      output += sensorData.state + '';
      });
      return output; // Alle restlichen sortierten States zusammen zurÞckgeben
      ]]]
      tap_action:
      action: navigate
      navigation_path: '#trash'
      styles:
      grid:
      - grid-template-areas: '"n l next" "n type next";'
      - grid-template-columns: 30% 1fr 1fr;
      - grid-template-rows: 30% 1fr;
      name:
      - font-size: 70px
      - font-weight: 800
      - justify-self: center
      - align-self: center
      - color: var(--contast20)
      card:
      - margin-top: 10px
      - margin-bottom: 10px
      label:
      - justify-self: start
      - font-size: 22px
      - font-weight: 500
      - color: var(--contast20)
      - text-align: left
      custom_fields:
      type:
      - justify-self: start
      - font-size: 18px
      - font-weight: 500
      - padding-top: 30px
      - color: var(--contast20)
      next:
      - justify-self: end
      - font-size: 12px
      - font-weight: 500
      - text-align: right;
      - color: var(--contast20)
      - padding: 26px 26px 0px 0px

  • @franks8415
    @franks8415 3 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

    Great tutorial! I however ran into an issue; the sensor is working but I can't get the custom card going it says: "Custom element doesn't exist: button-card." found out that I had to install the HACS lovelace button card first.

    • @My_Smart_Home
      @My_Smart_Home  3 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

      You need to install the custom button card from HACS. I see now that I forgot to add the link in the description
      github.com/custom-cards/button-card

  • @FilippSlipchenko
    @FilippSlipchenko āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

    In my case sensor has been created but... days are not available.. sure it's not defined...
    So here is the question how to setup the date? In my case it's every Tuesday 7 AM

    • @My_Smart_Home
      @My_Smart_Home  āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

      So its a fixed time every week? Do you really need a reminder?
      This will count days until tuesday, edit first line if its not correct for you.
      {% set target_day = 1 %} {# Tuesday is 1 #}
      {% set current_day = now().weekday() %}
      {% if current_day == target_day %}
      0
      {% else %}
      {{ ((target_day - current_day) + 7) % 7 }}
      {% endif %}
      AI is great for this kind of stuff.

  • @TAKER4437
    @TAKER4437 4 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

    For me write unavaible sensorðŸ˜Ē

    • @My_Smart_Home
      @My_Smart_Home  4 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

      Did you edit the sensors at the start of the template to match your own?

    • @deralte680
      @deralte680 3 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

      @@My_Smart_Home for me its the same. I think, it's due to the state format of the sensor. Mine are set up like this:
      - platform: waste_collection_schedule
      name: AbfallPapier
      details_format: "upcoming"
      count: 4
      value_template: 'in {{value.daysTo}} Tag(en)'
      date_template: '{{value.date.strftime("%d.%m.%Y")}}'
      types:
      - papier
      the states look like this: 'in 17 Tag(en)'

    • @TheEliteGamesDe
      @TheEliteGamesDe 25 āļ§āļąāļ™āļ—āļĩāđˆāļœāđˆāļēāļ™āļĄāļē

      ​@@deralte680 I had the same issue as you.
      There are 2 ways to get the same goal. A fast way without filtering the types and a more complex way like in the video:
      Without filtering the garbage types you can just adjust the value_template and remove the types attribute. Then you just get the garbage type which gets collected next time.
      - platform: waste_collection_schedule
      name: NextCollection
      value_template: {{value.daysTo}}{value.types|join(", ")}}'
      To be able to filter to only garbage types you wan to have I have created a sensor for each garbage type with the same value_template then for the nextCollection sensor.
      Later I have updated the code for the own next garbage collection sensor like:
      {% set garbage_types = {
      states.sensor.your_restmull_sensor.state.split(',')[0]: "RestmÞll",
      states.sensor.your_papier_sensor.state.split(',')[0]: "PapiermÞll",
      states.sensor..your_bio_sensor.state.split(',')[0]: "BiomÞll",
      states.sensor..your_gelbe_sensor.state.split(',')[0]: "Gelbe Tonne"
      } %}
      {% set pickup_days = namespace(min=999, types=[])%}
      {% for garbage_type in garbage_types.items() %}
      {% set days = garbage_type[0] | int %}
      {% if days < pickup_days.min %}
      {% set pickup_days.min = days %}
      {% set pickup_days.types = [garbage_type[1]] %}
      {% elif days == pickup_days.min %}
      {% set pickup_days.types = pickup_days.types + [garbage_type] %}
      {% endif %}
      {% endfor%}
      {% set types_string = pickup_days.types | join('and') if pickup_days.types | length > 1 else pickup_days.types[0] %}
      {{ pickup_days.min }},{{ types_string }}
      That worked for me as a workaround. Not the smoothest way I know, but it fixes the issue I had with the original state format of the sensors.

  • @HangingBack
    @HangingBack 2 āļŦāļĨāļēāļĒāđ€āļ”āļ·āļ­āļ™āļāđˆāļ­āļ™

    nice tutorial! tip: you dont have to restart HA to initiate a new template-sensor, there is a option to only reload template-entities (In norwegian its "Malentiteter")