# Multi-zone boiler and TRV control with Home Assistant, OpenTherm and node-red-contrib-pid

**URL:** <https://discourse.nodered.org/t/multi-zone-boiler-and-trv-control-with-home-assistant-opentherm-and-node-red-contrib-pid/102269>\
**Category:** Share Your Projects\
**Tags:** home-assistant\
**Created:** [27 November 2026 08:47 UTC](https://discourse.nodered.org/t/multi-zone-boiler-and-trv-control-with-home-assistant-opentherm-and-node-red-contrib-pid/102269 "2026-11-27T08:47:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![avk999](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/avk999/32/84348_2.png) [@avk999](https://discourse.nodered.org/u/avk999)\
**Post date:** [27 November 2026 08:47 UTC](https://discourse.nodered.org/t/multi-zone-boiler-and-trv-control-with-home-assistant-opentherm-and-node-red-contrib-pid/102269/1 "2026-11-27T08:47:29Z")

</div>

I have published the Node-RED flows that heat our house: [GitHub - avk999/heating-control: Node-RED boiler (OpenTherm/OTGW) and TRV heating control for Home Assistant · GitHub](https://github.com/avk999/heating-control)

**What it does.** One gas boiler (OpenTherm, through an OpenTherm Gateway) and five battery-powered radiator valves (TRVs), five rooms, each with a virtual thermostat in Home Assistant. Node-RED decides the boiler flow temperature and every TRV setpoint, and exports its internal state to Prometheus for a Grafana dashboard and alerts. It has run since October 2026.

**How it works.**

- Boiler loop, every 15 s: the room with the largest deficit leads; its error feeds node-red-contrib-pid, and the output is mapped to a 20 to 75 C flow temperature on a convex curve and written as the OpenTherm control setpoint.
- TRV loop: a PI controller per room on the room sensor writes the TRV setpoint. The TRV's own sensor is never used for control.
- When the leading room's mode or target changes, or a room warms by 2 K in 30 min from the sun or a fireplace, the PID integral is corrected by that step through `msg.integral`, so the loop does not spend hours unwinding stale history.
- Schedules with cron-plus, radar presence and a door contact; dead-sensor detection; an off switch that hands the boiler back to the wall thermostat and opens every valve.

**Things measured on the way that may save someone time.**

- TRV sensors next to the radiator are off by an amount that swings about 3 K with valve state, so no calibration offset works. Control on a room sensor instead.
- Derivative made things worse: room sensors report in 0.1 K steps and D turned them into command spikes. Lowering the proportional band fixed both the slow start and the overshoot.
- Deduplicate TRV writes against the setpoint the valve reports, not against the last value sent. A valve that silently reverted was left alone for 9.9 h the other way.
- Zero error does not mean zero output. Skipping the PID when no room wanted heat switched the boiler about 300 times a day in simulation.
- A `generic_thermostat` stays available when its source sensor dies; set `expire_after` on MQTT sensors.
- `node.error(text)` without the msg argument never reaches a Catch node.

The repo has both flows, the dashboard, example HA configuration, the alert rules, a user guide with every tunable, and a document with the measurements behind each decision.

**Thanks** to @Colin for node-red-contrib-pid, and for reviewing and merging the runtime integral setting (2.1.0) this depends on; to Schelte Bron for the OpenTherm Gateway; to Robert van den Breemen for OTGW-firmware; and to the authors of node-red-contrib-home-assistant-websocket, node-red-contrib-cron-plus and node-red-contrib-prometheus-exporter.

Comments and questions welcome.

 ![gr1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/a/6a0db7289052bba5f0f567271f4b5c8c0c581c3d.png)
