From 2ad155004a1eb9b2c4f03acc1015d960c0862944 Mon Sep 17 00:00:00 2001 From: Jeffrey Stone Date: Sun, 6 Mar 2022 18:36:18 -0500 Subject: [PATCH] Putting some logic to handle when there is no vacation event on the calendar. --- config/packages/events.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/config/packages/events.yaml b/config/packages/events.yaml index c708914..7383cb2 100755 --- a/config/packages/events.yaml +++ b/config/packages/events.yaml @@ -99,7 +99,12 @@ sensor: value_template: "{{ ((state_attr('input_datetime.school_last_day', 'timestamp')-as_timestamp(now())) | int /60/1440) | round(0) }}" unit_of_measurement: 'Days' vacation_days2go: - value_template: "{{ ((as_timestamp(strptime(state_attr('calendar.vacation', 'start_time'), '%Y-%m-%d'))-as_timestamp(now())) | int /60/1440) | round(0) }}" + value_template: > + {% if state_attr('calendar.vacation', 'start_time') %} + {{ ((as_timestamp(strptime(state_attr('calendar.vacation', 'start_time'), '%Y-%m-%d'))-as_timestamp(now())) | int /60/1440) | round(0) }} + {% else %} + 999 + {% endif %} unit_of_measurement: 'Days' - platform: rest resource: https://raw.githubusercontent.com/thejeffreystone/home-assistant-configuration/master/config/packages/json_data/school.json