r/smarthome • u/Bartakos • 3h ago
Home Assistant Added a bit of smart to my District Heating in a Dutch rental apartment
So, I live in a rental apartment in the Netherlands. The apartment has District heating with a heat exchanger, the heat exchanger was controlled by a central on/off thermostat, which lives in the same room as one radiator without thermostat valve. Needless to say that that is far from ideal, even though the other radiators had simple thermostatic valves, they would do nothing when the central thermostat didn't call for for heat. I needed this to be smarter and be able to control the system per radiator/room. I started with replacing the dumb thermostatic valves with Smart TRV's (Sonoff TRV-ZBT) and it was already a bit better, but still dependent on the central thermostat and the heat sensors in the TRV's did not really represent the true room temperature, so I added external temperature sensors (Sonoff SNZB-02B). Nice!! But still the central thermostat was in charge, so temperatures in the other rooms lacked most of the time.
At some point I thought, OH! Lets get a smart thermostat, dumbest thought ever, because it would still do the same thing. send on/off to the heat exchanger. When I figured that out I came up with the idea to find a smart on/off relais and make that switch on/off depending on heat demand per room/trv/sensor. I found one of those (sorry again Sonoff, a Mini-ZBD dry contact relais).
This is what it looks in terms of hardware and scheme:

Most important part was leaving the original system in place since this is a rental apartment, so all works in parallel with the original system. The original thermostat is set to 18, the room stays cozy because of the other rooms are providing the heat.
Now this all needed to be connected, working together in a smarter way. A custom template and two automations needed to be created and a bit of tweaking on the reporting settings and disabling smart control on the TRV's in Z2M settings, and creating scheduled setpoints (and changes) for every day of the week.
One automation for syncing the measured temperatures from the external sensors to the TRV's:
alias: Sync External Temp to Sonoff TRV-ZBT (All Rooms)
triggers:
- trigger: state
entity_id:
- sensor.clima_achterkamer_temperature
- sensor.clima_keuken_temperature
- sensor.clima_slaapkamer_3_temperature
- trigger: state
entity_id:
- select.trv_achterkamer_temperature_sensor_select
- select.trv_keuken_temperature_sensor_select
- select.trv_slaapkamer_temperature_sensor_select
to: remote_source_offline
- trigger: time_pattern
minutes: /30
actions:
- repeat:
for_each:
- sensor: sensor.clima_achterkamer_temperature
select: select.trv_achterkamer_temperature_sensor_select
number: number.trv_achterkamer_external_temperature_input
- sensor: sensor.clima_keuken_temperature
select: select.trv_keuken_temperature_sensor_select
number: number.trv_keuken_external_temperature_input
- sensor: sensor.clima_slaapkamer_3_temperature
select: select.trv_slaapkamer_temperature_sensor_select
number: number.trv_slaapkamer_external_temperature_input
sequence:
- if:
- condition: template
value_template: '{{ states(repeat.item.sensor) | is_number }}'
then:
- action: select.select_option
target:
entity_id: '{{ repeat.item.select }}'
data:
option: remote_temperature
- action: number.set_value
target:
entity_id: '{{ repeat.item.number }}'
data:
value: '{{ states(repeat.item.sensor) | float | round(1) }}'
- delay:
seconds: 2
mode: single
Another automation to actually respond to the heat demand from the TRV's and change the relais state:
alias: 'Stadsverwarming: AquaHeat op TRV-warmtevraag'
description: Stuurt de AquaHeat via het potentiaalvrije Sonoff-relais
triggers:
- trigger: state
entity_id: binary_sensor.centrale_warmtevraag
to:
- 'on'
- 'off'
- trigger: homeassistant
event: start
actions:
- choose:
- conditions:
- condition: state
entity_id: binary_sensor.centrale_warmtevraag
state: 'on'
sequence:
- delay:
seconds: 45
- condition: state
entity_id: binary_sensor.centrale_warmtevraag
state: 'on'
- action: switch.turn_on
target:
entity_id: switch.aquaheat_relais
data: {}
- conditions:
- condition: state
entity_id: binary_sensor.centrale_warmtevraag
state: 'off'
sequence:
- delay:
minutes: 3
- condition: state
entity_id: binary_sensor.centrale_warmtevraag
state: 'off'
- action: switch.turn_off
target:
entity_id: switch.aquaheat_relais
data: {}
default:
- action: switch.turn_off
target:
entity_id: switch.aquaheat_relais
mode: single
And a template for a binary sensor to glue it all together:
- binary_sensor:
- name: "Centrale Warmtevraag"
unique_id: centrale_warmtevraag_trvs
device_class: heat
availability: >
{{
expand(
'climate.trv_achterkamer',
'climate.trv_keuken',
'climate.trv_slaapkamer'
)
| rejectattr('state', 'in', ['unavailable', 'unknown'])
| list
| count > 0
}}
state: >
{{
expand(
'climate.trv_achterkamer',
'climate.trv_keuken',
'climate.trv_slaapkamer'
)
| rejectattr('state', 'in', ['unavailable', 'unknown'])
| selectattr('attributes.hvac_action', 'defined')
| selectattr('attributes.hvac_action', 'eq', 'heating')
| list
| count > 0
}}
Now what actually happens is that, if either one of the TRV's is receiving temperatures that are 0.4 degrees Celcius below the current setpoint (from the schedules), it opens up its valve, and the HA automation switches the relais to on and the Aquaheat heat exchanger turns on. Because the central room has a dumb valve that is open, there are no hydraulic restrictions for the heat demanding room to start heating.
The delays in the relay automation prevent brief changes in TRV heat demand from immediately switching the district-heating supply, reducing unnecessary cycling.
System has been dry running for about a week and needed tweaks, but I created a small dashboard to control what is happening (sorry in Dutch):

Action just took place. Early morning, 5.30, setpoints changed from 19 to 20 and automation started, after 45 seconds the relais switches to on:

Put all components in line yesterday and all seems to be working flawlessly since. Future will tell whether there are still remaining issues. I had some issues in my Z2M mesh, but those seem to be solved with some tweaks, replacing controller and changing reporting intervals. The dumb room, my living room, stays up to a nice temperature and that is good because that is were I am most of the time. Fun part is, I am an audiophile, and whenever my amplifiers are turned on in the back room, my listening and plant room, the TRV shuts down after 10-ish minutes because the amplifiers start heating the room :-)
I hope this is useful for others, it was an interesting journey, and I had some great help from my friend Copi!
And please shoot holes in the design. Winter is just starting here, and I'd rather discover a failure mode from a Reddit comment than during the first properly cold week. :-)
Added after initial post:
This is what it looks like in terms of installation:

