Skip to content

Smart solar water heating using Home Assistant

Hanoh Haim edited this page Dec 29, 2021 · 8 revisions

This page will guide you how to convert your old solar water heater into a smart one.

Features

  1. Monitor the water temperature

  2. Turn on the electric heater automatically

  3. Notify in case of a solar panels issue or a heater issue (effectiveness issue)

  4. Indirectly saves water consumption.

Dashboard

600
Figure 1. dashboard

How it works

In Israel it is common to find solar water heater (this project could with a small changes on electrical heater too)

58248489 f0b36100 7d64 11e9 9291 336f812fbb7b
Figure 2. solar water heater

In this system, there is a place to put a mechanical thermostat. The objective of this device is to identify that the heater was left opened and to turn it off so the boiler won’t blowe due to heat.

58248789 c57d4180 7d65 11e9 8fd8 576844f0f404
Figure 3. mechanical thermostat

It is located at the bottom of the boiler (see #1)

Using this project we will convert this mechanical thermostat to a digital temperature monitor while keeping the mechanical thermostat (in case of a bug in the software)

150
Figure 4. thermostat is located in #1

Ingredients

  1. HA

  2. Appdaemon

  3. Sonoff TH16 with DS18B20 sensor

150
Figure 5. Sonoff TH16

Hardware installation

  1. You should have wifi signals near your boiler

  2. TH16 + DS18 should be connected to the boiler power input (before the thermostat) the DS18 should be inserted into the thermostat (it is not simple to keep them both due to the cable, but it is possible if you replace the cable to a smaller cable)

  3. Keep the main power always on (it will power the TH16). Now HASS will take charge of things (don’t worry, it is a good thing)

Tasmota firmware configuration (failsafe)

This configuration should be done once. The rules make sure the boiler failsafe. E.g. in case of a network issue or mqtt/HA restart/stuck it will turn off automatically

Tasmota configuration (once)
Rule1 on Power1#state==1 do  RuleTimer1 7200 endon on Rules#Timer=1 do power off endon on Power1#state==0 do  RuleTimer1 off endon
Rule1 on
poweronstate 0
TelePeriod 60
SetOption36 20

Another better alternative is to use pulseTime tasmota command (without complex rules)

Tasmota configuration (once)
poweronstate 0
TelePeriod 60
SetOption36 20
pulsetime 7200

Install HA custom component

Copy this project <config directory>/custom_components/ folder to your <config directory> directory make sure you are in sync with the the right version of hass (see above) after you copy the data you should reboot/restart HA

HA Configuration

The switch configuration

Switch
switch:

  - platform: tasmota
    name: b0
    stopic: b0

It is important to use the custom component (tasmota) see discussion here

The sensors

sensor:

  - platform: mqtt
    name: "btemp0"
    state_topic: "tele/b0/SENSOR"
    value_template: "{{value_json['DS18B20'].Temperature }}"
    qos: 1
    unit_of_measurement : "C"

  - platform: statistics
    entity_id: sensor.btemp0
    max_age:
      minutes: 600

  - platform: accumulator
    name: boiler_total_hours2
    entity_id: switch.b0
    state_on: 'on'
    state_off: 'off'

full configuration can be found here boiler

AppDaemon app

When the app is enabled, the algorithm works as follow.

  1. If the water temperature is lower than user-min and UV index is lower than 1 ( no sun right now) turn on the heater

  2. If the water temperature is higher than user-max stop the heater.

  3. Calculate some variables - for Grafana chars

  4. watchdog the time the switch is opened

In simple words keep the water always hot. In case there is a Sunlight let the Sun heat it (UV index is higher than 1)

Note
I found that the energy waste is negligible beacuse the heat is saved. Only when you are going to vacation it is better to disable the app.
boiler_timer_off:
  module: heat_app
  class: SimpleTimerOff
  input_start: switch.b0
  input_time:  input_number.boiler_timer_time
  switchs : [switch.b0]

boiler_automation:
  module: heat_app
  class: CBoilerAutomation
  switch: switch.b0 #input . switch on/off
  temp: sensor.btemp0 # input: temp sensor
  input_automation: input_boolean.boiler_auto_enable # input: GUI enable/disable
  input_temp_min:   input_number.boiler_temp_min # input: GUI tune
  input_temp_max:   input_number.boiler_temp_max # input: GUI tune
  sensor_eff_power: variable.boiler_eff_power0 # # output: variable to calc effectiveness
  sensor_eff_solar:  variable.boiler_eff_solar0 # output: variable to calc effectiveness
  input_uv:  sensor.dark_sky_uv_index # input: UV index

Tunning

I found that turning it to minimum (input min/max) save a lot of water. The reason is that one of my sons loves to shower and he consumes all the hot water he could. So tuning it high value means very long showers. Keeping it low indirectly tune the maximum time of the shower 😄

I wish I could have a mechical water switch that could switch the hot water with icy cold water.

Grafana

temperature, heat effectiveness

700
Figure 6. temperature/speed of heating (solar/electric)

The yellow stands for the speed the water is heating up. in case this number is dropping it means that the effectiveness of the solar panels or heater is going down.

700

Total power (kw/h) per day

58251613 b5b52b80 7d6c 11e9 9ac0 188bf941380f
Figure 7. kwh per day

The b stand for kwh for the boiler based on the hours the switch was working.

500
Figure 8. query

notes: It wasn’t possible to use the integral of the switch.on.off due to a bug in InfluxDb, So I’ve used diff function on the accumulation that works.

see this defect integral does not work