Custom component Afvalbeheer - Support for multiple waste collectors

I installed the afvalbeheer via HACS, but I can’t see the sensors.
I configured the /config/custom_components/afvalbeheer/sensor.py.

What I’m doing wrong?

What does your config entry look like?

Below my configuration.yaml

Configure a default setup of Home Assistant (frontend, api, etc)

default_config:

Text to speech

tts:

  • platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

sensor:

  • platform: afvalbeheer
    wastecollector: DeAfvalApp
    resources:
    • restafval
    • gft
    • pmd
      postcode: xxxxx
      streetnumber: 31
      upcomingsensor: 0
      dateformat: ‘%d-%m-%Y’
      dateonly: 0
      dateobject: 0
      dayofweek: 1
      name: ‘’
      nameprefix: 1
      builtinicons: 0

The error message:
bad indentation of a mapping entry at line 16, column 19:
wastecollector: DeAfvalApp

Yes indentation is important in YAML.
This should work:

sensor:

- platform: afvalbeheer
  wastecollector: DeAfvalApp
  resources:
    - restafval
    - gft
    - pmd
  postcode: 6105CN
  streetnumber: 31
  upcomingsensor: 0
  dateformat: ‘%d-%m-%Y’
  dateonly: 0
  dateobject: 0
  dayofweek: 1
  name: ‘’
  nameprefix: 1
  builtinicons: 0

Anybody sending messages 24h before waste collection? What if I’m not looking at my lovelace? I would like to send messages to known mobile devices. How can I do this?

Well… should this do the trick? When status changes from day’s untill 2 to 1, @± 19:00h, send message. Is the logic correct? Will this send just one?

  alias: GFT test notification
  description: ''
  trigger:
  - platform: state
    entity_id: sensor.recycleapp_gft
    attribute: Days_until
    from: '2'
    to: '1'
    for:
      hours: 19
      minutes: 0
      seconds: 0
  condition: []
  action:
  - service: notify.whatsapp_stephane
    data:
      message: Morgen is het GFT!
  mode: single

I have an automation like this:

alias: 'Notify: Vuilnisbak'
description: ''
trigger:
  - at: '21:00'
    platform: time
condition:
  - condition: state
    entity_id: group.trackers
    state: home
  - condition: time
    weekday:
      - mon
    after: '20:00'
action:
  - data_template:
      entity_id: >-
        media_player.google_home_woonkamer, media_player.google_home_keuken,
        media_player.google_home_kantoor, media_player.google_home_slaapkamer
      language: nl
      message: >-
        hey, Staat de vuilnisbak al voor? Morgen is het {{states.sensor.circulus_morgen.state}}.
    service: tts.google_say
mode: single

This is the Yaml from the UI editor. It is modulair with the use of the morgen.state sensor.
It is an old automation, so maybe you can now also trigger when morgen.state is not none at 19h.
For me this still works, so I’m not going to bother rebuilding it :stuck_out_tongue:

I think the issue is that, when you restart HA during the 19 hours, it will not trigger.

Best therefore to use a time trigger with conditions, I combined both gft and restafval in one automation. 3 triggers, 2 times where either sensor switches from 2 to 1, this notifies at 7 in the morning (same issue as you have, if it reboots it’ll fail), third trigger is daily at 9 pm where a couple of conditions are checked - hope this is helpful.

You could improve this further by also triggering at ha restart and working from there - if certain conditions are met (EG. Days until = 1 and time before 7 pm in you case).

Alias: Garbage collection notification
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.meerlanden_gft
    attribute: Days_until
    below: '1'
    for:
      hours: 7
      minutes: 0
      seconds: 0
    id: '1'
  - platform: numeric_state
    entity_id: sensor.meerlanden_restafval
    attribute: Days_until
    below: '1'
    for:
      hours: 7
      minutes: 0
      seconds: 0
    id: '2'
  - platform: time
    at: '20:30'
    id: '3'
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: '1'
        sequence:
          - service: notify.signal
            data:
              message: Vandaag wordt de groene bak geleegd!
          - service: notify.mobile_app_pixel_4a
            data:
              message: Vandaag wordt de groene bak geleegd!
      - conditions:
          - condition: trigger
            id: '2'
        sequence:
          - service: notify.signal
            data:
              message: Vandaag wordt de grijze bak geleegd!
          - service: notify.mobile_app_pixel_4a
            data:
              message: Vandaag wordt de grijze bak geleegd!
      - conditions:
          - condition: trigger
            id: '3'
        sequence:
          - choose:
              - conditions:
                  - condition: numeric_state
                    entity_id: sensor.meerlanden_gft
                    attribute: Days_until
                    below: '2'
                    above: '0.75'
                sequence:
                  - service: notify.signal
                    data:
                      message: Morgen wordt de groene bak geleegd!
                  - service: notify.mobile_app_pixel_4a
                    data:
                      message: Morgen wordt de groene bak geleegd!
              - conditions:
                  - condition: numeric_state
                    entity_id: sensor.meerlanden_restafval
                    attribute: Days_until
                    below: '2'
                    above: '0.75'
                sequence:
                  - service: notify.signal
                    data:
                      message: Morgen wordt de grijze bak geleegd!
                  - service: notify.mobile_app_pixel_4a
                    data:
                      message: Morgen wordt de grijze bak geleegd!
            default: []
    default: []
