I just set up something similar for my son who temporarily lives in our house and is working shift. His shift pattersc onsist of a 42 day cycle with Day, Off, Early, Late and Night. Depending on the current and previous days shifts, I have defined a time window for increasing the underfloor heating in his room and setting it back to reduced temperature.
My solution consists of two automations and a helper input to flag when the automation has run.
- One that runs every day directly after midnight. It creates the respective time slot(s) for the day depending on the shift schedule. A flag is set to indicate that the schedule has been written to the local calendar for the day.
- A second one that switches the heating - in your case the blinds, triggered by the calendar events.
I am posting both automations for your information. Maybe you can use the approach for your own purposes.
1. Create calendar entries
alias: Schichtabhängige FBH-Zeiten
description: Trägt die Schichtzeitblöcke ein und löscht die vom Vortag
triggers:
- at: "00:02:00"
trigger: time
conditions:
- condition: state
entity_id: input_boolean.automation_schicht_eingetragen
state: "off"
actions:
- choose:
- conditions:
- condition: template
value_template: "{{ bloecke | length == 0 }}"
sequence:
- target:
entity_id: input_boolean.automation_schicht_eingetragen
action: input_boolean.turn_on
- stop: Keine Zeitblöcke für diese Schichtkombination.
- repeat:
for_each: "{{ bloecke }}"
sequence:
- variables:
start_raw: "{{ repeat.item.start }}"
ende_raw: "{{ repeat.item.ende }}"
start_dt: |
{% if start_raw == '24:00' %}
{{ tomorrow }}T00:00:00
{% else %}
{{ today }}T{{ start_raw }}:00
{% endif %}
ende_dt: |
{% if ende_raw == '24:00' %}
{{ tomorrow }}T00:00:00
{% elif ende_raw < start_raw %}
{{ tomorrow }}T{{ ende_raw }}:00
{% else %}
{{ today }}T{{ ende_raw }}:00
{% endif %}
- target:
entity_id: calendar.planer
data:
summary: "Schicht: {{ heute }}"
start_date_time: "{{ start_dt }}"
end_date_time: "{{ ende_dt }}"
action: calendar.create_event
mode: single
variables:
heute: "{{ states('sensor.schicht_heute') }}"
gestern: "{{ states('sensor.schicht_gestern') }}"
today: "{{ now().strftime('%Y-%m-%d') }}"
tomorrow: "{{ (now() + timedelta(days=1)).strftime('%Y-%m-%d') }}"
bloecke: |
{% set g = gestern %} {% set h = heute %}
{% if h == 'Tag' %}
{{ [{'start':'15:00','ende':'23:00'}] }}
{% elif h == 'Früh' %}
{{ [{'start':'15:00','ende':'22:00'}] }}
{% elif g == 'Früh' and h == 'Spät' %}
{{ [
{'start':'09:00','ende':'14:00'},
{'start':'21:30','ende':'24:00'}
] }}
{% elif g == 'Spät' and h == 'Spät' %}
{{ [
{'start':'00:00','ende':'01:30'},
{'start':'10:00','ende':'13:30'},
{'start':'21:30','ende':'24:00'}
] }}
{% elif g == 'Spät' and h == 'Nacht' %}
{{ [
{'start':'00:00','ende':'01:30'},
{'start':'09:00','ende':'20:30'}
] }}
{% elif g == 'Nacht' and h == 'Nacht' %}
{{ [{'start':'07:00','ende':'21:00'}] }}
{% elif g == 'Nacht' and h == 'Frei' %}
{{ [{'start':'09:00','ende':'21:30'}] }}
{% elif g == 'Frei' and h == 'Frei' %}
{{ [{'start':'09:00','ende':'21:30'}] }}
{% else %}
{{ [] }}
{% endif %}
2. Actions - in my case heating
alias: Scheduler – Heizung
description: |-
Steuert die FBH-Heizung im Haus. Schaltet zwischen heat_temp und drop_temp um
triggers:
- event: start
entity_id: calendar.planer
id: start
trigger: calendar
- event: end
entity_id: calendar.planer
id: end
trigger: calendar
- event: start
id: ha_start
trigger: homeassistant
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id: start
sequence:
- action: climate.set_temperature
target:
entity_id: climate.jean_t_soll
data:
temperature: "{{ heat_temp }}"
hvac_mode: heat
- conditions:
- condition: trigger
id: end
sequence:
- action: climate.set_temperature
target:
entity_id: climate.jean_t_soll
data:
temperature: "{{ drop_temp }}"
- conditions:
- condition: trigger
id: ha_start
sequence:
- choose:
- conditions:
- condition: template
value_template: "{{ event_active }}"
sequence:
- action: climate.set_temperature
target:
entity_id: climate.jean_t_soll
data:
temperature: "{{ heat_temp }}"
hvac_mode: heat
default:
- action: climate.set_temperature
metadata: {}
target:
entity_id: climate.jean_t_soll
data:
temperature: "{{ drop_temp }}"
hvac_mode: heat
mode: single
variables:
heat_temp: 20
drop_temp: 19.5
event_active: "{{ is_state('calendar.planer', 'on') }}"
3. Reset help flag
alias: Reset Schicht-Automation Flag
description: Setz den Helper jeden Tag um 23:59 zurück
triggers:
- at: "23:59:30"
trigger: time
actions:
- target:
entity_id: input_boolean.automation_schicht_eingetragen
action: input_boolean.turn_off