With the following automation, I can switch on my electric hot water heater when the forecast for solar generation is good. As soon as the forecast becomes bad, the heating is switched off. That works fine too.
Now I would like to add that the heating is also switched off if my battery level has dropped by 5% since the heating was switched on. The battery level sensor is sensor.envoy_122206102883_total_battery_percentage
Here is the code so far:
alias: Warmwasserheizung steuern
description: ""
trigger:
- platform: numeric_state
entity_id: sensor.solar_prognose_verbrauchersteuerung
for:
hours: 0
minutes: 1
seconds: 0
above: 27000
id: Warmwasserheizung Auslöser zum Einschalten
- platform: numeric_state
entity_id: sensor.solar_prognose_verbrauchersteuerung
for:
hours: 0
minutes: 1
seconds: 0
below: 25000
id: Warmwasserheizung Auslöser Solarfaktor zum Ausschalten
- platform: state
entity_id:
- sensor.solar_prognose_verbrauchersteuerung
to: unavailable
for:
hours: 0
minutes: 5
seconds: 0
id: Warmwasserheizung Auslöser Nicht verfügbar zum Ausschalten
- platform: state
entity_id:
- sensor.solar_prognose_verbrauchersteuerung
to: unknown
for:
hours: 0
minutes: 5
seconds: 0
id: Warmwasserheizung Auslöser Unbekannt zum Ausschalten
condition: []
action:
- if:
- condition: or
conditions:
- condition: trigger
id: Warmwasserheizung Auslöser Solarfaktor zum Ausschalten
- condition: trigger
id: Warmwasserheizung Auslöser Nicht verfügbar zum Ausschalten
- condition: trigger
id: Warmwasserheizung Auslöser Unbekannt zum Ausschalten
then:
- type: turn_off
device_id: 990c1fa02f5750c74695320f637ed36c
entity_id: switch.warmwasser_heizung_ss00_blau_tz3000_gjnozsaz_ts011f_switch_2
domain: switch
- if:
- condition: trigger
id: Warmwasserheizung Auslöser zum Einschalten
then:
- type: turn_on
device_id: 990c1fa02f5750c74695320f637ed36c
entity_id: switch.warmwasser_heizung_ss00_blau_tz3000_gjnozsaz_ts011f_switch_2
domain: switch
mode: single
Adjust the value of timeout to whatever makes sense for your application (it should be longer than the time it normally takes the battery level to decrease by 5%).
In principle, the hot water heating should only be operated if the self-produced electricity would otherwise be fed into the grid.
I generally achieve this via the yield forecast. While the hot water heater is running, there should generally not be any consumption from the battery, as it is also being charged (unless it is already full).
That’s why it was important to me that the battery level shouldn’t drop during the heating period.
I just want to build in some safety because sometimes the forecast is pretty wrong.
If I understand the timeout correctly, after the set time has elapsed, it turns off the heating anyway. So I could set this to 10 hours, for example, because the sun doesn’t usually shine for longer than that.
If you want it to behave like that, change the value of continue_on_timeout to true.
timeout is a time limit for the wait_template. Instead of allowing wait_template to wait forever, it sets a limit. If it reaches the limit, the next decision is should it continue executing any other actions or should it stop immediately. That’s what continue_on_timeout determines.
In addition, changing mode to restart allows the automation to be triggered while it’s busy waiting for the wait_template. In other words, it ceases waiting immediately and proceeds to act on the trigger event.
If I only want the shutdown if the battery level has dropped by at least 5% for at least 2 minutes since the heater was switched on. Then what would I have to do?
The aim is to operate the heating system using only solar energy. Not or only very slightly from the battery.
Create the following Trigger-based Template Sensor:
template:
- trigger:
- platform: state
entity_id: switch.warmwasser_heizung_ss00_blau_tz3000_gjnozsaz_ts011f_switch_2
from: 'off'
to: 'on'
sensor:
- name: Solar Battery Threshold
state: >
{% set battery_level = states('sensor.envoy_122206102883_total_battery_percentage') | float(0) %}
{{ battery_level - (battery_level * 0.05) }}
Initially, it will report unknown but that will change when it’s triggered for the first time. It’s triggered whenever the switch changes from off to on. When the switch is turned on, this Template Sensor will report a value that’s 5% less than the current battery level.
Create the following automation. Instead of a wait_template it uses a wait_for_trigger.
The wait_for_trigger will trigger only when the value of:
Thanks so much.
I’ll install and test it tomorrow because I have to go first.
I add the trigger-based template sensor to the configuration.yaml ? Correct?