Wochentag
Manchmal möchte man in Automationen auf den Wochentag setzen.
Um das zu vereinfachen hier der Templatesensor "sensor.weekday"
- platform: template
sensors:
weekday:
friendly_name: "Wochentag"
value_template: >
{% set weekday = int(as_timestamp(states('sensor.date_time_iso')) | timestamp_custom('%u')) %}
{% if weekday == 7 -%}
Sonntag
{%- elif weekday == 6 -%}
Samstag
{%- elif weekday == 5 -%}
Freitag
{%- elif weekday == 4 -%}
Donnerstag
{%- elif weekday == 3 -%}
Mittwoch
{%- elif weekday == 2 -%}
Dienstag
{%- elif weekday == 1 -%}
Montag
{%- else -%}
error
{%- endif %}