Beetje complex verhaal. Probeer het even in grote lijnen te doen.
Deze Atlantic split unit boiler heeft een soort dal\piektarief aansturing met een voor mij wat ingewikkeld schema om deze op de meterkast aan te sluiten, schijnt vooral gebruikelijk te zijn in Frankrijk. Maar het blijken gewoon twee contacten die wel of geen 230 willen ontvangen om de boiler in piek of daltarief te zetten. Ik heb dus een slimme schakelaar genomen en er een afgeknipt apparaatsnoer in gestoken, de uiteinden van het snoer op de contacten. (Note to self, dat moet ik even goed labelen, een buitenstaander kan denken dat hij de stekker eruit heeft terwijl de echte voeding direct naar een eigen groep in de meterkast gaat

) Met het menu op de boiler kon een bepaalde ECO stand worden geselecteerd en kan ingesteld worden dat verwarmen uitsluitend tijdens ECO tijdstippen mag plaatsvinden. Als ik de slimme schakelaar "aan" zet (en het water is koud genoeg) dan begint de boiler met opwarmen. Ik ben er nog niet helemaal uit wat er gebeurt als ik tijdens het verwarmen de schakelaar uitzet, volgens mij maakt de boiler wel gewoon de run af, dat vind ik geen probleem, de boiler wordt dan teminste niet afgekapt tijdens een legionella run.
We hebben een dynamisch energiecontract en wij douchen terwijl de rest van Nederland dat ook doet, precies tijdens de hoogste tarieven en dus niet een fijn en ook geen duurzaam moment om dan de boiler direct weer te laten opwarmen. Dat moet op het moment dat er een groene stroom (=goedkoop) overschot is. Dus ik heb in Home Assistant de
Nordpool integratie geïnstalleerd, daarmee weet ik wat vandaag en morgen de goedkoopste momenten zijn. Ik heb in eerste instantie met een NodeRed schema ingesteld dat de boiler twee keer per dag op het goedkoopste moment aan ging, maar zoals je aan het energieverbruik ziet is dat niet heel handig, na het goedkoopste uur gaat vaak het tarief alweer met kleine sprongen omhoog en had de boiler beter een uurtje vóór het goedkoopste moment aan kunnen gaan.
Met ons douchegedrag duren de runs tussen 2 en 3 uur maar dat is niet helemaal zeker dus ik wilde dat de boiler twee keer per dag een run maakt tijdens de 4 goedkoopste aaneengesloten uren.
Ik heb nog wat meer gerommeld maar ik ben bij de volgende methode blijven hangen en ben daar erg tevreden mee. Ik heb nu twee aangepaste scripts geïnstalleerd van
deze maker die gebruik maakt van de Home Assistant calendar, zo kan ik ook zien wanneer de boiler zal gaan draaien en wanneer hij gedraaid heeft.
Twee scripts omdat ik twee runs per dag wil, in de scripts heb ik ingesteld dat een run maximaal 4 uur mag duren en dan wordt voor de eerste run de goedkoopste aaneengesloten 4 uur gezocht binnen de gekozen periode 21:00 tot 9:00 uur en de tweede run zoekt de goedkoopste aaneengesloten 4 uren tussen 9:00 en 21:00. Het varieert meestal maar een uurtje of 2 maar er zijn toch wel eens uitzonderingen en ik voel me er wel gerust bij dat ik zoveel mogelijk centen bespaar. Ziet er dan in HA zo uit.
Omdat ik niet super behendig ben met scripten (kost me gewoon heel veel tijd om ze vervolgens maar voor een kwart te doorgronden) heb ik ze nog niet weten samen te voegen. De maker heeft wel voorbeelden waarbij hij in één script de agenda van de boiler en een laadpaal bestuurt. Ik probeerde eerst alle variabelen, ID's en namen van de laadpaal te gebruiken voor de tweede run van de boiler maar kreeg het niet werkend. Dus heb ik eerst 1 script gemaakt en die gekopeerd voor de tweede run, na hier alle variabelen en ID's te hernoemen werkte het wel. Ik zet ze hier neer voor wie dat kan gebruiken, je hoeft alleen maar wat entiteiten aan te passen.
advanced_cheapest_hours_multiple_boiler_night.yaml:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
| # Package to create and handle cheapest hours from nord pool integration!
# This is the SINGLE entry version.
# For more details check out the blog post at https://www.creatingsmarthome.com/?p=1620
template:
- sensor:
# The actual cheapest hour sensor. If multiple entries are required, copy and set unique_id and configure attributes.
- name: "Cheapest hours energy boiler night"
unique_id: cheapest_hours_energy_boiler_night
device_class: timestamp
state: >
{%- set sensor = (this.attributes.get('sensor', 'sensor.nordpool_kwh_nl_eur_3_09_0') | string) -%}
{%- set numberOfSequentialHours = (this.attributes.get('number_of_sequential_hours',1) | int) -%}
{%- set lastHour = (this.attributes.get('last_hour',23) | int) -%}
{%- set firstHour = (this.attributes.get('first_hour', 0) | int) -%}
{%- set startingToday = (this.attributes.get('starting_today', false) | bool) -%}
{%- if state_attr(sensor, 'tomorrow_valid') == true -%}
{%- set arr = state_attr(sensor, 'today') + state_attr(sensor, 'tomorrow') -%}
{%- set ns = namespace(counter=0, list=[], cheapestHour=today_at("00:00"), cheapestPrice=999.00) -%}
{%- if startingToday == true -%}
{%- set ns.starting = firstHour -%}
{%- else -%}
{%- set ns.starting = firstHour + 24 -%}
{%- endif -%}
{%- set ns.ending = lastHour + 24 -%}
{%- for i in range(ns.starting + numberOfSequentialHours, ns.ending+1) -%}
{%- set ns.counter = 0.0 -%}
{%- for j in range(i-numberOfSequentialHours, i) -%}
{%- set ns.counter = ns.counter + arr[j] -%}
{%- endfor -%}
{%- set ns.list = ns.list + [ns.counter] -%}
{%- if ns.counter < ns.cheapestPrice -%}
{%- set ns.cheapestPrice = ns.counter -%}
{%- set ns.cheapestHour = today_at("00:00") + timedelta( hours = (i - numberOfSequentialHours)) -%}
{%- endif -%}
{%- endfor -%}
{{ ns.cheapestHour }}
{%- set ns.cheapestPrice = ns.cheapestPrice / numberOfSequentialHours -%}
{%- endif -%}
attributes:
# CHANGE-ME: Set your personal configurations in here
number_of_sequential_hours: 4 # Amount of sequantial cheapest hours in search
first_hour: 21 # Search starting hour
last_hour: 09 # Search ending hour
starting_today: true # Is the first_hour today (true / false). If false, first_hour needs to be before last_hour.
sensor: sensor.nordpool_kwh_nl_eur_3_09_0 # Nord pool sensor id. Check it ouf from your integrations page!
fail_safe_starting: '02:00' # If nordpool fetch fails, starting time to make the calendar entry
automation:
# Automation to trigger when calendar event hits the cheapest hour mark
# start/stop automation
- id: 'cheapest_hours_calendar_entry_boiler_night'
alias: 'Cheapest hours: Calendar trigger boiler night'
description: ''
trigger:
- platform: calendar
event: start
entity_id: calendar.electricity
- platform: calendar
event: end
entity_id: calendar.electricity
condition:
- condition: template
value_template: >
{%- set sensorId = 'sensor.cheapest_hours_energy_boiler_night' -%}
{{ (state_attr(sensorId, 'friendly_name') | string) == trigger.calendar_event.summary }}
action:
- if:
- condition: template
value_template: '{{ trigger.event == ''start'' }}'
then:
# CHANGE-ME: Actions to do when cheapest hours starts
- service: switch.turn_on
entity_id: switch.switch_boiler_tarief
else:
# CHANGE-ME: Actions to do when cheapest hours ends
- service: switch.turn_off
entity_id: switch.switch_boiler_tarief
mode: single
# -- GLOBAL CONFIGURATIONS BELOW, NO NEED TO CHANGE UNLESS CREATING MULTIPLE SEQUENCES --
# Create calendar event
- id: 'cheapest_hours_set_sequence_boiler_night'
alias: 'Cheapest hours: Set next cheapest sequence boiler night'
description: 'Checks tomorrow energy prices every hour and create calendar entry when available AND events not yet created'
trigger:
- platform: time_pattern
hours: /1
condition:
- condition: template
# from which sensor we should try the tomorrow price validation
value_template: >
{%- set sensorId = 'sensor.cheapest_hours_energy_boiler_night' -%}
{{ state_attr((state_attr(sensorId, 'sensor') | string), 'tomorrow_valid') == true }}
- condition: state
entity_id: input_boolean.cheapest_hours_set_boiler_night
state: 'off'
action:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.cheapest_hours_set_boiler_night
# Event creation
- service: calendar.create_event
data:
start_date_time: >
{%- set sensorId = 'sensor.cheapest_hours_energy_boiler_night' -%}
{{ as_timestamp(states(sensorId), 0) | timestamp_local }}
end_date_time: >
{%- set sensorId = 'sensor.cheapest_hours_energy_boiler_night' -%}
{{ (as_timestamp(states(sensorId), 0) + (3600 * state_attr(sensorId, 'number_of_sequential_hours') | float)) | timestamp_local }}
summary: >
{%- set sensorId = 'sensor.cheapest_hours_energy_boiler_night' -%}
{{ state_attr(sensorId, 'friendly_name') | string }}
target:
entity_id: calendar.electricity
# If multiple cheapest hours sequences are required, copy 'calendar.create_event' block from aboce and change the 'sensorId' variabes values to match corresponding new cheapest hours templated sensor
mode: single
# Failsafe
- id: 'cheapest_hours_failsafe boiler night'
alias: 'Cheapest hours: Failsafe boiler night'
description: 'Failsafe: Set cheapest hours from fail_safe value to amount of hours'
trigger:
- platform: time
at: '23:15'
condition:
- condition: state
entity_id: input_boolean.cheapest_hours_set_boiler_night
state: 'off'
action:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.cheapest_hours_set_boiler_night
# Failsafe action
- service: calendar.create_event
data:
start_date_time: >
{%- set sensorId = 'sensor.cheapest_hours_energy_boiler_night' -%}
{{ as_timestamp(today_at(state_attr(sensorId, 'fail_safe_starting')) + timedelta( hours = 24 ), 0) | timestamp_local }}
end_date_time: >
{%- set sensorId = 'sensor.cheapest_hours_energy_boiler_night' -%}
{{ (as_timestamp(today_at(state_attr(sensorId, 'fail_safe_starting')) + timedelta( hours = 24 ), 0) + (3600 * state_attr(sensorId, 'number_of_sequential_hours') | float)) | timestamp_local }}
summary: >
{%- set sensorId = 'sensor.cheapest_hours_energy_boiler_night' -%}
{{ state_attr(sensorId, 'friendly_name') | string }}
target:
entity_id: calendar.electricity
# If multiple cheapest hours sequences are required, make a copy of 'calendar.create_event' block above and set the 'sensorId' values to match the new one
mode: single
# input_boolean reset
- id: 'cheapest_hours_clear_set_flag_boiler_night'
alias: 'Cheapest hours: Reset the set helper for the next day boiler night'
description: 'Clears cheapest hours helper boolean when the day changes.'
trigger:
- platform: time
at: '01:15:00'
condition: []
action:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.cheapest_hours_set_boiler_night
mode: single
# We need a helper to know if the calendar mark(s) has already been set!
input_boolean:
cheapest_hours_set_boiler_night:
name: Cheapest hours set for the next day boiler night
icon: mdi:clock |
advanced_cheapest_hours_multiple_boiler_night.yaml
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
| # Package to create and handle cheapest hours from nord pool integration!
# This is the SINGLE entry version.
# For more details check out the blog post at https://www.creatingsmarthome.com/?p=1620
template:
- sensor:
# The actual cheapest hour sensor. If multiple entries are required, copy and set unique_id and configure attributes.
- name: "Cheapest hours energy boiler night"
unique_id: cheapest_hours_energy_boiler_night
device_class: timestamp
state: >
{%- set sensor = (this.attributes.get('sensor', 'sensor.nordpool_kwh_nl_eur_3_09_0') | string) -%}
{%- set numberOfSequentialHours = (this.attributes.get('number_of_sequential_hours',1) | int) -%}
{%- set lastHour = (this.attributes.get('last_hour',23) | int) -%}
{%- set firstHour = (this.attributes.get('first_hour', 0) | int) -%}
{%- set startingToday = (this.attributes.get('starting_today', false) | bool) -%}
{%- if state_attr(sensor, 'tomorrow_valid') == true -%}
{%- set arr = state_attr(sensor, 'today') + state_attr(sensor, 'tomorrow') -%}
{%- set ns = namespace(counter=0, list=[], cheapestHour=today_at("00:00"), cheapestPrice=999.00) -%}
{%- if startingToday == true -%}
{%- set ns.starting = firstHour -%}
{%- else -%}
{%- set ns.starting = firstHour + 24 -%}
{%- endif -%}
{%- set ns.ending = lastHour + 24 -%}
{%- for i in range(ns.starting + numberOfSequentialHours, ns.ending+1) -%}
{%- set ns.counter = 0.0 -%}
{%- for j in range(i-numberOfSequentialHours, i) -%}
{%- set ns.counter = ns.counter + arr[j] -%}
{%- endfor -%}
{%- set ns.list = ns.list + [ns.counter] -%}
{%- if ns.counter < ns.cheapestPrice -%}
{%- set ns.cheapestPrice = ns.counter -%}
{%- set ns.cheapestHour = today_at("00:00") + timedelta( hours = (i - numberOfSequentialHours)) -%}
{%- endif -%}
{%- endfor -%}
{{ ns.cheapestHour }}
{%- set ns.cheapestPrice = ns.cheapestPrice / numberOfSequentialHours -%}
{%- endif -%}
attributes:
# CHANGE-ME: Set your personal configurations in here
number_of_sequential_hours: 4 # Amount of sequantial cheapest hours in search
first_hour: 21 # Search starting hour
last_hour: 09 # Search ending hour
starting_today: true # Is the first_hour today (true / false). If false, first_hour needs to be before last_hour.
sensor: sensor.nordpool_kwh_nl_eur_3_09_0 # Nord pool sensor id. Check it ouf from your integrations page!
fail_safe_starting: '02:00' # If nordpool fetch fails, starting time to make the calendar entry
automation:
# Automation to trigger when calendar event hits the cheapest hour mark
# start/stop automation
- id: 'cheapest_hours_calendar_entry_boiler_night'
alias: 'Cheapest hours: Calendar trigger boiler night'
description: ''
trigger:
- platform: calendar
event: start
entity_id: calendar.electricity
- platform: calendar
event: end
entity_id: calendar.electricity
condition:
- condition: template
value_template: >
{%- set sensorId = 'sensor.cheapest_hours_energy_boiler_night' -%}
{{ (state_attr(sensorId, 'friendly_name') | string) == trigger.calendar_event.summary }}
action:
- if:
- condition: template
value_template: '{{ trigger.event == ''start'' }}'
then:
# CHANGE-ME: Actions to do when cheapest hours starts
- service: switch.turn_on
entity_id: switch.switch_boiler_tarief
else:
# CHANGE-ME: Actions to do when cheapest hours ends
- service: switch.turn_off
entity_id: switch.switch_boiler_tarief
mode: single
# -- GLOBAL CONFIGURATIONS BELOW, NO NEED TO CHANGE UNLESS CREATING MULTIPLE SEQUENCES --
# Create calendar event
- id: 'cheapest_hours_set_sequence_boiler_night'
alias: 'Cheapest hours: Set next cheapest sequence boiler night'
description: 'Checks tomorrow energy prices every hour and create calendar entry when available AND events not yet created'
trigger:
- platform: time_pattern
hours: /1
condition:
- condition: template
# from which sensor we should try the tomorrow price validation
value_template: >
{%- set sensorId = 'sensor.cheapest_hours_energy_boiler_night' -%}
{{ state_attr((state_attr(sensorId, 'sensor') | string), 'tomorrow_valid') == true }}
- condition: state
entity_id: input_boolean.cheapest_hours_set_boiler_night
state: 'off'
action:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.cheapest_hours_set_boiler_night
# Event creation
- service: calendar.create_event
data:
start_date_time: >
{%- set sensorId = 'sensor.cheapest_hours_energy_boiler_night' -%}
{{ as_timestamp(states(sensorId), 0) | timestamp_local }}
end_date_time: >
{%- set sensorId = 'sensor.cheapest_hours_energy_boiler_night' -%}
{{ (as_timestamp(states(sensorId), 0) + (3600 * state_attr(sensorId, 'number_of_sequential_hours') | float)) | timestamp_local }}
summary: >
{%- set sensorId = 'sensor.cheapest_hours_energy_boiler_night' -%}
{{ state_attr(sensorId, 'friendly_name') | string }}
target:
entity_id: calendar.electricity
# If multiple cheapest hours sequences are required, copy 'calendar.create_event' block from aboce and change the 'sensorId' variabes values to match corresponding new cheapest hours templated sensor
mode: single
# Failsafe
- id: 'cheapest_hours_failsafe boiler night'
alias: 'Cheapest hours: Failsafe boiler night'
description: 'Failsafe: Set cheapest hours from fail_safe value to amount of hours'
trigger:
- platform: time
at: '23:15'
condition:
- condition: state
entity_id: input_boolean.cheapest_hours_set_boiler_night
state: 'off'
action:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.cheapest_hours_set_boiler_night
# Failsafe action
- service: calendar.create_event
data:
start_date_time: >
{%- set sensorId = 'sensor.cheapest_hours_energy_boiler_night' -%}
{{ as_timestamp(today_at(state_attr(sensorId, 'fail_safe_starting')) + timedelta( hours = 24 ), 0) | timestamp_local }}
end_date_time: >
{%- set sensorId = 'sensor.cheapest_hours_energy_boiler_night' -%}
{{ (as_timestamp(today_at(state_attr(sensorId, 'fail_safe_starting')) + timedelta( hours = 24 ), 0) + (3600 * state_attr(sensorId, 'number_of_sequential_hours') | float)) | timestamp_local }}
summary: >
{%- set sensorId = 'sensor.cheapest_hours_energy_boiler_night' -%}
{{ state_attr(sensorId, 'friendly_name') | string }}
target:
entity_id: calendar.electricity
# If multiple cheapest hours sequences are required, make a copy of 'calendar.create_event' block above and set the 'sensorId' values to match the new one
mode: single
# input_boolean reset
- id: 'cheapest_hours_clear_set_flag_boiler_night'
alias: 'Cheapest hours: Reset the set helper for the next day boiler night'
description: 'Clears cheapest hours helper boolean when the day changes.'
trigger:
- platform: time
at: '01:15:00'
condition: []
action:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.cheapest_hours_set_boiler_night
mode: single
# We need a helper to know if the calendar mark(s) has already been set!
input_boolean:
cheapest_hours_set_boiler_night:
name: Cheapest hours set for the next day boiler night
icon: mdi:clock |