Hello,
I have 2 sensors to state my shift start and shift end. I can use them as trigger to switch between “on” and “energy_save” heater.
# google calendar sensor start time
# state - to <time> bevore event
- platform: template
sensors:
next_shift_start:
friendly_name: Schichtbeginn
#entity_id: sensor.time
value_template: >-
{% if states.calendar.sap_schichtplan.attributes.start_time %}
{{((as_timestamp(states.calendar.sap_schichtplan.attributes.start_time) - as_timestamp(now())) /60) | default(99) | int}}
{%- else -%}
0
{%- endif %}
# google calendar sensor start time
# state - to <time> bevore event
- platform: template
sensors:
next_schift_end:
friendly_name: Schichtende
#entity_id: sensor.time
value_template: >-
{% if states.calendar.sap_schichtplan.attributes.end_time %}
{{((as_timestamp(states.calendar.sap_schichtplan.attributes.end_time) - as_timestamp(now())) /60) | default(99) | int}}
{%- else -%}
0
{%- endif %}
If I open the the window, the heater has to be off. After close the window again, I want to reset the heater, to a state depending on my shift if need to heat or energy save.
I guess a template which contains heat or energy_save is the way. But how can I calculate here? Below dies not work.
- platform: template
sensors:
schift_heat:
friendly_name: Schicht - Büro Heizen?
value_template: >-
{% if (next_schift_end > 30) and (next_shift_start < 60 ) %}
heat
{%- else -%}
energy_save
{%- endif %}
Can ayone Help pleased?
Many thanks in advance