Friday, December 30, 2022

Quest for lower electricity consumption - OpenTherm

The first article ends by the need to get more data from boiler because it heats warm water too often.

The first step I did was actually disabling circulating warm water every 15 minutes which I used to have always warm water immediately instead of waiting until it reaches a tap. Surprisingly, I observe almost no difference. There is still quite warm water immediately in the tap but the boiler heats water with the same frequency...

My home heating setup consists of two main heating branches - one with central heating (additionally split to radiators and floor heating) and the second with external tank for warm water. For some reason there is no three-way valve to stop flowing water to external tank when running in central heating mode. I suspect this is the culprit why boiler heats external tank approximately every two hours. To confirm it, I need data about what mode the boiler runs (although it can be guessed from the power consumption) and temperature in the external tank which triggers its heating. All can be retrieved via OpenTherm protocol.

OpenTherm standard is designed for communication between boiler and thermostat. Mine boiler - Thermona Therm EL 9 - does support it.

Googling how to get data from OpenTherm resulted in several links:

  1. https://www.home-assistant.io/integrations/opentherm_gw/
    Hurray - there is a way how to get data to Home Assistant!
  2. http://otgw.tclcode.com/ - the gateway. Unfortunately, it looks quite complex...
  3. https://github.com/jpraus/arduino-opentherm - library for Arduino by Jiří Praus with his HW looks much easier to use and I went for this option.
  4. Only later I have found out it would be enough to use https://ihormelnyk.com/opentherm_adapter (because I don't need to communicate with thermostat).
I have ordered OpenTherm Gateway Arduino Shield. I struggled to find 24V power supply, even wrote to Jiří who quickly suggested GME but eventually I've ordered it from Tipa. Soldering it together was a challenge as I have soldered only big electronic parts till now. Because of my "huge" experiences, I've managed to solder headers upside down so I need to use wires to connect it to Arduino Uno for testing.

Eventually, I was able to put everything together and test the hardware, interfaces and self-test. All tests have passed. The only issue/difference I saw was in step 6 where I measured ~4.7V instead of 5-7V.

Here is the wiring because it was not obvious for me; pin constants in code are the same:
  • OpenTherm jumper set to 5V
  • OpenTherm D3 - Uno D3 (via header) : #define BOILER_IN 3
  • OpenTherm D5 - Uno D5 (via header) : #define BOILER_OUT 5
  • OpenTherm 5V - Uno 5V
  • OpenTherm GND - Uno GND

Having wired the OpenThem shield with Arduino, next step was to get data from boiler using sample code. The code uses arduino-opentherm library which needs to be put into Arduino IDE Sketchbook library folder (e.g. C:\Users\{username}\Documents\Arduino\libraries\arduino-opentherm on Windows).


It worked! Going through OpenThem 2.2 specification, I've identified useful messages for my boiler:
  • OT_MSGID_STATUS - boiler's status (what does it heat)
  • OT_MSGID_FAULT_FLAGS - current fault code
  • OT_MSGID_MODULATION_LEVEL - boiler's power (0-100%)
  • OT_MSGID_CH_WATER_PRESSURE - boiler's water pressure
  • OT_MSGID_FEED_TEMP - boiler's water temperature
  • OT_MSGID_DHW_TEMP - warm tank's water temperature
  • OT_MSGID_OUTSIDE_TEMP - outside temperature (for equithermal regulation)
  • OT_MSGID_DHW_SETPOINT - target water tank temperature
Next step is to switch from Arduino Uno to WeMos D1 so I can send the data wirelessly to my Home Assistant.

Thursday, December 29, 2022

Quest for lower electricity consumption - Measurement

With electricity prices skyrocketing this year, I've started looking into ways how to save some money by lowering electricity consumption. The first step is of course measurement!

I use Shelly Plus 2PM to control my external blinds so the choice was obvious - use Shelly 3EM. To get some idea how installation looks like, I watched Shelly 3EM Installation video by Jimmy James. Based on that, I've decided I can handle it myself.

Shelly 3EM Installation
The problem was space in our electrical cabinet. Because it's not only 1 spot for the meter but another 3 for the circuit breaker and place around input wires to put clamps. Eventually, I've hacked it for the beginning and put the circuit breaker outside of the cabinet. Just to see whether the meter works fine.


It does! Of course, later I plan to make it nicer and hide the cables into the wall.

Setup Shelly 3EM In Home Assistant
Setup in Shelly web interface is easy - I just restricted access for admin, configured wifi and added Device name - I called in Main Power so it will look good in Home Assistant. Then I added the Shelly integration to my Home assistant which configured automatically all sensors. I remember small hick-up with discovering the device - you need to enter just IP address and then it will ask you for user/password (I was trying to add http://IP which does not work).


Later I have updated Shelly settings based on recommendation for generation 1 devices and set ColoT peer directly to my Home assistant IP address. It seems to me it speeds up updates in Home Assistant.


Energy Dashboard
For Energy dashboard in Home assistant, I just added all three channels/phases as Grid consumption - it nicely shows the consumption split by them.


Detailed Energy Graphs
To see detailed consumption, first I set up Total Power sensor in configuration.yaml (based on Jimmy video):

template:
    - name: Total Power
      unique_id: total_power_tmpl
      unit_of_measurement: W
      state_class: measurement
      device_class: energy
      state: >
        {% set phase1 = states('sensor.main_power_channel_a_power') | float %}
        {% set phase2 = states('sensor.main_power_channel_b_power') | float %}
        {% set phase3 = states('sensor.main_power_channel_c_power') | float %}
        {{ phase1 + phase2 + phase3 }}
And then using apexcharts-card graphs, I've set up cards showing consumption in the last hour, 6 hours, etc.

type: custom:apexcharts-card
graph_span: 1h
header:
  show: true
  title: Energy 1h
all_series_config:
  stroke_width: 1
series:
  - entity: sensor.total_power
    name: Total
    color: rgb(162, 185, 207)
  - entity: sensor.main_power_channel_a_power
    name: Phase A
    color: rgb(3, 169, 244)
  - entity: sensor.main_power_channel_b_power
    name: Phase B
    color: rgb(128, 233, 234)
  - entity: sensor.main_power_channel_c_power
    name: Phase C
    color: rgb(255, 191, 128)

The big spikes on 6h graph are when our boiler heats tank with warm water. The problem is it does it every ~2 hours even during night which is too often and thus costly…

The next part is to find out more data from the boiler.