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.
by borrowing and continuouing on code from:
Within this readme several abbreviations are used to describe the working and used methodolgy. Hereunder the most relevant are described.
"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
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
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.
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.
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:
sensors (at least one sensor needs to be specified):
sensor (Optional): entity_id of the temperature sensor, sensor.state must be temperature (float). Not required when running in weather compensation only.
filter_mode (Optional): unscented kalman filter can be used to smoothen the temperature sensor readings. Especially usefull in case of irregular sensor updates such as battery operated devices (for instance battery operated zigbee sensor). Default = 0 (off) (see section 'sensor filter' for more details)
sensor_out (Optional): entity_id for a outdoor temperature sensor, sensor_out.state must be temperature (float). Only required when running weather mode. No filtering possible.
initial_hvac_mode (Optional): Set the initial operation mode. Valid values are 'off', 'cool' or 'heat'. Default = off
initial_preset_mode (Optional): Set the default mode. Default is normal operational mode. Allowed alternative is any in 'extra_presets'. The 'inital_preset_mode' needs to be present in the 'extra_presets' of the 'initial_hvac_mode'
precision (Optional): specifiy setpoint precision: 0.1, 0.5 or 1
detailed_output (Optional): include detailed control output including PID contributions and sub-control (PWM) output. To include detailed output use 'True'. Use this option limited for debugging and tuning only as it increases the database size. Default = False
checks for sensor and switch:
recovery of settings
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:
entity_id (Required): This can be an on-off switch or a proportional valve(input_number, etc)
switch_mode (Optional): Specify if switch (valve) is normally closed 'NC' or normally open 'NO'. Default = 'NC'
min_target_temp (Optional): Lower limit temperature setpoint. Default heat=14, cool=20
max_target_temp (Optional): Upper limit temperature setpoint. Default for heat=24, cool=35
initial_target_temp (Optional): Initial setpoint at start. Default for heat=19, cool=28
extra_presets (Optional): A list of custom presets. Needs to be in to form of a list of name and value. Defining 'extra_presets' will make away preset available. default no preset mode available.
passive_switch_duration (Optional): specifiy per switch the maximum time before forcing toggle to avoid jammed valve. Specify a time period. Default is not activated.
passive_switch_opening_time (Optional): specify the minium opening time of valve when running passive switch operation. Specify a time period. Default 1 minute.
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:'):
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.
bounded_scale_to_master(Optional): scale proporitional valves with the master's PWM. 'bounded_scale_to_master' defines the scale limit. For example:
Default = 1 (no scaling)
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 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):
The configuration scheme is similar as for a satellite only with the following differences.
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:
For master mode not applicable
For master mode not applicable
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):
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 is possible by enabling logger in configuration with following configuration
logger:
default: info
logs:
multizone_thermostat: debug
Several services are included to change the active configuration of a satellite or master.
Change the 'minimal_diff'
Change the 'preset'
Change the current kp, ki, kd values of the PID or Valve PID controller
Change the PID integral value contribution
Change the ka and kb for the weather controller
change the UKF filter level for the temperature sensor
Control the attribute output for PID-, WC-contributions and control output