mode: single

Someone gave me his Node-red config regarding this. And that works fine! Now I get message on my mobile and I’ve added a TTS so the google assistant wil also tell me @ 19h what trash I have to put outside! Tested and works like a charm!

It’s more useful if you include the actual code and not just a print screen :wink:

And it’s more stupid if you don’t even know how to get that code … ← me :stuck_out_tongue:
Aaah think I have found it :stuck_out_tongue: (not that stupid anymore)

1 Like
[{"id":"dab0eec59d8a9168","type":"inject","z":"332392b9c5f4c00c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 19 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":20,"wires":[["94d43dce3a80154e"]]},{"id":"94d43dce3a80154e","type":"api-current-state","z":"332392b9c5f4c00c","name":"Welke vuil ophaling?","server":"9de3e011.9ae44","version":3,"outputs":2,"halt_if":"Geen","halt_if_type":"str","halt_if_compare":"is_not","entity_id":"sensor.recycleapp_morgen","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":320,"y":20,"wires":[["45739be9e85b0453"],[]]},{"id":"45739be9e85b0453","type":"function","z":"332392b9c5f4c00c","name":"","func":"msg.payload = { data: {} }\n\nmsg.payload.data.message = \"Morgen is er afvalophaling van: \" + msg.data.state\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":20,"wires":[["cbe76a7a0c80a02f","5b5941abd4b7855d","2302d83e8c3dcd59"]]},{"id":"cbe76a7a0c80a02f","type":"api-call-service","z":"332392b9c5f4c00c","name":"GSM Stephane","server":"9de3e011.9ae44","version":3,"debugenabled":false,"service_domain":"notify","service":"mobile_app_sm_g950f","entityId":"","data":"","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":880,"y":20,"wires":[[]]},{"id":"9de3e011.9ae44","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]
1 Like

Hi, in the sensor is an days_until attribute is it possible to show that in the frontend? Instead the date.

Hi Peppyn,

Almere doesn’t seem to work at all. I try to add the sensor by adding it to the config file. But the sensor does not come up.

Also no log files about the sensor. What am I doing wrong?

**Edit** Fun fact... it magically started working after posting. I tried to make it work for 2 days and all it took was one post :)

Hello @Kartale1903,

You should not declare the sensor config twice. Please remove line 61

The API fetch does take some time, a couple of minutes. So after a restart wait a bit for the sensors to populate with the correct info.

Hi Pippyn,

Just configured the sensors and works like a charm.
Just wanted to say thank you so much for the work and time you put into building and then continuing to support this! :smiley:

1 Like

Hi @Pippyn

Would it be possible to use friendly names in the today and tomorrow sensor? I use tts and want to rename pmd to Plastic, Metalen en Drankkartons.
Or add friendly names to the current type of waste? gft: Groente Fruit en Tuinafval.

When multiple collections on the same day, would it be possible to replace the ‘,’ with ‘en’? The sensor value will be: Plastic Metalen en Drankkartons en Restafval

yes this would be possible. But… this will be complicated. Both issues I’ll keep in mind for next updates. Would you be able to request these improvements on my github please? in separated tickets as they’re not related

1 Like

Yes I will do. Thanks for the support. :+1:t2:

Update: done.

1 Like

Yesterday I released version 5 of this custom component.

It will add support for the calendar entity. It is backwards compatible, but if you want to make use of the calendar you’ll have to change your config. The steps to do this are:

  • Update the custom component
  • Restart HA
  • Remove the config of this component in the sensor platform
  • Add this component as a platform in configuration.yaml (example config)
  • Restart HA
2 Likes