vindaalex / multizone-thermostat

This is a home assistant custom component. It is a thermostat including various control options, such as: on-off, PID, weather controlled. The thermostat can be used in stand-alone mode or as zoned heating (master- satellites).
33 stars 6 forks source link
climate home-assistant multizone thermostat

hacs_badge

custom_components/multizone_thermostat

see also https://community.home-assistant.io/t/multizone-thermostat-incl-various-control-options

This is a home assistant custom component. It is a thermostat including various control options, such as: on-off, PID, weather controlled. The thermostat can be used in stand-alone mode or as zoned heating (master with satellites).

Note: This is only the required software to create a (zoned) thermostat. Especially zoned heating systems will affect the flow in your heating system vy closing and opening valves. Please check your heating system if modifications are requried to handle the flow variations, such as: pump settings, bypass valves etc.

Installation:

  1. Go to default /homeassistant/.homeassistant/ (it's where your configuration.yaml is)
  2. Create /custom_components/ directory if it does not already exist
  3. Clone this repository content into /custom_components/
  4. Reboot HA without any configuration using the code to install requirements
  5. Set up the multizone_thermostat and have fun

thanx to:

by borrowing and continuouing on code from:

Explanatory notes

Within this readme several abbreviations are used to describe the working and used methodolgy. Hereunder the most relevant are described.

Pulse Width Modulation (PWM)

"PWM" stands for Pulse Width Modulation. Pulse Width Modulation is a technique often used in conjunction with PID controllers to regulate the amount of power delivered to a system, such as the heating elements in each zone of your underfloor heating system.

Pulse Width Modulation (PWM) is used to adjust the amount of power delivered to an electronic device by effectively turning the heating (or cooling) on and off at a "fast" rate. The "width" of the "on" time (the pulse) is varied (modulated) to represent a specific power delivery level. When the pulse is wider (meaning the device is on for a longer period), more power is delivered to the heating element, increasing the temperature. Conversely, a narrower pulse delivers less power, reducing the temperature.

https://en.wikipedia.org/wiki/Pulse-width_modulation

proportional–integral–derivative controller (PID)

The PID controller calculates the difference between a desired setpoint (the target temperature) and the actual temperature measured by the sensors in each zone. Based on this difference (the error), and the rate of temperature change, the PID controller adjusts the PWM signal to increase or decrease the heat output, aiming to minimize the error over time and maintain a stable temperature in each zone.

The use of PWM in your underfloor heating system allows for precise control over the temperature in each zone by adjusting the duty cycle of the electrical power to the heating elements. This method is efficient and can lead to more uniform temperature control and potentially lower energy consumption, as it adjusts the heating output to the actual need in each zone.

PID controller explained:

config examples: slow low temperature underfloor heating: PID_mode: kp: 30 ki: 0.005 kd: -24000

high temperature radiator: PID_mode: kp: 80 ki: 0.09 kd: -5000

Operation modes

The multizone thermostat can operate in two modes:

Per room a thermostat needs to be configured. A thermostat can operate by either hyesteris (on-off mode) or proportional mode (weather compensation and PID mode). The PID and weather compensation can be combined or one of both can be used. Only a satellite operating in proportional mode can be used as satellite as hysteris operation (on-off by a dT) cannot run in synchronised mode with other satellites and the master.

When a master controller is included it will coordinate for all enlisted satellites the valve opening and closures. When the master hvac mode is heat or cool it will trigger the satellites to update their controller and from that moment it interacts with the master. A satellite interaction with the master will be updated when the master is activated or switched off. When the master is activated to heat or cool, the controller routines of all satellites are synced to the master controller. When the master is switched off the satellite will return to their stand-alone mode with individual settings. The master itself receives the satellite state (PWM signal) and return the moment the satellite has to open or close valves. The master determines the moment when the satellite valves is opened, the satellite itself still determines the valve opening time.

Examples

See the examples folder for examples. The '\examples\multizone thermostat - explained.yaml' shows an worked-out multizone example including explanation. The '\examples\single thermostat - on_off.yaml' shows an worked-out single operating hysteris thermostat with explanation.

Room thermostat configuration (not for master config)

This thermostat is used for satellite or stand-alone operation mode. The thermostat can be configured for a wide variation of hardware specifications and options:

Thermostat configuration

sensors (at least one sensor needs to be specified):

checks for sensor and switch:

recovery of settings

HVAC modes: heat or cool (sub entity config)

The control is specified per hvac mode (heat, cool). At least 1 to be included. EAch HVAC mode should include one of the control modes: on-off, proportional or master.

Generic HVAC mode setting:

on-off mode (Optional) (sub of hvac mode)

The thermostat will switch on or off depending the setpoint and specified hysteris. Configured under 'on_off_mode:' with the data (as sub of 'on_off_mode:'):

proportional mode (Optional) (sub of hvac mode)

Configured under 'proportional_mode:' Two control modes are included to control the proportional thermostat. A single one can be specfied or combined. The control output of both are summed.

The proportional controller is called periodically and specified by control_interval. If no PWM interval is defined, it will set the state of "heater" from 0 to "PWM_scale" value as for a proportional valve. Else, when "PWM_duration" is specified it will operate in on-off mode and will switch proportionally with the PWM signal.

PID controller (Optional) (sub of proportional mode)

PID controller. Configured under 'PID_mode:' error = setpoint - room temp output = error Kp + sum(error dT) Ki + error / dT Kd

heat mode: Kp & Ki positive, Kd negative cool mode: Kp & Ki negative, Kd positive

with the data (as sub):

Weather compensating controller (Optional) (sub of proportional mode)

Weather compensation controller. Configured under 'weather_mode:' error = setpoint - outdoor_temp output = error * ka + kb

heat mode: ka positive, kb negative cool mode: ka negitive, kb positive

with the data (as sub):

Master configuration

The configuration scheme is similar as for a satellite only with the following differences.

HVAC modes: heat or cool (sub entity config)

The control is specified per hvac mode (heat, cool). At least 1 to be included. EAch HVAC mode should include one of the control modes: on-off, proportional or master.

Generic HVAC mode setting: For master mode not applicable:

on-off mode (Optional) (sub of hvac mode)

For master mode not applicable

proportional mode (Optional) (sub of hvac mode)

For master mode not applicable

Master configuration (Required) (sub of hvac mode)

Specify the control of the satellites. Configured under 'master_mode:'

Referenced thermostats (satellites) will be linked to this controller. The heat or cool requirement will be read from the satellites and are processed to determine master valve opening and adjust timing of satellite openings.

The master will check satellite states and group them in on-off and proportional valves. The govering group will define the opening time of the master valve.

The preset mode changes on the master will be synced to the satellites.

The master can operate in 'minimal_on', 'balanced' or 'continuous' mode. This will determine the satellite timing scheduling. For the minimal_on mode the master valve is opened as short as possible, for balanced mode the opening time is balanced between heating power and duration and for continuous mode the valve opening time is extended as long as possible. All satellite valves operating as on-off switch are used for the nesting are scheduled in time to get a balanced heat requirement. In 'continuous' mode the satellite timing is scheduled aimed such that a continuous heat requirement is created. The master valve will be opened continuous when sufficient heat is needed. In low demand conditions an on-off mode is maintained.

The controller is called periodically and specified by control_interval. If no PWM interval is defined, it will set the state of "heater" from 0 to "PWM_scale" value as for a proportional valve. Else, when PWM is specified it will operate in on-off mode and will switch proportionally with the PWM signal.

with the data (as sub):

Sensor filter (filter_mode):

An unscented kalman filter is present to smoothen the temperature readings in case of of irregular updates. This could be the case for battery operated temperature sensors such as zigbee devices. This can be usefull in case of PID controller where derivative is controlled (speed of temperature change). The filter intesity is defined by a factor between 0 to 5 (integer). 0 = no filter 5 = max smoothing

DEBUGGING:

debugging is possible by enabling logger in configuration with following configuration

logger:
  default: info
  logs:
    multizone_thermostat: debug

Services callable from HA:

Several services are included to change the active configuration of a satellite or master.

set_mid_diff:

Change the 'minimal_diff'

set_preset_mode:

Change the 'preset'

set_pid:

Change the current kp, ki, kd values of the PID or Valve PID controller

set_integral:

Change the PID integral value contribution

set_ka_kb:

Change the ka and kb for the weather controller

set_filter_mode:

change the UKF filter level for the temperature sensor

detailed_output:

Control the attribute output for PID-, WC-contributions and control output