mampfes / hacs_waste_collection_schedule

Home Assistant integration framework for (garbage collection) schedules
MIT License
988 stars 631 forks source link

[Feature]: AbfallNavi need the option to filter on "Abfallsorten" (fractions) #1692

Closed frankfrommelt closed 7 months ago

frankfrommelt commented 8 months ago

I propose a feature for:

Sources

Describe your wanted feature

Currently Abfallnavi reports all "Abfallsorten". As usually no-one has a e.g. 2-week-schedule AND a 4-week-schedule for his "Restmüll" one needs to be able to filter which are relevant.

image

Looking at the query below each "Abfallsorte" in one "fraktion" (see the example below).

7 "Abfallsorten" = 7 "fraktion"s

OPTIONS //abfall-app-unna/rest/strassen/08154711/termine?fraktion=0&fraktion=4&fraktion=5&fraktion=6&fraktion=7&fraktion=11&fraktion=21 HTTP/1.1

So, in addition to service, city, street there should be the option to filter on "fraktion"/"Abfallsorte".

5ila5 commented 8 months ago

I do not think that's the best way of handling this. You should use the customize argument for customizing which collection is shown how: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/installation.md#attributes-for-sources

hobbysegler commented 7 months ago

You can use the customization in the source definition or filter with the sensors.

waste_collection_schedule:
  sources:
    - name: bsr_de
      calendar_title: "Müllkalender"
      args:
        abf_strasse: "xxxx"
        abf_hausnr: x
      customize:
        - type: "Abholung Biogut"
          alias: BioTonne
          icon: mdi:flower-outline
        - type: "Abholung Wertstoffe (Abholung durch BSR)"
          alias: WertstoffTonne
          icon: mdi:recycle
        - type: "Abholung Hausmüll"
          alias: Restmuell
          icon: mdi:trash-can
        - type: "Abholung Weihnachtsbäume"
          alias: 'Weihnachtsbäume'
          icon: mdi:pine-tree
    - name: ics
      calendar_title: "Papiertonne"
      args: 
        url: "https://calendar.google.com/calendar/ical/xxxx"
      customize:
        - type: "Abholung Papier (an die Strasse stellen)"
          alias: Papiertonne
          icon: mdi:trash-can-outline        
  fetch_time: 03:00
  random_fetch_time_offset: 59

and the sensors: no filter:

- platform: waste_collection_schedule
  source_index: [0, 1]
  name: muell

and filter to one wastetype:

- platform: waste_collection_schedule
  source_index: [0, 1]
  name: AbfallRestmuell
  details_format: "upcoming"
  value_template: '{% if value.daysTo == 0 %}Heute{% elif value.daysTo == 1 %}Morgen{% else %}in {{value.daysTo}} Tagen{% endif %}'
  types:
    - Restmuell

edit by @5ila5: fixed code display style

frankfrommelt commented 7 months ago

Nice; and the example is very helpful to me. Thanks.

While this is a good workaround, I still believe it is better to not poll unwanted data instead of polling “everything” and then dumping most of it into the data-nirvana… 😉

Take care

                  Frank

Von: hobbysegler @.> Gesendet: Dienstag, 30. Januar 2024 09:06 An: mampfes/hacs_waste_collection_schedule @.> Cc: Frank Frommelt @.>; Author @.> Betreff: Re: [mampfes/hacs_waste_collection_schedule] [Feature]: AbfallNavi need the option to filter on "Abfallsorten" (fractions) (Issue #1692)

You can use the customization in the source definition or filter with the sensors. ' waste_collection_schedule: sources:

and filter to one wastetype:

— Reply to this email directly, view it on GitHubhttps://github.com/mampfes/hacs_waste_collection_schedule/issues/1692#issuecomment-1916276962, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AN5XG75TSDJBGYVKHJW2HA3YRCSYLAVCNFSM6AAAAABB73BRDSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJWGI3TMOJWGI. You are receiving this because you authored the thread.Message ID: @.**@.>>

5ila5 commented 7 months ago

You can use

   customize:
        - type: "Abholung Biogut"
          show: False

To remove entries completely from your calendar/Sensor, providing the options for selecting waste types on fetch adds complexity and additional points of failure.

This is described in the contribution guide:

Filtering of data for waste types or time periods is a functionality of the framework and should not be done by the source script.

  • A source script should return all data for all available waste types.
  • A source script should not provide options to limit the returned waste types.
hobbysegler commented 7 months ago

@5ila5 : thx for editing and formatting my code :-) i tried but unsuccessful.

frankfrommelt commented 7 months ago

OK, this version is working for me.

I had to add a "show: false" for all types that I did not want to show up in my calendar. Sadly, we have as many types that I need as the ones that I do not need. ;-)

Thanks again

waste_collection_schedule:
  sources:
    - name: abfallnavi_de
      calendar_title: "Müllkalender"
      args:
        service: unna
        ort: irgendwo
        strasse: irgendwo
        hausnummer: 4711
      customize:
        - type: "Biotonne"
          icon: mdi:flower-outline
        - type: "Papiertonne"
          icon: mdi:paper-roll
        - type: "Wertstofftonne"
          alias: Wertstofftonne
          icon: mdi:recycle
        - type: "Restmüll 2-wö."
          alias: Restmüll
          icon: mdi:trash-can
        - type: "Weihnachtsbaum"
          icon: mdi:pine-tree
        - type: "Restmüll Umleerer 1-wchtl. 1100 L"
          show: false
        - type: "Restmüll 2-wö. 1100 Liter"
          show: false
        - type: "Restmüll 4-wö. 1100 Liter"
          show: false
        - type: "Restmüll 4-wö."
          show: false
        - type: "Wertstoffcontainer"
          show: false