olibos/HomeAssistant-RecycleApp

Feature request "next pickup"

Closed this issue · 11 comments

Hello,

Would it be possible to add an entity called "next pickup" with the nearest pickup only? Well that would be great, like this we can add a card with only 1 entity instead of all entities without struggling a lot with custom entities and conditional cards.

Kind regards,

olibos commented

Hi @Jhamende,

Thanks for the suggestion.
image

If I understand your idea correctly, it should add a new sensor: "Next Pickup" with the name "Sac Noir" and value of 03/10.
But after October 3, I'm not sure what to do because "Sac bleu", "Carton" and "Jardin" have the same date.

Any ideas?

Hello,

I didn't think about the possibility to have 2 pickups the same day, and I understand it makes things a bit more complicated.
Other solution is indeed to add additional helpi,g sensors like the one I made:

Example:

  • platform: template
    sensors:
    date_demain:
    friendly_name: date demain
    value_template: "{{ (as_timestamp(now())+(86400)) | timestamp_custom('%Y-%m-%d') }}"

  • platform: template
    sensors:
    pmc_demain:
    friendly_name: pmc demain
    value_template: "{% if states('sensor.pmc') == states('sensor.date_demain') -%}True{%- else -%}False{%- endif %}"
    ===========================

So in my case I made a sensor with date of tomorrow. When pickup PMC is tomorrow, then value is true for pmc_demain, else it will be false.

In my yaml I added a conditional card, if pickup PMC is tomorrow, then show up card, else hide it.

If these sensors for each pickup type is delivered with the plugin, it would help users gain time to add possibility to trigger some sensors for automations like notifications etc.

I hope you understand everything I wrote up here :)

Kind regards
Jonathan

olibos commented

If I have to solve the same problem, I think of 2 simple ways to do that:
With an entity-filter card:
image

Or if you prefer templates:
image

Boths scenarios use the "days" attribute available on each sensor.

What do you think?

Thanks a lot for your answers.
Well indeed first scenario is good for entity-filter card, but there are not sorted from first to latest.

Templating seems quite good for making automations.
could these templates be delivered with plugin or should I make them my self ?

Kind regards,

Hi, Is there a simple way to make notifications one day before the pickup?

Kind regards and thanks for the integration

Hi, Is there a simple way to make notifications one day before the pickup?

Kind regards and thanks for the integration

I created something like this with the following helpers and automations. I only use PMD, Papier-Karton and Restafval so you might have to adapt

Helpers

Tomorrow Date

{{ (as_timestamp(now())+(86400)) | timestamp_custom('%Y-%m-%d') }}

image

Tomorrow's Pickup(s)

{% if states('sensor.papier_karton') == states('sensor.tomorrow_date') -%}
{{ state_attr('sensor.papier_karton', 'friendly_name') +  " - " }}
{%- endif %}
{%- if states('sensor.pmd') == states('sensor.tomorrow_date') -%}
{{ state_attr('sensor.pmd', 'friendly_name')  +  " - " }}
{%- endif %}
{%- if states('sensor.restafval') == states('sensor.tomorrow_date') -%}
{{ state_attr('sensor.restafval', 'friendly_name') +  " - " }}
{%- endif %}

image

Automation:

alias: Afval ophalen
description: ""
trigger:
  - platform: time
    at: "19:00:00"
condition:
  - condition: template
    value_template: >-
      {% if is_state('sensor.tomorrow_s_pickup_s', '') %}false{% else %}true{%
      endif %}
action:
  - service: notify.mobile_app_pixel6a
    metadata: {}
    data:
      message: Morgen afval ophaling van {{states('sensor.tomorrow_s_pickup_s')}}
mode: single

Thanks @MathiasVandePol

If it's ok for you I can add your configuration and samples in the documentation.

Thanks @MathiasVandePol

If it's ok for you I can add your configuration and samples in the documentation.

Yes of course 👍

Hi, I implemented the autmoation and the helpers, tomorrow they will collect 'snoeihout' I added it to the template, but the automation gives 'condition not met'. maybe it has something to do with the dates not metching of tomorrow's date and from snoeihout.

{% if states('sensor.papier_karton') == states('sensor.tomorrow_date') -%}
{{ state_attr('sensor.papier_karton', 'friendly_name') + " - " }}
{%- endif %}
{%- if states('sensor.pmd') == states('sensor.tomorrow_date') -%}
{{ state_attr('sensor.pmd', 'friendly_name') + " - " }}
{%- endif %}
{%- if states('sensor.restafval') == states('sensor.tomorrow_date') -%}
{{ state_attr('sensor.restafval', 'friendly_name') + " - " }}
{%- endif %}
{%- if states('sensor.gft') == states('sensor.tomorrow_date') -%}
{{ state_attr('sensor.gft', 'friendly_name') + " - " }}
{%- endif %}
{%- if states('sensor.glas') == states('sensor.tomorrow_date') -%}
{{ state_attr('sensor.glas', 'friendly_name') + " - " }}
{%- endif %}
{%- if states('sensor.snoeihout') == states('sensor.tomorrow_date') -%}
{{ state_attr('sensor.snoeihout', 'friendly_name') + " - " }}
{%- endif %}

Screenshot_20240118_190455_Home Assistant
Screenshot_20240118_190555_Home Assistant
Screenshot_20240118_190534_Home Assistant
Screenshot_20240118_190515_Home Assistant

Hello @Yakie996,

the reason is linked to the choosed date format.
Your template compares: 2024-01-19 with 19-01 which are differents.
I think, it's simpler to use the days attribute like in this addapted sample

{% set tomorrow_pickups = namespace(entities=[]) %}
{% set collect_types = ['sensor.dechets_non_recyclables_sac', 'sensor.pmc', 'sensor.papier'] %}
{% for collect_type in collect_types %}
  {% if state_attr(collect_type, 'days') == 1 %}
    {% set tomorrow_pickups.entities = tomorrow_pickups.entities + [state_attr(collect_type, 'friendly_name')] %}
  {% endif %}
{% endfor %}
{{ tomorrow_pickups.entities | join(' - ') }}

Let me know if it works for you.

I hope the next release will make those kinds of automation more easier!

Hello,

I've pushed a new pre-release: v2.3.0-b1
This release add new calendar entity for the collect address.

It's easier, I think, to get the next pickup from it:
image

The information about the event is stored in the calendar attributes:
image

If there are multiple collects all the names are joined in the message to simplify notifications.

Automation Sample:

alias: Wastes
description: ""
trigger:
  - platform: calendar
    event: start
    offset: "-6:0:0"
    entity_id: calendar.home
condition: []
action:
  - service: telegram_bot.send_animation
    data:
      url: >
        {% set urls = [
        'https://media1.giphy.com/media/3o6Mb8TVrTepl6sJtC/giphy.gif'
        'https://media1.giphy.com/media/l2Jeg2UYi9opZqxJS/giphy.gif',
        'https://media3.giphy.com/media/xT5LMpG7mY0lSVkZaM/giphy.gif',
        'https://media4.giphy.com/media/xT5LMH41F5NNod141G/giphy.gif',
        'https://media2.giphy.com/media/xT5LMO2CnEEth7O3sI/giphy.gif',
        'https://media0.giphy.com/media/xT5LMxnlknujYHrBOU/giphy.gif',
        'https://64.media.tumblr.com/55b477451de8e4ff54251a8117340863/tumblr_pa46pb88Me1vbcnq8o1_500.gif',
        'https://i.gifer.com/EnPP.gif' ] %} {{ urls|random }}
      caption: |
        {{state_attr('calendar.home', 'message')}}
mode: single

I'll test this release for a week...