The aim of this automation is to have the boiler heat only on solar energy.
I get information on grid consumption/injection from the Homewizard P1 meter, use this info to drive a Shelly dimmer, that drives a Proportional Solid State Relays, that controls the power of the boiler.
When the sun is down, no calculations or triggering are needed, this saves processing power.
Also I want the mechanical relays of the Shelly dimmer to switch on or off, when the dimmer is at 0% brightness, because this will prolong the lifetime of the Shelly relays.
The power of the electrical boiler is 1600W, when solar injection to the grid is higher than 1700 W, the dimmer should be set to brightness_pct 100, to deliver maximum power to the boiler.
# configuration for boiler dimmer
# This configuration.yaml entry creates a new entity, based on the P1 meter power reading
# The value is 1 when there is no injection or when electricity is taken from the grid
# The boiler takes 1600W (LoadNominalPower) when it is on, so to calculate it as a percentage,
# the value needs to be divided by 100, therefore, in the raw value you see a division by 16.
# The Shelly dimmer produces a voltage according to the value of the light on attribute
# brightness_pct, so in the automation, I write the value of tp_pct into the dimmer.
# To avoid that the Shelly relais switches a lot, when injection is around zero, the minimum
# value of tp_pct is 1, because with a value of 0, the light is switched off by the relais.
# The max value is limited to 100, if there is more injection than what the boiler takes,
# the dimmer and SSR are set to deliver maximum power (brightness_pct = 100)
# To compensate for the fact that the SSR does not react to low voltages on its 0-10 V
# input, I add an offset of 5 to the value of tp_pct
template:
- sensor:
- name: "tp_pct"
unit_of_measurement: "%"
state: >-
{% set LoadNominalPower = 1600 %}
{% set NomPowerPCT = LoadNominalPower / 100 %}
{% set Offset = 5 %}
{% set raw_value = ((states('sensor.shelly0110dimg3_8cbfeaa72794_light_0_power') | float(0))
+ Offset + (states('sensor.p1_meter_active_power') | float(0)) * -1) / NomPowerPCT %}
{{ raw_value | round(0) | int if 1 <= raw_value <= 100 else 1 if raw_value < 1 else 100 }}
To visualize this entity, I created a gauche card on the dashboard.
Now we need an automation to drive the Shelly dimmer.
I created an automation via the Settings/Automations&scenes GUI, and than edited the automation in YAML, because the GUI does not support driving the Shelly dimmer.
The automation starts when the value of the sensor tp_pct changes, and also when the sun goes below the horizon.
In the morning, when the solar panels start producing more power then what the house consumes, the value of tp_pct starts to change, and that value is written to the dimmer that drives the SSR.
When the sun goes below the horizon, the dimmer is set to the minimum value, to avoid that the Shelly relays switches under load conditions, this to prolong the lifetime of this relays. After a delay of 1 minute, the command light.turn_off is sent to the dimmer.
alias: adjust Shelly dimmer according to solar production
description: ""
triggers:
- entity_id: sun.sun
from: above_horizon
to: below_horizon
trigger: state
- entity_id: sensor.tp_pct
trigger: state
actions:
- choose:
- conditions:
- condition: state
entity_id: sun.sun
state: above_horizon
sequence:
- target:
entity_id: light.shelly0110dimg3_8cbfeaa72794_light_0
data:
brightness_pct: "{{ states('sensor.tp_pct') | int(0) }}"
action: light.turn_on
- conditions:
- condition: state
entity_id: sun.sun
state: below_horizon
sequence:
- target:
entity_id: light.shelly0110dimg3_8cbfeaa72794_light_0
data:
brightness_pct: 0
action: light.turn_on
- delay: "00:01:00"
- target:
entity_id: light.shelly0110dimg3_8cbfeaa72794_light_0
action: light.turn_off
data: {}
mode: restart
To monitor what is happening during the day, when solar production and home consumption continuously changes, I created some gauge cards on my Home Assistant dashboard.
I also connected a lamp to really see how the Shelly dimmer regulates the power of the SSR (see pictures below)