Custom component Afvalbeheer - Support for multiple waste collectors

Paul, is the recycle app connection working again.

How do you get the next pickup item sensor

To enable the today and tomorrow sensors set the upcomingsensor to 1 in your config (docs)

I already have but not showing the next pickup item. In the Image from Ralfkroon you see a sensor Next pickup Item.

Sorry @rswennen, missed your message. But I can confirm the RecycleApp connection has started working again shortly after noting the problem, and has not failed anymore since …

I have created the nextpickitem and nextpickdays myself

Here is the code for the sensors

     nextpickdays:
       value_template: >-
         {% set sensors = [ 
           state_attr('sensor.circulus_berkel_papier', 'Days-until') | int,
           state_attr('sensor.circulus_berkel_gft', 'Days-until') | int,
           state_attr('sensor.circulus_berkel_pmd', 'Days-until') | int,
           state_attr('sensor.circulus_berkel_restafval', 'Days-until') | int,
              ]
            %}
            {{ sensors|min }}
     nextpickitem:
       value_template: >-
         {% if state_attr('sensor.circulus_berkel_papier', 'Days-until') | int == states('sensor.nextpickdays') | int %} Papier
         {% elif state_attr('sensor.circulus_berkel_gft', 'Days-until') | int == states('sensor.nextpickdays') | int %} GFT
         {% elif state_attr('sensor.circulus_berkel_pmd', 'Days-until') | int == states('sensor.nextpickdays') | int %} PMD
         {% elif state_attr('sensor.circulus_berkel_restafval', 'Days-until') | int == states('sensor.nextpickdays') | int %} Restafval
         {% endif %}
    

One sensor is telling you how many days till next pickup and this sensor is needed to tell you the next pickup Item.

----Edit–

Fix the nextpickupitem

what if you have 2 pick-ups on the same day, the sensor will show one in this case?

yes only one. It is really rare to get 2 pickups a day

every 2 weeks here 2 pick-ups
restafval + papier
restafval + pmd
restafval + plastic

2 Likes

i have just the same every 2 weeks gft and pmd?

Hey @Pippyn,

Thank you so much for the great work. I tried to set up all. But got the following message:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 278, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 471, in async_device_update
    await self.hass.async_add_executor_job(self.update)  # type: ignore
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/afvalbeheer/sensor.py", line 1367, in update
    collection = self.data.collections.get_first_upcoming_by_type(self.waste_type)
  File "/config/custom_components/afvalbeheer/sensor.py", line 443, in collections
    return self.collector.collections
AttributeError: 'NoneType' object has no attribute 'collections'

My sensor Yaml:

- platform: afvalbeheer
  wastecollector: Twente Milieu
  resources:
    - restafval
    - gft
    - papier
    - pmd
  postcode: 0000XX
  streetnumber: 00               
  upcomingsensor: 0
  dateformat: '%d-%m-%Y'
  dateonly: 0
  dateobject: 0
  name: ''
  nameprefix: 1
  builtinicons: 0
  disableicons: 0
  dutch: 0

Can you help me figure out what is wrong?

Can you DM me an address that is in your neighbourhood? So I can do some tests?

1 Like

Same here. I have GFT & Papier en Karton the same day, only GFT in the sensor :frowning:

I have the same situation here but the below config results in 5 sensors with the 5 states
sensor.recycleapp_vandaag > geen
sensor.recycleapp_morgen > restafval, pmd
sensor.recycleapp_papier > 23-11-2020
sensor.recycleapp_pmd > Morgen, 16-11-2020
sensor.recycleapp_restafval > Morgen, 16-11-2020

  - platform: afvalbeheer
    wastecollector: RecycleApp
    resources:
      - restafval
      - papier
      - pmd
    postcode: 1234
    streetname: xxxxx
    streetnumber: xx
    upcomingsensor: 1
    dateformat: '%d-%m-%Y'
    dateonly: 0
    dateobject: 0
    dayofweek: 1
    alwaysshowday: 0
    name: ''
    nameprefix: 1
    builtinicons: 1
    disableicons: 0
    dutch: 1
#    printwastetypes: 1

According to me this is how I should expect it.

Another thing I saw is that in the recycle app I only have 1 collection on the “home” screen, but when I go to the calendar, I have the 2 collections that appear… Could be linked perhaps?

I have sent a message through the reycle app to the developers

I think my email worked :slight_smile:

Seems they fixed the bug in the recycleapp API

image

How do you add Nog 0 dag(en) to the card?

This looks nice
Tnx

card:
  show_header_toggle: false
  type: entities
filter:
  include:
    - attributes:
        Days-until: < 3
      entity_id: sensor.recycle*
      options:
        secondary_info: 'Nog [[ {entity}.attributes.Days-until ]] dag(en)'
        type: 'custom:secondaryinfo-entity-row'
show_empty: false
sort:
  method: state
  numeric: true
type: 'custom:auto-entities'

which gives then this:
image

Sorts the most upcoming event, and only the ones due in 3 days (but this you can change of course :slight_smile:)

3 Likes

Hi,

I just installed the code on my HA (Docker image) and get these errors in the log of HA

Logger: homeassistant
Source: custom_components/afvalbeheer/sensor.py:927
First occurred: 9:14:44 PM (1 occurrences)
Last logged: 9:14:44 PM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/afvalbeheer/sensor.py", line 437, in async_update
    await self.collector.update()
  File "/config/custom_components/afvalbeheer/sensor.py", line 949, in update
    await self.hass.async_add_executor_job(self.__fetch_address)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/afvalbeheer/sensor.py", line 927, in __fetch_address
    response = requests.get(
  File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 900, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/simplejson/__init__.py", line 525, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.8/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/local/lib/python3.8/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Is there anyone who knows what i’m doing wrong?

Please make a new issue at my github, with these errors, your config and an address in your neighbourhood.

1 Like