Putting some logic to handle when there is no vacation event on the calendar.
This commit is contained in:
parent
aca880a378
commit
2ad155004a
|
@ -99,7 +99,12 @@ sensor:
|
||||||
value_template: "{{ ((state_attr('input_datetime.school_last_day', 'timestamp')-as_timestamp(now())) | int /60/1440) | round(0) }}"
|
value_template: "{{ ((state_attr('input_datetime.school_last_day', 'timestamp')-as_timestamp(now())) | int /60/1440) | round(0) }}"
|
||||||
unit_of_measurement: 'Days'
|
unit_of_measurement: 'Days'
|
||||||
vacation_days2go:
|
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'
|
unit_of_measurement: 'Days'
|
||||||
- platform: rest
|
- platform: rest
|
||||||
resource: https://raw.githubusercontent.com/thejeffreystone/home-assistant-configuration/master/config/packages/json_data/school.json
|
resource: https://raw.githubusercontent.com/thejeffreystone/home-assistant-configuration/master/config/packages/json_data/school.json
|
||||||
|
|
Loading…
Reference in New Issue