Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Days to collection Sensor #51

Open
torsti09 opened this issue Mar 24, 2023 · 1 comment
Open

Days to collection Sensor #51

torsti09 opened this issue Mar 24, 2023 · 1 comment

Comments

@torsti09
Copy link

torsti09 commented Mar 24, 2023

Hey!
First of all, thanks for this nice integration.

I've build a sensor in configuration for display how many days until colletion date.
Feel free to use it, too.

template:
  - sensor:
      - name: "Abholung Restmüll"
        unique_id: "abholung_restmuell"
        unit_of_measurement: "Days"
        icon: mdi:trash-can
        state: >
            {% set days_to = (((as_timestamp(strptime(states('sensor.restabfall'), "%Y-%m-%d")))  - as_timestamp(now())) / 86400) | round(0, "ceil", default)%}
            {% if days_to == 0 %}Heute{% elif days_to == 1 %}Morgen{% else %}in {{days_to}} Tagen{% endif %}

Greetings
torsti09

@Arnerei
Copy link

Arnerei commented Mar 26, 2023

Hey torsti09,
thanks for your blueprint.
I adjusted it for my case.

 - platform: template
    sensors:
      countdown_restmuell:
        friendly_name: "Abholung Restmüll"
        value_template: >
            {% set days_to = (((as_timestamp(strptime(states('sensor.restabfall'), "%Y-%m-%d")))  - as_timestamp(now())) / 86400) | round(default=0) %}
            {% if days_to == 0 %}Heute{% elif days_to == 1 %}Morgen{% else %}in {{days_to}} Tagen{% endif %}

Cheers
Arnerei

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants