Improve school related "days2go" sensors with time macros
This commit is contained in:
@ -104,40 +104,51 @@ sensor:
|
||||
sensors:
|
||||
school_start_days2go:
|
||||
unique_id: 94a53e67-c00f-4cc7-9309-f9033a9482f9
|
||||
value_template: "{{ ((state_attr('input_datetime.school_first_day', 'timestamp')-as_timestamp(now())) | int /60/1440) | round(0) }}"
|
||||
value_template: >
|
||||
{% from 'easy_time.jinja' import count_the_days %}
|
||||
{{ count_the_days('input_datetime.school_first_day') }}
|
||||
attribute_templates:
|
||||
date: "{{ state_attr('input_datetime.school_first_day','timestamp') | timestamp_custom('%B %d, %Y') }}"
|
||||
unit_of_measurement: 'Days'
|
||||
school_end_days2go:
|
||||
unique_id: 589c44ec-7e16-4c72-a264-cdf54de409a9
|
||||
value_template: "{{ ((state_attr('input_datetime.school_last_day', 'timestamp')-as_timestamp(now())) | int /60/1440) | round(0) }}"
|
||||
value_template: >
|
||||
{% from 'easy_time.jinja' import count_the_days %}
|
||||
{{ count_the_days('input_datetime.school_last_day') | int }}
|
||||
attribute_templates:
|
||||
date: "{{ state_attr('input_datetime.school_last_day','timestamp') | timestamp_custom('%B %d, %Y') }}"
|
||||
unit_of_measurement: 'Days'
|
||||
vacation_days2go:
|
||||
unique_id: f1628d87-e58a-4d1a-8a49-a71f0a9ed3e5
|
||||
value_template: >
|
||||
{% from 'easy_time.jinja' import count_the_days %}
|
||||
{% 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) }}
|
||||
{{ count_the_days('calendar.vacation','start_time') }}
|
||||
{% else %}
|
||||
999
|
||||
{% endif %}
|
||||
unit_of_measurement: 'Days'
|
||||
thanksgiving_break_days2go:
|
||||
unique_id: 2381e9de-407b-4304-b09a-448c169bbaf2
|
||||
value_template: "{{ ((state_attr('input_datetime.thanksgiving_break_start', 'timestamp')-as_timestamp(now())) | int /60/1440) | round(0) }}"
|
||||
value_template: >
|
||||
{% from 'easy_time.jinja' import count_the_days %}
|
||||
{{ count_the_days('input_datetime.thanksgiving_break_start') }}
|
||||
attribute_templates:
|
||||
date: "{{ state_attr('input_datetime.thanksgiving_break_start','timestamp') | timestamp_custom('%B %d, %Y') }}"
|
||||
unit_of_measurement: 'Days'
|
||||
christmas_break_days2go:
|
||||
unique_id: 851700f7-c593-4db8-ba4f-001cbffcfc4a
|
||||
value_template: "{{ ((state_attr('input_datetime.christmas_break_start', 'timestamp')-as_timestamp(now())) | int /60/1440) | round(0) }}"
|
||||
value_template: >
|
||||
{% from 'easy_time.jinja' import count_the_days %}
|
||||
{{ count_the_days('input_datetime.christmas_break_start') }}
|
||||
attribute_templates:
|
||||
date: "{{ state_attr('input_datetime.christmas_break_start','timestamp') | timestamp_custom('%B %d, %Y') }}"
|
||||
unit_of_measurement: 'Days'
|
||||
spring_break_days2go:
|
||||
unique_id: cec6e687-8999-4548-991c-02ba546335f5
|
||||
value_template: "{{ ((state_attr('input_datetime.spring_break_start', 'timestamp')-as_timestamp(now())) | int /60/1440) | round(0) }}"
|
||||
value_template: >
|
||||
{% from 'easy_time.jinja' import count_the_days %}
|
||||
{{ count_the_days('input_datetime.spring_break_start') }}
|
||||
attribute_templates:
|
||||
date: "{{ state_attr('input_datetime.spring_break_start','timestamp') | timestamp_custom('%B %d, %Y') }}"
|
||||
unit_of_measurement: 'Days'
|
||||
|
Reference in New Issue
Block a user