Putting some logic to handle when there is no vacation event on the calendar.

This commit is contained in:
Jeffrey Stone 2022-03-06 18:36:18 -05:00
parent aca880a378
commit 2ad155004a
1 changed files with 6 additions and 1 deletions

View File

@ -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