I use this macro in an automation that creates events in a calendar called calendar.cumulus.
If the prevision for tomorrow is good, the water boiler will be heated during the day, otherwise it is heated the night.
It requires an input_select called input_select.cumulus_mode = [‘On’,‘Off’,‘Auto’,‘Jour/Nuit’,‘Vacances’]
alias: Cumulus - Planification periode de chauffe
description: ""
triggers:
- trigger: time
at: "20:00:00"
- trigger: state
entity_id:
- input_select.cumulus_mode
to: Auto
conditions:
- condition: or
conditions:
- condition: state
entity_id: input_select.cumulus_mode
state: Auto
- condition: state
entity_id: input_select.cumulus_mode
state: Jour/Nuit
actions:
- alias: Set variables
variables:
sundates: >-
{%- from 'tools.jinja' import dates_sun -%} {{-
dates_sun(1800,1300)|from_json -}}
- choose:
- conditions:
- condition: template
value_template: "{{ sundates.power|float>5000 }}"
alias: Si prod >5kW sur la période de chauffe
- condition: numeric_state
entity_id: sensor.solcast_pv_forecast_previsions_pour_demain
attribute: estimate
above: 10
enabled: false
- condition: numeric_state
entity_id: sensor.solcast_pv_forecast_previsions_du_pic_pour_demain
attribute: estimate
above: 1800
- condition: state
entity_id: input_select.cumulus_mode
state: Auto
sequence:
- action: calendar.create_event
alias: Planifie la chauffe en journée le lendemain
metadata: {}
data:
summary: Chauffe CE
start_date_time: "{{ sundates.start }}"
end_date_time: "{{ sundates.end }}"
target:
entity_id: calendar.cumulus
alias: Si mode auto ET puissance demain >10kWh ET pic >1800W
default:
- alias: Planifie la chauffe durant la nuit
action: calendar.create_event
metadata: {}
data:
summary: Chauffe CE
start_date_time: "{{ now().replace(hour=23, minute=0, second=0).isoformat() }}"
end_date_time: >-
{{ (now().replace(hour=23, minute=0, second=0) +
timedelta(hours=3)).isoformat() }}
target:
entity_id: calendar.cumulus
mode: single