Waste Collection Schedule Framework

Gefunden? :slight_smile: Found it? :slight_smile:

Falls nicht, hier wäre die Antwort: If not, here would be the answer:

value_template:  >-
      {% if value.daysTo == 0 %}
      HEUTE
      {% elif value.daysTo == 1 %}
      MORGEN
      {% else %}
      in {{value.daysTo}} Tagen
      {% endif %}

Du musst das auch zusätzlich eintragen. You need to configure the additional text.

Thanks a lot, I have found it :wink:

Hi, I have installed this via HACS, but I can’t find it under integrations?

In the log I can see following error:
2021-09-02 11:50:41 ERROR (MainThread) [homeassistant.setup] Error during setup of component waste_collection_schedule

Traceback (most recent call last):

File “/usr/src/homeassistant/homeassistant/setup.py”, line 249, in _async_setup_component

result = await task

File “/config/custom_components/waste_collection_schedule/init.py”, line 103, in async_setup

api.add_scraper(

File “/config/custom_components/waste_collection_schedule/init.py”, line 182, in add_scraper

Scraper.create(

File “/config/custom_components/waste_collection_schedule/waste_collection_schedule/scraper.py”, line 227, in create

source = source_module.Source(**source_args) # type: ignore

TypeError: init() got an unexpected keyword argument ‘calendar_title’

Check the indentation of your configuration.

Hey folks,

i am struggeling setting up the configuration for this component:

waste_collection_schedule:
  sources:
    - name: awbkoeln_de
      args:
        street_code: !secret awb_street
        building_number: !secret awb_building
      customize:
        - type: grey
          alias: RestmĂźll
          picture: '/local/img/icon_trash_grey.png'
        - type: brown
          alias: Biomuell
          picture: "/local/img/icon_trash_green.png"
        - type: blue
          alias: Papiermuell
          picture: "/local/img/icon_trash_blue.png"
        - type: wertstoff
          alias: Gelbe Tonne
          picture: "/local/img/icon_trash_recycle.png"
      calendar_title: Abfallkalender
  day_switch_time: "13:00"

Got this error:

Invalid config for [waste_collection_schedule]: invalid url for dictionary value @ data['waste_collection_schedule']['sources'][0]['customize'][0]['picture']. Got 'local/img/icon_trash_grey.png'. (See ?, line ?).

Don’t know how to format the picture url :confused:
Any ideas?

One time, you use ‘/local/img/icon_trash_grey.png’ ( with ’ )
Another time, you use “/local/img/icon_trash_green.png” ( with " )
Maybe, thats the reason?

Have you tried without any quotes?

    customize:
        - type: grey
          alias: RestmĂźll
          picture: /local/img/icon_trash_grey.png

I’m not using pictures, so can’t say for sure. :slight_smile:

Just to check, you did create the folder /www, did you? See here:

I tried the following:

  • local//img/icon_trash_grey.png
  • ‘local//img/icon_trash_grey.png’
  • “local//img/icon_trash_grey.png”

But none of them worked out. In other sonsors of my setup this works:

homeassistant:
  customize:
    sensor.epson_ink_level_black:
      friendly_name: Schwarz
      entity_picture: /local/img/icon_ink_black.png

So i think i shoul customize the entities afterwards through the homeassistant-cusomize-part.

BUT: This works:
http://www.local.com/img/icon_trash_grey.png

So i think its not supposed to use the entity_picture-property this way!?
https://github.com/mampfes/hacs_waste_collection_schedule/blob/8c2d6dd9c09b7e471ae794aee2174a1b2f6ecac9/custom_components/waste_collection_schedule/sensor.py#L134

Currently, the location of a picture has to be a URL, e.g.:

picture: http://localhost:8123/local/img/icon_trash_grey.png

if your file location is

<config-dir>/www/img/icon_trash_grey.png

I will also facilitate local file syntax in the next version of the component.

1 Like

Alright, i just did it with the full path to the images :slight_smile:

waste_collection_schedule:
  sources:
    - name: awbkoeln_de
      args:
        street_code: !secret awb_street
        building_number: !secret awb_building
      customize:
        - type: grey
          alias: RestmĂźll
          picture: https://my.domain.lan:8123/local/img/icon_trash_grey.png
        - type: brown
          alias: BiomĂźll
          picture: https://my.domain.lan:8123/local/img/icon_trash_brown.png
        - type: blue
          alias: PapiermĂźll
          picture: https://my.domain.lan:8123/local/img/icon_trash_blue.png
        - type: wertstoff
          alias: Gelbe Tonne
          picture: https://my.domain.lan:8123/local/img/icon_trash_recycle.png
      calendar_title: Abfallkalender
  day_switch_time: "13:00"

sensor:
  - platform: waste_collection_schedule
    name: RestmĂźll
    source_index: 0
    details_format: "upcoming"
    add_days_to: true
    date_template: '{{value.date.strftime("%a, %d.%m.")}}'
    value_template: '{% if value.daysTo == 0 %}heute{% elif value.daysTo == 1 %}morgen{% else %}in {{value.daysTo}} Tagen{% endif %}'
    types:
      - RestmĂźll
  - platform: waste_collection_schedule
    name: PapiermĂźll
    source_index: 0
    details_format: "upcoming"
    add_days_to: true
    date_template: '{{value.date.strftime("%a, %d.%m.")}}'
    value_template: '{% if value.daysTo == 0 %}heute{% elif value.daysTo == 1 %}morgen{% else %}in {{value.daysTo}} Tagen{% endif %}'
    types:
      - PapiermĂźll
  - platform: waste_collection_schedule
    name: Gelbe Tonne
    source_index: 0
    details_format: "upcoming"
    add_days_to: true
    date_template: '{{value.date.strftime("%a, %d.%m.")}}'
    value_template: '{% if value.daysTo == 0 %}heute{% elif value.daysTo == 1 %}morgen{% else %}in {{value.daysTo}} Tagen{% endif %}'
    types:
      - Gelbe Tonne

trash

5 Likes

Does anyone know, if it is possible to get the original value in the sensor entity as well?

To make that clearer, what I’m looking for is value.daysTo as an attribute or something like that in the sensor that one gets after configuring.

The problem is, if I want to have “friendly days” like today or tomorrow, I don’t have the actual number of days anymore…

Maybe I misinterpret it, but what I do is using the sensor like this:

- platform: waste_collection_schedule
  name: abfall.rest
  details_format: "upcoming"
  value_template: '{{value.daysTo}}'
  date_template: '{{value.date.strftime("%d.%m.%Y")}}'
  add_days_to: True
  count: 2
  types:
    - "RestmĂźll"

and use the “friendly days” in the template for the custom:button-card:

  bc_muell:
    show_label: true
    show_name: true
    label: |
      [[[
        var days_to = entity.state
        if (days_to == 0)
        { return "Heute" }
        else if (days_to == 0)
        { return "Morgen" }
        else
        { return "in " + days_to + " Tagen" }
      ]]]
    state:
      - styles:
          card:
            - background: red
          icon:
            - color: white
        operator: template
        value: '[[[ return entity.state == 0 ]]]'
      - styles:
          card:
            - background: orange
          icon:
            - color: black
        operator: template
        value: '[[[ return entity.state == 1 ]]]'
      - styles:
          card:
            - filter: opacity(100%)
        operator: template
        value: '[[[ return entity.state > 1 ]]]'
        id: my_id
    aspect_ratio: 1.2
    styles:
      card:
        - font-size: 90%
2 Likes

Thanks for your reply, you get it absolutely right. :slight_smile: That was my “planB”, if nothing else works.

My problem with that solution is, that you have to set the “friendly_days” everywhere you want to use it, not only in one place. I for one have a few different devices, that show my waste collection dates. I’d have to set the “friendly_days” up in every different view…

My second point, but that is very specific, I’d like to use it not only for the “friendly_days”. I need to have something available, that I can use “in code”, and to filter for “HEUTE” is not very user friendly, in my use case not doable, because I additionally need a language variable…

See here for the button-card template:

  custom_fields:
    notification: >
      [[[
        if (entity.state == 'unavailable' || entity.state == 'HEUTE' || entity.state == 'MORGEN'){
          return `<ha-icon icon="mdi:exclamation" style="width: 12px; height: 12px; color: var(--primary-background-color);"></ha-icon>`
        }
      ]]]

This can’t be shared with others, as everyone could have a different name, like “Heute” vs. “HEUTE” or “Später” (yep, have seen that).

IMHO an attribute would be great, one could use the “friendly_days” in value_template, but could as well check for values.daysTo. Something like that:

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

and in button-card like this:

  custom_fields:
    notification: >
      [[[
        if (entity.state == 'unavailable' || entity.attributes.daysTo == 1 || entity.attributes.daysTo == 0){
          return `<ha-icon icon="mdi:exclamation" style="width: 12px; height: 12px; color: var(--primary-background-color);"></ha-icon>`
        }
      ]]]

But maybe I’m off here and there is a better solution and I just can’t see it. :slight_smile:

Hm, I have an attribute with the number of days in my sensor (daysTo). confused
image

1 Like

Thanks for the update, now it’s getting weird… :confused:

This is what my sensor shows, so it seems, the error must be on my side… I’ll compare your code with mine this afternoon. :slight_smile: Thanks for posting it! :slight_smile:

ha_210928_waste_collection_1

OK, found it, was me being dump! :wink: :slight_smile: Thanks @EddieFAF! Much ppreciated!

you’re welcome :slight_smile:

1 Like

You can add as many sensors as you want. So you could add one sensor which displays days_to, and another sensor which displays a today, tomorrow, …

I like to add the calender from the AWG
https://awg-wuppertal.de/privatkunden/abfallkalender.html
by the abc_com.py script or any other way :wink:
or this

At the moment I do not understand how it works …
Could somebody help me?

I downloaded the file and at it locally to my HA, that works :slight_smile: The next step is to automate the next years :slight_smile:

Hey,

i´ve problems with my sensors.

waste_collection_schedule:
  sources:
    - name: ics
      args:
        url: "https://calendar.google.com/calendar/ica....

  - platform: waste_collection_schedule
    name: Biomuell_date
    value_template: '{{value.date.strftime("%d.%m.%Y")}}'
    types:
      - 'Vl-BM-2w: Vlotho'
      - 'Vl-BMS-2w: Vlotho'
  - platform: waste_collection_schedule
    name: Biomuell_collection
    value_template: '{{value.daysTo}}'
    types:
      - 'Vl-BM-2w: Vlotho'
      - 'Vl-BMS-2w: Vlotho'
      

  - platform: waste_collection_schedule
    name: Restmuell_date
    value_template: '{{value.date.strftime("%d.%m.%Y")}}'
    types:
      - 'Vl-RM-4-w: Vlotho'
      
  - platform: waste_collection_schedule
    name: Restmuell_collection
    value_template: '{{value.daysTo}}'
    types:
      - 'Vl-RM-4-w: Vlotho'