mampfes / hacs_waste_collection_schedule

Home Assistant integration framework for (garbage collection) schedules
MIT License
1.08k stars 658 forks source link

Using multiple sources breaks sensors of 2nd source. #149

Closed FHeilmann closed 2 years ago

FHeilmann commented 2 years ago

I'm trying to add a 2nd source (abfall_io) to an existing source (muellmax) but whenever I add the 2nd source, the sensors for the 2nd source break.

My configuration:

waste_collection_schedule:
  sources:
    - name: muellmax_de
      args:
        service: Ask
        mm_frm_str_sel: Mainzer Straße 63-119, 86-132
      customize:
        - type: ASK Bioabfall-Abfuhr
          alias: Bioabfall
        - type: ASK Restabfall-Abfuhr 2x wöchentlich
          show: no
        - type: ASK Restabfall-Abfuhr alle 2 Wochen
          show: no
        - type: ASK Restabfall-Abfuhr wöchentlich
          alias: Restmüll
        - type: ASK Altpapier-Abfuhr alle 4 Wochen
          alias: Papiermüll
        - type: ASK Altpapier-Abfuhr wöchentlich
          show: no
        - type: ASK Altpapier-Abfuhr alle 2 Wochen
          show: no
        - type: ASK Gelber Sack-Abfuhr alle 2 Wochen
          alias: Gelber Sack
    - name: abfall_io
      args:
        key: "6efba91e69a5b454ac0ae3497978fe1d"
        f_id_kommune: 5916
        f_id_strasse: 5916heinigstrasse
        f_id_strasse_hnr: 10165
        f_abfallarten:
          - 27
          - 67
          - 665
          - 1677

sensor:
  - platform: waste_collection_schedule
    add_days_to: True
    value_template: '{% if value.daysTo == 0 %}Today{% elif value.daysTo == 1 %}Tomorrow{% else %}in {{value.daysTo}} days{% endif %} ({{value.date.strftime("%a, %d.%m.%Y")}})'
    date_template: '{{value.date.strftime("%a, %d.%m.%Y")}}'
    name: lu_restabfall
    types:
      - Restabfall
  - platform: waste_collection_schedule
    add_days_to: True
    value_template: '{% if value.daysTo == 0 %}Today{% elif value.daysTo == 1 %}Tomorrow{% else %}in {{value.daysTo}} days{% endif %} ({{value.date.strftime("%a, %d.%m.%Y")}})'
    date_template: '{{value.date.strftime("%a, %d.%m.%Y")}}'
    name: lu_altpapier
    types:
      - Altpapier
  - platform: waste_collection_schedule
    add_days_to: True
    value_template: '{% if value.daysTo == 0 %}Today{% elif value.daysTo == 1 %}Tomorrow{% else %}in {{value.daysTo}} days{% endif %} ({{value.date.strftime("%a, %d.%m.%Y")}})'
    date_template: '{{value.date.strftime("%a, %d.%m.%Y")}}'
    name: lu_leichtverpackungen
    types:
      - Leichtverpackungen
  - platform: waste_collection_schedule
    add_days_to: True
    value_template: '{% if value.daysTo == 0 %}Today{% elif value.daysTo == 1 %}Tomorrow{% else %}in {{value.daysTo}} days{% endif %} ({{value.date.strftime("%a, %d.%m.%Y")}})'
    date_template: '{{value.date.strftime("%a, %d.%m.%Y")}}'
    name: lu_gruenabfall
    types:
      - Grünabfallsammlung
  - platform: waste_collection_schedule
    name: gelbersack
    add_days_to: True
    value_template: '{% if value.daysTo == 0 %}Today{% elif value.daysTo == 1 %}Tomorrow{% else %}in {{value.daysTo}} days{% endif %} ({{value.date.strftime("%a, %d.%m.%Y")}})'
    date_template: '{{value.date.strftime("%a, %d.%m.%Y")}}'
    types:
      - Gelber Sack
  - platform: waste_collection_schedule
    name: papierabfall
    add_days_to: True
    value_template: '{% if value.daysTo == 0 %}Today{% elif value.daysTo == 1 %}Tomorrow{% else %}in {{value.daysTo}} days{% endif %} ({{value.date.strftime("%a, %d.%m.%Y")}})'
    date_template: '{{value.date.strftime("%a, %d.%m.%Y")}}'
    types:
      - Papiermüll
  - platform: waste_collection_schedule
    name: bioabfall
    add_days_to: True
    value_template: '{% if value.daysTo == 0 %}Today{% elif value.daysTo == 1 %}Tomorrow{% else %}in {{value.daysTo}} days{% endif %} ({{value.date.strftime("%a, %d.%m.%Y")}})'
    date_template: '{{value.date.strftime("%a, %d.%m.%Y")}}'
    types:
      - Bioabfall
  - platform: waste_collection_schedule
    name: restmuell
    add_days_to: True
    value_template: '{% if value.daysTo == 0 %}Today{% elif value.daysTo == 1 %}Tomorrow{% else %}in {{value.daysTo}} days{% endif %} ({{value.date.strftime("%a, %d.%m.%Y")}})'
    date_template: '{{value.date.strftime("%a, %d.%m.%Y")}}'
    types:
      - Restmüll

With both sources, all sensors related to abfallio dates (prefixed `lu) break. The dates show up in the calendar tab, but the sensors have unknown state. If I remove themuellmax` source, those sensors work as expected.

If any more information is needed, please let me know.

-Florian

Haitec commented 2 years ago

Try to use:

  - platform: waste_collection_schedule
    source_index: 1
    name: restmuell
    add_days_to: True
    value_template: '{% if value.daysTo == 0 %}Today{% elif value.daysTo == 1 %}Tomorrow{% else %}in {{value.daysTo}} days{% endif %} ({{value.date.strftime("%a, %d.%m.%Y")}})'
    date_template: '{{value.date.strftime("%a, %d.%m.%Y")}}'
    types:
      - Restmüll

source_index (integer) (optional, default: 0)

Reference to source (service provider). Used to assign a sensor to a specific source. Only required if you defined more than one source. The first defined source has the source_index 0, the second source 1, ...

FHeilmann commented 2 years ago

Oh no, I must have missed that. Apologies.