From e615ade85ea430663df5584b887d5a54440e5b7f Mon Sep 17 00:00:00 2001 From: proddy Date: Wed, 23 Oct 2024 17:38:05 +0200 Subject: [PATCH] update HA shower example --- docs/Home-Assistant.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/Home-Assistant.md b/docs/Home-Assistant.md index 29d60668..e161fb5d 100644 --- a/docs/Home-Assistant.md +++ b/docs/Home-Assistant.md @@ -97,10 +97,20 @@ sensor: sensors: last_shower_duration: friendly_name: Last shower duration - value_template: "{{ int(states('sensor.ems_esp_shower_duration')) | timestamp_custom('%-M min %-S sec', false)}}" + value_template: >- + {% if has_value('sensor.ems_esp_shower_duration') %} + {{ int(states('sensor.ems_esp_shower_duration')) | timestamp_custom('%-M min %-S sec', false)}} + {% else %} + unknown + {% endif %} last_shower_time: friendly_name: Last shower timestamp - value_template: '{{ as_timestamp(states.sensor.ems_esp_shower_duration.last_updated) | int | timestamp_custom("%-I:%M %p on %a %-d %b") }}' + value_template: >- + {% if has_value('sensor.ems_esp_shower_duration') %} + {{ as_timestamp(states.sensor.ems_esp_shower_duration.last_updated) | int | timestamp_custom("%-I:%M %p on %a %-d %b") }} + {% else %} + unknown + {% endif %} ``` Note you can configure the `timestamp_custom()` to your own preferred format.