Smart Virtual Thermostat with PID python plugin for Domoticz home automation system
Inspired by SmartVirtualThermostat https://www.domoticz.com/wiki/Plugins/Smart_Virtual_Thermostat.html
An internal temperature sensor is used to control a smart thermostatic radiator valve. using a PID regulator.
Possible control modes:
- changing a TRV set point temperature
- changing an internal TRV temperature sensor value adjustment (not tested)
- replacing an internal TRV temperature sensor values by an additional sensor value (not implemented)
Current code was tested with Danfoss Living Connect Z-Wave (014G0013) and Xiaomi Mi ZigBee Temperature and Humidity Sensor WSDCG6Q01LM
Plugin creates a new device
Example of timers. Pause is applied once a week for 10 minutes to close a valve regularly.
Example of plugin settings
List of all temperature sensors installed in the controlled room. An average is caluclated.
Example: 4,5
List of all open window sensors installed in the controlled room.
Example: 6
List of all TRV installed in the controlled room.
Example: 9,11
- High - temperature (in C) during a day
- Low - temperature (in C) during a night
- Pause - temperature (in C) used when windows are open or during Pause mode (antifreeze)
- TRV Prec - precision of valve set point (in C) - this parameter prevent too frequent changes and adds kind of histeresis
- Sensor Prec - precision of sensor (in C) - this parameter adds histeresis when sensor temperature is near the target
- Max shift - highest accepted difference between set point and target temperatur (High/Low)
Example: 21.0,20.0,5.0,0.5,0.1,3.0
- Calc. interval - time between calculation of PID shift
- Pause On delay - time between opening a window and virtual thermostat switching to Pause mode
- Pause Off delay - time between closing a window and virtual thermostat switching to previous mode (Normal/Economic)
- Sensor Timeout - when temperature sensors are not responding - virtual thermostat will use only an internal TRV temperature sensor (not implemented)
Example: 3,1,10,90
- Kp - proportional factor
- Ki - integral factor
- Kd - differential factor
- Debug - 1/0 debug logging on/off
- E - shift calculation mode: 1 - PID, 2 - simple delta
- C - TRV Control mode - 1 - set point, 2 - internal TRV sensor temperature value adjustment, 3 - internal TRV sensor temperature value replacement
Example: 0.9,0.1,0.2,0,1,1
- Off - virtual thermostat is not controlling TRV devices
- Normal - control TRV to achive defined higher temperture
- Economy - control TRV to achive defined lower temperture
- Pause - sets on all TRVs antifreeze temperture
- 3x Off - reload internal values from user variable - after first "Off" update user variable (i.e. "Integral")
- 3x Pause - restore default internal values
- open window pause
- TRV control modes 2 and 3
- Sensor Timeout
- Multiple temperature sensors - min/max/avg mode - currently only avg