pippyn / Home-Assistant-Sensor-Afvalbeheer

Provides Home Assistant sensors for multiple Dutch and Belgium waste collectors
Apache License 2.0
287 stars 87 forks source link

"volgende" sensor #306

Open hilsonp opened 2 years ago

hilsonp commented 2 years ago

The "morgen" and "vandaag" sensors are great to set alerts/notifications. Nevertheless, I would love having a "volgende" sensor that would have as state:

Here is a card I did that would be even better if the "head" entity was showing the next scheduled collect: `type: entities entities:

pippyn commented 2 years ago

You could do that with a template sensor. But I'll think about including the next-up sensor in this integration. But I'm struggling to see how useful this sensor would be..

hilsonp commented 2 years ago

As you see, I keep on my dashboard a fold-entity-row that allows me, in a tap, to see the next collect day/date. I would like to see, when folded, the next collect(s).

Maybe you are right, the "morgen" entity should suffice... I'll see.

I'll go the template route and will post here if anyone else is interested.

hilsonp commented 2 years ago

So. Here what I did:

A template sensor:

    - name: "Prochaine collecte"
      state: >
        {%- if now() > today_at("10:15") -%}
          {%- set next_collect = {
              "moment": "Demain: ",
              "garbage_items": states("sensor.recycleapp_morgen")
            }
          -%}
        {% else %}
          {%- set next_collect = {
              "moment": "Aujourd'hui: ",
              "garbage_items": states("sensor.recycleapp_vandaag")
            }
          -%}
        {%- endif -%}
        {%- if next_collect.garbage_items == 'None' -%}
          {%- set next_collect = {
              "moment": "",
              "garbage_items": "Aucune"
            }
          -%}
        {%- endif -%}
        {{ next_collect.moment }}{{ 
          next_collect.garbage_items 
            | regex_replace(find='gft', replace='Compost', ignorecase=False)
            | regex_replace(find='papier', replace='Cartons', ignorecase=False)
            | regex_replace(find='pmd', replace='PMC', ignorecase=False)
            | regex_replace(find='restafval', replace='Grise', ignorecase=False)
        }}
      icon: >
        {% if states("sensor.prochaine_collecte") is match("Demain", ignorecase=False) %}
          mdi:delete
        {% elif states("sensor.prochaine_collecte") is match("Aujourd'hui", ignorecase=False) %}
          mdi:delete-circle
        {% else %}
            mdi:delete-empty
        {% endif %}

An entity card:

entities:
  - type: custom:auto-entities
    filter:
      include:
        - entity_id: sensor.recycleapp_*
      exclude:
        - entity_id: sensor.recycleapp_morgen
        - entity_id: sensor.recycleapp_vandaag
        - entity_id: sensor.recycleapp_textiel
    sort:
      method: attribute
      attribute: Sort_date
    card:
      type: custom:fold-entity-row
      head:
        entity: sensor.prochaine_collecte
        name: Poubelles
        tap_action:
          action: fire-dom-event
          fold_row: true

Here are 2 examples:

  1. Closed (default) with collection of 2 items today (displayed like this until 10am): image

  2. Opened (when we tap on it) with no collection (as displayed after 10am): image

Venderwel commented 2 years ago

Hi there! I would like the next up sensor also. With the possibility to have multiple and to have the terms today and tomorrow in it.

Examples: (today is the 6th of june)

Next up: Papier on june 10th

Next up: Tomorrow, june 7th is Papier

Next up: Today is Papier or if today and tomorrow there is pickups: Next up: Today is Papier, Tomorrow, june 7th is GFT and Restafval

I think having the possibility for a next up in HA is great for (week) planning. Besides, I have 3 bins, I don't want to display all 3 of them on the same time on my dashboard.

WesleyLiekens commented 2 years ago

The "morgen" and "vandaag" sensors are great to set alerts/notifications. Nevertheless, I would love having a "volgende" sensor that would have as state:

  • "none": if no schedule can be found
  • "date: ressource, ressource, ..." with the date being the next date where a collect is found, then the list of ressources collected on that day (like the morgen and vandaag sensors display)

Here is a card I did that would be even better if the "head" entity was showing the next scheduled collect: `type: entities entities:

  • type: custom:auto-entities filter: include:
    • entityid: sensor.recycleapp* exclude:
    • entity_id: sensor.recycleapp_morgen
    • entity_id: sensor.recycleapp_vandaag
    • entity_id: sensor.recycleapp_textiel sort: method: attribute attribute: Sort_date card: type: custom:fold-entity-row head: entity: sensor.recycleapp_vandaag tap_action: action: fire-dom-event fold_row: true`

Could you please provide how you set up an alert/notification. I have tried this but I don't get any