Good morning everyone,
I used this project
[Garbage card for home assistant]
(GitHub - Simonz82/ha_garbage: Garbage card for home assistant)
- platform: template
sensors:
raccoltadifferenziata:
entity_id: sensor.date
friendly_name: "Dalle ore 20 alle 07" #Orario di conferimento
value_template: >-
{% if now().weekday() == 6 -%}
Nulla
{%- elif now().weekday() == 0 -%}
Organico
{%- elif now().weekday() == 1 -%}
Plastica
{%- elif now().weekday() == 2 -%}
Carta
{%- elif now().weekday() == 3 -%}
Organico e resto
{%- elif now().weekday() == 4 -%}
Vetro
{%- elif now().weekday() == 5 -%}
Nulla
{%- endif %}
I added the first edit to exclude some months and it works.
sensor:
- platform: template
sensors:
raccoltadifferenziata:
entity_id: sensor.date
friendly_name: "Dalle ore 20 alle 24" #Orario di conferimento
value_template: >-
{% if now().weekday() == 6 -%}
Nulla
{%- elif now().weekday() == 0 -%}
Organico
{%- elif now().weekday() == 1 -%}
Nulla
{%- elif now().weekday() == 2 -%}
Secco
{%- elif now().weekday() == 3 -%}
Nulla
{%- elif now().weekday() == 4 -%}
{% if now().month in [1,2,12] -%}
Nulla
{% else -%}
Organico
{%- endif %}
{%- elif now().weekday() == 5 -%}
Nulla
{%- endif %}
As an answer he must give:
Nulla
Organico
Then I tried to put a helper to disable the warning, but it doesn’t work well because it doubles the names:
Organico Organico
Organico Nulla
sensor:
- platform: template
sensors:
raccoltadifferenziata:
entity_id: sensor.date
friendly_name: "Dalle ore 20 alle 24" #Orario di conferimento
value_template: >-
{% if now().weekday() == 6 -%}
Nulla
{%- elif now().weekday() == 0 -%}
Organico
{%- elif now().weekday() == 1 -%}
Nulla
{%- elif now().weekday() == 2 -%}
Secco
{%- elif now().weekday() == 3 -%}
Nulla
{%- elif now().weekday() == 4 -%}
{% if now().month in [1,2,12] -%}
Nulla
{% else -%}
Organico
{%- endif %}
{% if is_state('input_boolean.reset_raccolta_differenziata', 'on') -%}
Nulla
{% else -%}
Organico
{%- endif %}
{%- elif now().weekday() == 5 -%}
Nulla
{%- endif %}
Let me start by saying that I am a beginner, can someone explain to me where I am going wrong?
Thanks