From c5a514803a77d3f209e0ddb48437efbcb4365813 Mon Sep 17 00:00:00 2001 From: Claus Dethlefsen Date: Mon, 17 Jan 2022 19:38:22 +0100 Subject: [PATCH] added time --- include/sensors/time.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 include/sensors/time.yaml diff --git a/include/sensors/time.yaml b/include/sensors/time.yaml new file mode 100644 index 0000000..991df8f --- /dev/null +++ b/include/sensors/time.yaml @@ -0,0 +1,14 @@ +- platform: time_date + display_options: + - 'time' + - 'date' + +- platform: template + sensors: + dato: + friendly_name: "Dagens dato" + value_template: >- + {% set timestamp = strptime(states('sensor.date'), '%Y-%m-%d').timestamp() %} + {% set weekdays_DK = ['Man', 'Tirs', 'Ons', 'Tors', 'Fre', 'Lør', 'Søn'] %} + {% set months_DK = ['Januar', 'Februar', 'Marts', 'April', 'Maj', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'December'] %} + {{ weekdays_DK[timestamp | timestamp_custom('%w') | int - 1] }}dag den {{ timestamp | timestamp_custom('%-d.') }} {{ months_DK[timestamp | timestamp_custom('%-m') | int - 1] }} {{ timestamp | timestamp_custom('%Y') }}