Python Plugin: Smart Virtual Thermostat
Moderator: leecollings
-
- Posts: 37
- Joined: Wednesday 10 December 2014 21:08
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Location: Netherlands
- Contact:
Re: Python Plugin: Smart Virtual Thermostat
Hy Guys,
This week I finally where able to install this plugin and its working great, thanks logread and all other contributers!
After reading the posts I read the option to install multiple instances of this plugin. Because I'm not that guru and want to create multizone heating I'm looking for some pointers how I can do this.
Do I simply copy the plugin into an extra directory "SVT2" and then proceed as I did with the first one?
Hopefully somebody is willing to help.
Thanks again, Johnny
This week I finally where able to install this plugin and its working great, thanks logread and all other contributers!
After reading the posts I read the option to install multiple instances of this plugin. Because I'm not that guru and want to create multizone heating I'm looking for some pointers how I can do this.
Do I simply copy the plugin into an extra directory "SVT2" and then proceed as I did with the first one?
Hopefully somebody is willing to help.
Thanks again, Johnny
Raspi 3B+; Razberry zwave; zigbee; lots and lots of sensors
-
- Posts: 63
- Joined: Thursday 04 February 2016 20:18
- Target OS: -
- Domoticz version:
- Contact:
Re: Python Plugin: Smart Virtual Thermostat
Hi Johnnie,johnnie wrote:Hy Guys,
This week I finally where able to install this plugin and its working great, thanks logread and all other contributers!
After reading the posts I read the option to install multiple instances of this plugin. Because I'm not that guru and want to create multizone heating I'm looking for some pointers how I can do this.
Do I simply copy the plugin into an extra directory "SVT2" and then proceed as I did with the first one?
Hopefully somebody is willing to help.
Thanks again, Johnny
In the domoticz hardware page you can just add a second one with a different name.
Regards,
Marco
Verstuurd vanaf mijn SM-G920F met Tapatalk
-
- Posts: 742
- Joined: Saturday 30 May 2015 22:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Contact:
Re: Python Plugin: Smart Virtual Thermostat
You can add the SVT hardware multiple times. Only the thermal characteristics will be shared and that is not optimal, since every room can have it's own thermal characteristics.
-
- Posts: 742
- Joined: Saturday 30 May 2015 22:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Contact:
Re: Python Plugin: Smart Virtual Thermostat
Quoting myself: an idea: what about giving the uservariable with the settings the same name as chosen when the hardware was created? By doing so, every thermostat can build it's own set of parameters for optimal functioning in that room. (in our case, floor heating downstairs and convectors upstairs. Totally opposite from eachother)jake wrote:You can add the SVT hardware multiple times. Only the thermal characteristics will be shared and that is not optimal, since every room can have it's own thermal characteristics.
-
- Posts: 37
- Joined: Wednesday 10 December 2014 21:08
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Location: Netherlands
- Contact:
Re: Python Plugin: Smart Virtual Thermostat
Hi marcojpolet and jake,jake wrote: ↑Saturday 24 November 2018 21:33Quoting myself: an idea: what about giving the uservariable with the settings the same name as chosen when the hardware was created? By doing so, every thermostat can build it's own set of parameters for optimal functioning in that room. (in our case, floor heating downstairs and convectors upstairs. Totally opposite from eachother)jake wrote:You can add the SVT hardware multiple times. Only the thermal characteristics will be shared and that is not optimal, since every room can have it's own thermal characteristics.
Thanks for your responses and interesting thought jake!
Regards, Johnnie
Raspi 3B+; Razberry zwave; zigbee; lots and lots of sensors
-
- Posts: 230
- Joined: Sunday 14 July 2013 20:21
- Target OS: Linux
- Domoticz version: 4.10233
- Location: Alkmaar, The Netherlands
- Contact:
Re: Python Plugin: Smart Virtual Thermostat
I had several svt's working so this already works.johnnie wrote:Hi marcojpolet and jake,jake wrote: ↑Saturday 24 November 2018 21:33Quoting myself: an idea: what about giving the uservariable with the settings the same name as chosen when the hardware was created? By doing so, every thermostat can build it's own set of parameters for optimal functioning in that room. (in our case, floor heating downstairs and convectors upstairs. Totally opposite from eachother)jake wrote:You can add the SVT hardware multiple times. Only the thermal characteristics will be shared and that is not optimal, since every room can have it's own thermal characteristics.
Thanks for your responses and interesting thought jake!
Regards, Johnnie
-
- Posts: 11
- Joined: Sunday 14 October 2018 13:28
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python Plugin: Smart Virtual Thermostat
To which variables are you referring? I have 4 different SVT's set up for four rooms. They each have their own internal variables in the user variables. Each containing the following string (with different values of course):jake wrote: ↑Saturday 24 November 2018 21:33Quoting myself: an idea: what about giving the uservariable with the settings the same name as chosen when the hardware was created? By doing so, every thermostat can build it's own set of parameters for optimal functioning in that room. (in our case, floor heating downstairs and convectors upstairs. Totally opposite from eachother)jake wrote:You can add the SVT hardware multiple times. Only the thermal characteristics will be shared and that is not optimal, since every room can have it's own thermal characteristics.
{'LastInT': 0, 'LastPwr': 0, 'LastSetPoint': 20, 'ALStatus': 0, 'nbCT': 0, 'nbCC': 0, 'LastOutT': 0, 'ConstT': 1, 'ConstC': 60}
-
- Posts: 742
- Joined: Saturday 30 May 2015 22:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Contact:
Re: Python Plugin: Smart Virtual Thermostat
I'm sorry, you are absolutely right. It was a wrong assumption from my side without trying it.wardc wrote:To which variables are you referring? I have 4 different SVT's set up for four rooms. They each have their own internal variables in the user variables. Each containing the following string (with different values of course):jake wrote: ↑Saturday 24 November 2018 21:33Quoting myself: an idea: what about giving the uservariable with the settings the same name as chosen when the hardware was created? By doing so, every thermostat can build it's own set of parameters for optimal functioning in that room. (in our case, floor heating downstairs and convectors upstairs. Totally opposite from eachother)jake wrote:You can add the SVT hardware multiple times. Only the thermal characteristics will be shared and that is not optimal, since every room can have it's own thermal characteristics.
{'LastInT': 0, 'LastPwr': 0, 'LastSetPoint': 20, 'ALStatus': 0, 'nbCT': 0, 'nbCC': 0, 'LastOutT': 0, 'ConstT': 1, 'ConstC': 60}
To test it, I created a new 'test thermostat' and to my surpris it creates a new uservariable with the name [name-of-thermostat-as-given-in-hardware-page]-InternalVariables
Yes, the plugin already has the flexibility to create an own set of unique parameters for each room.
Thanks for correcting my statement.
-
- Posts: 132
- Joined: Monday 07 August 2017 17:17
- Target OS: Linux
- Domoticz version: Latest β
- Location: Near London (Saaarf!)
- Contact:
Re: Python Plugin: Smart Virtual Thermostat
Yes, multiple instances of the plugin work well for a 'zoned' heating solution. You just need one (or more) temperature sensors for each area and also a heater switch for each area.
I use z-wave TRVs on each radiator to regulate the heating appropriately in each 'zone' and have virtual 'Call for heat' switches (see below) that are triggered by the different temperature sensors based on the settings of virtual thermostats.
The need for 'Call for heat' switches
If you only have one boiler switch then you need the virtual switches to call for heat otherwise if you just use the real boiler switch in the SVT hardware parameters the different instances of the plugin will conflict with each other trying to switch the heat on and off.
I use z-wave TRVs on each radiator to regulate the heating appropriately in each 'zone' and have virtual 'Call for heat' switches (see below) that are triggered by the different temperature sensors based on the settings of virtual thermostats.
The need for 'Call for heat' switches
If you only have one boiler switch then you need the virtual switches to call for heat otherwise if you just use the real boiler switch in the SVT hardware parameters the different instances of the plugin will conflict with each other trying to switch the heat on and off.
Domoticz Latest β, RPi 4B with 110Gb SSD for Domoticz, RPi 4B with 110Gb SSD for Node-Red & a RPi 2B for logging / IP addressing. RFXCOM, PiZiGate, Z-Wave, Harmony, Hue lamps and a bit of Broadlink.
-
- Posts: 10
- Joined: Monday 05 November 2018 9:16
- Target OS: Linux
- Domoticz version: lastest
- Location: Barcelona (Spain)
- Contact:
Re: Python Plugin: Smart Virtual Thermostat
Hi,
Yes it is true, if you use SVT on central heating with TRV and one boiler, need to make some "adjustments", as script and/or virtual switches etc.
After month of test of the LC13 (and popp version that is same), and speaking with Danfoss etc. What we are sure.
First, temperature measured by the TRV is not each time as the one measured by the room temp sensor. Most depending of the position of the TRV, angle etc. More is the is curtain near it...etc. The result is if you have TRV and SVT for same zone, the risk is asking 21 for example in SVT, and if ask same at the TRV, never reaching this set temp.
So. When you have several zone etc, you need to use the TRVs as more or less ON/OFF control of the radiator.
For this, when heating is requested, ask setpoint of 28 to the TRV, when OFF, ask 17.
IT is what we do in several installation for testing, it work well...
As i wrote, i am working on SVT plugin for trying to make one version of it for central heating with TRV. About this, &logread, your help can be very good. And better if we can make only one working with all. But i think will ask for hours of coding and test...
And for now, all mode parameters are used..
What is needed.
First, adding in the SVT one dummy named for example "Heating request", and that will turn off or on depending if SVT ask for heating.
Like this can be used for controlling the central boiler (or heat pump) using a small script if you ahve several SVT in same system (but i am working also on one plugin for controlling the boiler with several "heating request" switch and using the water temp control depending of the outdoor temp, meteo etc).
For now what i have tried :
my work is here : https://github.com/Erwanweb/SVT3/blob/master/plugin.py
After :
if 7 not in Devices:
Domoticz.Device(Name="Heating Request", Unit=7, TypeName="Switch", Image=9, Used=1).Create()
devicecreated.append(deviceparam(7, 0, "")) # default is Off
i tried :
# flip on / off as needed
self.heat = switch
command = "On" if switch else "Off"
Domoticz.Debug("Heating '{}'".format(command))
for idx in self.Heaters:
if switches[idx] != switch: # check if action needed
DomoticzAPI("type=command¶m=switchlight&idx={}&switchcmd={}".format(idx, command))
if switch:
Domoticz.Debug("End Heat time = " + str(self.endheat))
Devices[7].Update(nValue=0, sValue="100")
else:
Devices[7].Update(nValue=0, sValue="0")
I try to do this but have some bad returns for changing the state.
Some one have one idea ?
Yes it is true, if you use SVT on central heating with TRV and one boiler, need to make some "adjustments", as script and/or virtual switches etc.
After month of test of the LC13 (and popp version that is same), and speaking with Danfoss etc. What we are sure.
First, temperature measured by the TRV is not each time as the one measured by the room temp sensor. Most depending of the position of the TRV, angle etc. More is the is curtain near it...etc. The result is if you have TRV and SVT for same zone, the risk is asking 21 for example in SVT, and if ask same at the TRV, never reaching this set temp.
So. When you have several zone etc, you need to use the TRVs as more or less ON/OFF control of the radiator.
For this, when heating is requested, ask setpoint of 28 to the TRV, when OFF, ask 17.
IT is what we do in several installation for testing, it work well...
As i wrote, i am working on SVT plugin for trying to make one version of it for central heating with TRV. About this, &logread, your help can be very good. And better if we can make only one working with all. But i think will ask for hours of coding and test...
And for now, all mode parameters are used..
What is needed.
First, adding in the SVT one dummy named for example "Heating request", and that will turn off or on depending if SVT ask for heating.
Like this can be used for controlling the central boiler (or heat pump) using a small script if you ahve several SVT in same system (but i am working also on one plugin for controlling the boiler with several "heating request" switch and using the water temp control depending of the outdoor temp, meteo etc).
For now what i have tried :
my work is here : https://github.com/Erwanweb/SVT3/blob/master/plugin.py
After :
if 7 not in Devices:
Domoticz.Device(Name="Heating Request", Unit=7, TypeName="Switch", Image=9, Used=1).Create()
devicecreated.append(deviceparam(7, 0, "")) # default is Off
i tried :
# flip on / off as needed
self.heat = switch
command = "On" if switch else "Off"
Domoticz.Debug("Heating '{}'".format(command))
for idx in self.Heaters:
if switches[idx] != switch: # check if action needed
DomoticzAPI("type=command¶m=switchlight&idx={}&switchcmd={}".format(idx, command))
if switch:
Domoticz.Debug("End Heat time = " + str(self.endheat))
Devices[7].Update(nValue=0, sValue="100")
else:
Devices[7].Update(nValue=0, sValue="0")
I try to do this but have some bad returns for changing the state.
Some one have one idea ?
-
- Posts: 132
- Joined: Monday 07 August 2017 17:17
- Target OS: Linux
- Domoticz version: Latest β
- Location: Near London (Saaarf!)
- Contact:
Re: Python Plugin: Smart Virtual Thermostat
I control the TRVs so that when the boiler first switches on they are all set at 28 degrees, after that, when the room temperature sensor is above the target the TRV is instructed to 'turn down' by twice the difference between the target and the room temperature, equally this is also the case if the room is below the target then the TRV is 'turned up' by twice the difference.
This allows for a more gradual transition between the radiator being on or off and seems to assist in maintaining a steady temperature.
I also adjust the set-points based on the outside temperature and time of day and additionally increase them if it is raining or the wind gust is high (to counter the cooling effect of drafts (we like to keep the window vents open for fresh air.
This allows for a more gradual transition between the radiator being on or off and seems to assist in maintaining a steady temperature.
I also adjust the set-points based on the outside temperature and time of day and additionally increase them if it is raining or the wind gust is high (to counter the cooling effect of drafts (we like to keep the window vents open for fresh air.
Domoticz Latest β, RPi 4B with 110Gb SSD for Domoticz, RPi 4B with 110Gb SSD for Node-Red & a RPi 2B for logging / IP addressing. RFXCOM, PiZiGate, Z-Wave, Harmony, Hue lamps and a bit of Broadlink.
-
- Posts: 228
- Joined: Sunday 28 August 2016 7:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: France
- Contact:
Re: Python Plugin: Smart Virtual Thermostat
@jake, @alanlsmith,
Many thanks for sharing your experiences and how you have been tweaking your setups around the SVT plugin... @alanlsmith, your tip for "Call for heat" virtual switch is great.
@Erwanweb,
I am not sure it is useful to add another switch to the plugin, considering the solution provided by @alanlsmith... Most users probably will want fewer default devices, not more !
Feel free to fork for your own needs though, but by the way your code for switching a switch device on/off is wrong... nValue = 1 or 0 is to be used... not sValue
Many thanks for sharing your experiences and how you have been tweaking your setups around the SVT plugin... @alanlsmith, your tip for "Call for heat" virtual switch is great.
@Erwanweb,
I am not sure it is useful to add another switch to the plugin, considering the solution provided by @alanlsmith... Most users probably will want fewer default devices, not more !
Feel free to fork for your own needs though, but by the way your code for switching a switch device on/off is wrong... nValue = 1 or 0 is to be used... not sValue
-
- Posts: 4
- Joined: Thursday 06 December 2018 16:15
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python Plugin: Smart Virtual Thermostat
Hi Alanalanlsmith wrote: ↑Saturday 01 December 2018 11:53 I control the TRVs so that when the boiler first switches on they are all set at 28 degrees, after that, when the room temperature sensor is above the target the TRV is instructed to 'turn down' by twice the difference between the target and the room temperature, equally this is also the case if the room is below the target then the TRV is 'turned up' by twice the difference.
Could you clarify your algorith?
Lets say you want 23 and the current temp is 20. I guess you set 28 on TRV. When the temperature reaches 23, you do nothing as the difference is 0. Everytime the temperature changes, you adjust TRV setting ? When it gets to 23.1 you turn it down by 0.2 and set it to 27.8 ? When you got 24 in the room, you set 26 on TRV? In such cacase valve would probalby be still full openened, so the temperature in room will keep rising, wouldn't ?
I have exactly same cause as you and would like to use your experience to set up my heating
Regards
Piotr
-
- Posts: 132
- Joined: Monday 07 August 2017 17:17
- Target OS: Linux
- Domoticz version: Latest β
- Location: Near London (Saaarf!)
- Contact:
Re: Python Plugin: Smart Virtual Thermostat
You are almost right Piotr, what I failed to mention is the frequency with which the room temperature is checked. So what actually happens is that, with a target of 23° and a TRV fully open at 28° if the target is exceeded by 0.1° then the TRV is turned down by 0.2°. Then 2 minutes later this is checked again and if the target is still exceeded by the same 0.1°the TRV will turn down by another 0.2°(obviously if the temperature has continued to rise, as is likely, e it will turn down by more) until it is effectively turned off.)
The adjustments to the TRVs are limited to between 17° and 28°
Also, as the room temperature has exceeded the target the thermostat in that room would have turned off the 'call for heat' switch. This may turn the boiler if no other rooms need heating but if it doesn't the 2 minute monitoring of the TRVs will continue to adjust them to attempt to maintain the temperature near to the target.
Originally I had a plus 0.1° and minus 0.2° tolerance around the target that was constantly recalculated and if those limits were exceeded then the TRV would be adjusted by 5 times the difference but this seemed overly complicated.
A bit long winded I'm afraid but I hope it is understandable.
The adjustments to the TRVs are limited to between 17° and 28°
Also, as the room temperature has exceeded the target the thermostat in that room would have turned off the 'call for heat' switch. This may turn the boiler if no other rooms need heating but if it doesn't the 2 minute monitoring of the TRVs will continue to adjust them to attempt to maintain the temperature near to the target.
Originally I had a plus 0.1° and minus 0.2° tolerance around the target that was constantly recalculated and if those limits were exceeded then the TRV would be adjusted by 5 times the difference but this seemed overly complicated.
A bit long winded I'm afraid but I hope it is understandable.
Domoticz Latest β, RPi 4B with 110Gb SSD for Domoticz, RPi 4B with 110Gb SSD for Node-Red & a RPi 2B for logging / IP addressing. RFXCOM, PiZiGate, Z-Wave, Harmony, Hue lamps and a bit of Broadlink.
-
- Posts: 230
- Joined: Sunday 14 July 2013 20:21
- Target OS: Linux
- Domoticz version: 4.10233
- Location: Alkmaar, The Netherlands
- Contact:
Re: Python Plugin: Smart Virtual Thermostat
Alan, Sounds nice! do you do this with another script or?alanlsmith wrote: ↑Friday 07 December 2018 10:22 You are almost right Piotr, what I failed to mention is the frequency with which the room temperature is checked. So what actually happens is that, with a target of 23° and a TRV fully open at 28° if the target is exceeded by 0.1° then the TRV is turned down by 0.2°. Then 2 minutes later this is checked again and if the target is still exceeded by the same 0.1°the TRV will turn down by another 0.2°(obviously if the temperature has continued to rise, as is likely, e it will turn down by more) until it is effectively turned off.)
The adjustments to the TRVs are limited to between 17° and 28°
Also, as the room temperature has exceeded the target the thermostat in that room would have turned off the 'call for heat' switch. This may turn the boiler if no other rooms need heating but if it doesn't the 2 minute monitoring of the TRVs will continue to adjust them to attempt to maintain the temperature near to the target.
Originally I had a plus 0.1° and minus 0.2° tolerance around the target that was constantly recalculated and if those limits were exceeded then the TRV would be adjusted by 5 times the difference but this seemed overly complicated.
A bit long winded I'm afraid but I hope it is understandable.
I'm looking for the same kind of setup
-
- Posts: 742
- Joined: Saturday 30 May 2015 22:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Contact:
Re: Python Plugin: Smart Virtual Thermostat
I'd say when room temperature is below setpoint, increase valve setpoint to 28 degrees, the other way around: lower it to 17 degrees.
In other words, when the boiler switch is on, TRV setpoint to 28, otherwise to 17 degrees.
In other words, when the boiler switch is on, TRV setpoint to 28, otherwise to 17 degrees.
-
- Posts: 4
- Joined: Thursday 06 December 2018 16:15
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python Plugin: Smart Virtual Thermostat
Thank you alanlsmith. This is perfectly clear now and makes sense. Will implement it the same way in my setup and see how it works
Great thanks.
Great thanks.
-
- Posts: 132
- Joined: Monday 07 August 2017 17:17
- Target OS: Linux
- Domoticz version: Latest β
- Location: Near London (Saaarf!)
- Contact:
Re: Python Plugin: Smart Virtual Thermostat
Here is the script I use to control the TRVs, there are comments explaining most of the sections.Skippiemanz wrote: ↑Friday 07 December 2018 23:10 Alan, Sounds nice! do you do this with another script or?
I'm looking for the same kind of setup
There are 4 rooms Front, Kitchen, Bedroom and mumsroom.
The script requires 4 temperature sensors (I actually use 2 in each room and average them to provide the temperature for that room), 4 virtual thermostats, 4 TRVs, 1 boiler switch, 8 variables holding the max / min temperatures for each room and 4 virtual text devices to show a summary for each room, the last section of the script deals with the generation of data for these sensors.
There are 2 boost switches one for the whole house and one just for the bedroom, these increase the SVT set point to 1.5° above the current temperature for 1 hour.
There is also a round function that is used to make sure that the target and actual temperatures are in the same format for comparison. this function in my script is called from a separate script, it's pretty standard but I have included the function below for reference.
Code: Select all
--Round to a set number of decimal places
function M.round(what, precision)
if (what) then
return math.floor(what*math.pow(10,precision)+0.5) / math.pow(10,precision)
else
return math.floor(val+0.5)
end
end
Code: Select all
commandArray = {}
package.path = package.path .. ';' .. '/home/alan/domoticz/scripts/lua/?.lua'
myFunc = require('myLUAfunctions') -- Include the module with common functions
time = os.date("*t")
local houroftheday = tonumber(os.date("%H"))
yeardate = os.date("%Y");
monthdate = os.date("%b");
dayname = os.date("%a");
daydate = os.date("%d");
hourtime = os.date("%H");
mintime = os.date("%M");
current = dayname.. '. ' ..daydate.. ' ' ..monthdate.. '-' ..hourtime.. ':' ..mintime
if((time.min % 2)==0)then
local physicalheater = 'Boiler_Switch'
local boost = 'Heating_Boost'
local bedroomboost = 'Bedroom_Heating_Boost'
local kitchenstatname = 'Kitchen Thermostat'
local frontstatname = 'Front Thermostat'
local bedroomstatname = 'Bedroom SVT - Setpoint Normal'
local mumsroomstatname = 'Mumsroom Thermostat'
local kitchenrad = 515
local frontrad = 516
local bedroomrad = 517
local mumsroomrad = 518
local kitchenstatus = ''
local frontstatus = ''
local bedroomstatus = ''
local mumsroomstatus = ''
local kitchenTRVidx = 494
local frontTRVidx = 485
local bedroomTRVidx = 481
local mumsroomTRVidx = 496
local kitchentemp = tonumber(otherdevices_svalues['Living Room Temperature'])
local fronttemp = tonumber(otherdevices_svalues['Living Room Temperature'])
local bedroomtemp = tonumber(otherdevices_svalues['Bedroom Temperature'])
local mumsroomtemp = tonumber(otherdevices_svalues['Mumsroom Temperature'])
local kitchensetpoint = tonumber(otherdevices_svalues['Kitchen TRV'])
local frontsetpoint = tonumber(otherdevices_svalues['Front TRV'])
local bedroomsetpoint = tonumber(otherdevices_svalues['Bedroom TRV'])
local mumsroomsetpoint = tonumber(otherdevices_svalues['Mumsroom TRV'])
local kitchennewsetpoint = kitchensetpoint --store current setpoints in case thermostat has been chaned manually
local frontnewsetpoint = frontsetpoint
local bedroomnewsetpoint = bedroomsetpoint
local mumsroomnewsetpoint = mumsroomsetpoint
local kitchenonsetpoint = tonumber(uservariables['Kitchen_On_Set_Point']) --Stored value for TRV maximum set point and set point for when when boiler first switches on (28°)
local frontonsetpoint = tonumber(uservariables['Front_On_Set_Point'])
local bedroomonsetpoint = tonumber(uservariables['Bedroom_On_Set_Point'])
local mumsroomonsetpoint = tonumber(uservariables['Mumsroom_On_Set_Point'])
local kitchenoffsetpoint = tonumber(uservariables['Kitchen_Off_Set_Point']) --Stored value for TRV minimum set point(17°)
local frontoffsetpoint = tonumber(uservariables['Front_Off_Set_Point'])
local bedroomoffsetpoint = tonumber(uservariables['Bedroom_Off_Set_Point'])
local mumsroomoffsetpoint = tonumber(uservariables['Mumsroom_Off_Set_Point'])
local toleranceup = tonumber(uservariables['Tolerance_Up']) --tolerence over and under target temperature
local tolerancedown = tonumber(uservariables['Tolerance_Down'])
--Room targets for control
local kitchentarget = myFunc.round(tonumber(otherdevices_svalues[kitchenstatname]), 1)
local fronttarget = myFunc.round(tonumber(otherdevices_svalues[frontstatname]), 1)
local bedroomtarget = myFunc.round(tonumber(otherdevices_svalues[bedroomstatname]), 1)
local mumsroomtarget = myFunc.round(tonumber(otherdevices_svalues[mumsroomstatname]), 1)
local kitchendiff = kitchentarget - kitchentemp --So if upper target = 21 and temperature is 23.5 then difference is minus 1.5
local frontdiff = fronttarget - fronttemp
local bedroomdiff = bedroomtarget - bedroomtemp
local mumsroomdiff = mumsroomtarget - mumsroomtemp
--Max / min room targets for printout
local kitchentargetup = myFunc.round(kitchentarget + toleranceup,1)
local fronttargetup = myFunc.round(fronttarget + toleranceup,1)
local bedroomtargetup = myFunc.round(bedroomtarget + toleranceup,1)
local mumsroomtargetup = myFunc.round(mumsroomtarget + toleranceup,1)
local kitchentargetdown = myFunc.round(kitchentarget + tolerancedown,1)
local fronttargetdown = myFunc.round(fronttarget + tolerancedown,1)
local bedroomtargetdown = myFunc.round(bedroomtarget + tolerancedown,1)
local mumsroomtargetdown = myFunc.round(mumsroomtarget + tolerancedown,1)
local adjustkitchensetpointdown = myFunc.round((kitchendiff * 2),1)--To adjust setpoint downwards by 2 times the difference between upper target and temperature (a minus figure)
local adjustkitchensetpointup = myFunc.round((kitchendiff * 3),1) --Adjust setpoint upwards by 3 times the difference between lower target and temperature (a positive figure)
local adjustfrontsetpointdown = myFunc.round((frontdiff * 2),1)
local adjustfrontsetpointup = myFunc.round((frontdiff * 3),1)
local adjustbedroomsetpointdown = myFunc.round((bedroomdiff * 2),1)
local adjustbedroomsetpointup = myFunc.round((bedroomdiff * 3),1)
local adjustmumsroomsetpointdown = myFunc.round((mumsroomdiff * 2),1)
local adjustmumsroomsetpointup = myFunc.round((mumsroomdiff * 3),1)
--set TRV setpoints if boiler is on***********************************************************************************
if(otherdevices[physicalheater] == 'On') then
boilerstatus = 'Boiler On'
if ( otherdevices[boost] == 'Off' ) and ( otherdevices[bedroomboost] == 'Off' ) then
if(kitchentemp >= kitchentarget ) then
kitchennewsetpoint = kitchensetpoint + adjustkitchensetpointdown --this closes valve a small amount when over target
elseif(kitchentemp < kitchentarget ) then
kitchennewsetpoint = kitchensetpoint + adjustkitchensetpointup --this opens valve a small amount when over target
end
if(fronttemp >= fronttarget ) then
frontnewsetpoint = frontsetpoint + adjustfrontsetpointdown
elseif(fronttemp < fronttarget ) then
frontnewsetpoint = frontsetpoint + adjustfrontsetpointup
end
if(bedroomtemp >= bedroomtarget ) then
bedroomnewsetpoint = bedroomsetpoint + adjustbedroomsetpointdown
elseif(bedroomtemp < bedroomtarget ) then
bedroomnewsetpoint = bedroomsetpoint + adjustbedroomsetpointup
end
if(mumsroomtemp >= mumsroomtarget ) then
mumsroomnewsetpoint = mumsroomsetpoint + adjustmumsroomsetpointdown
elseif(mumsroomtemp < mumsroomtarget ) then
mumsroomnewsetpoint = mumsroomsetpoint + adjustmumsroomsetpointup
end
--Whole house heating boost is on
elseif ( otherdevices[boost] == 'On' ) and ( otherdevices[bedroomboost] == 'Off' ) then
kitchennewsetpoint = kitchenonsetpoint
frontnewsetpoint = frontonsetpoint
if(bedroomtemp >= bedroomtarget ) then
bedroomnewsetpoint = bedroomsetpoint + adjustbedroomsetpointdown
elseif(bedroomtemp < bedroomtarget ) then
bedroomnewsetpoint = bedroomsetpoint + adjustbedroomsetpointup
end
if(mumsroomtemp >= mumsroomtarget ) then
mumsroomnewsetpoint = mumsroomsetpoint + adjustmumsroomsetpointdown
elseif(mumsroomtemp < mumsroomtarget ) then
mumsroomnewsetpoint = mumsroomsetpoint + adjustmumsroomsetpointup
end
--only bedroom heating boost is on
elseif ( otherdevices[boost] == 'Off' ) and ( otherdevices[bedroomboost] == 'On' ) then
bedroomnewsetpoint = bedroomonsetpoint --make sure bedroom TRV is on as Bedroom Boost is on
if(kitchentemp >= kitchentarget ) then
kitchennewsetpoint = kitchensetpoint + adjustkitchensetpointdown --this closes valve a small amount when in range
elseif(kitchentemp < kitchentarget ) then
kitchennewsetpoint = kitchensetpoint + adjustkitchensetpointup --this opens valve a small amount when in range
end
if(fronttemp >= fronttarget ) then
frontnewsetpoint = frontsetpoint + adjustfrontsetpointdown --this closes valve a small amount when in range
elseif(fronttemp < fronttarget ) then
frontnewsetpoint = frontsetpoint + adjustfrontsetpointup --this opens valve a small amount when in range
end
if(mumsroomtemp >= mumsroomtarget ) then
mumsroomnewsetpoint = mumsroomsetpoint + adjustmumsroomsetpointdown --this closes valve a small amount when in range
elseif(mumsroomtemp < mumsroomtarget ) then
mumsroomnewsetpoint = mumsroomsetpoint + adjustmumsroomsetpointup --this opens valve a small amount when in range
end
--whole househeating boost and bedroom boost is on
elseif ( otherdevices[boost] == 'On' ) and ( otherdevices[bedroomboost] == 'On' ) then
kitchennewsetpoint = kitchenonsetpoint --make sure kitchen TRV is on as Heating Boost is on
frontnewsetpoint = frontonsetpoint --make sure front TRV is on as Heating Boost is on
bedroomnewsetpoint = bedroomonsetpoint --make sure bedroom TRV is on as Bedroom Boost is on
end
else
boilerstatus = 'Boiler Off'
end
--Always make sure setpoints are within a certain range********************************************************************
if(kitchennewsetpoint > kitchenonsetpoint) then
kitchennewsetpoint = kitchenonsetpoint
elseif(kitchennewsetpoint < kitchenoffsetpoint) then
kitchennewsetpoint = kitchenoffsetpoint
end
if(frontnewsetpoint > frontonsetpoint) then
frontnewsetpoint = frontonsetpoint
elseif(frontnewsetpoint < frontoffsetpoint) then
frontnewsetpoint = frontoffsetpoint
end
if(bedroomnewsetpoint > bedroomonsetpoint) then
bedroomnewsetpoint = bedroomonsetpoint
elseif(bedroomnewsetpoint < bedroomoffsetpoint) then
bedroomnewsetpoint = bedroomoffsetpoint
end
if(mumsroomnewsetpoint > mumsroomonsetpoint) then
mumsroomnewsetpoint = mumsroomonsetpoint
elseif(mumsroomnewsetpoint < mumsroomoffsetpoint) then
mumsroomnewsetpoint = mumsroomoffsetpoint
end
--Set TRVs if setpoints have changed***********************************************************************************
if( kitchennewsetpoint ~= kitchensetpoint ) then
commandArray[#commandArray+1] = {['OpenURL']='http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=' ..kitchenTRVidx.. '&nvalue=0&svalue='..kitchennewsetpoint }
end
if( frontnewsetpoint ~= frontsetpoint ) then
commandArray[#commandArray+1] = {['OpenURL']='http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=' ..frontTRVidx.. '&nvalue=0&svalue='..frontnewsetpoint }
end
if( bedroomnewsetpoint ~= bedroomsetpoint ) then
commandArray[#commandArray+1] = {['OpenURL']='http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=' ..bedroomTRVidx.. '&nvalue=0&svalue='..bedroomnewsetpoint }
end
if( mumsroomnewsetpoint ~= mumsroomsetpoint ) then
commandArray[#commandArray+1] = {['OpenURL']='http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=' ..mumsroomTRVidx.. '&nvalue=0&svalue='..mumsroomnewsetpoint }
end
--Below here is for showing summary in text devices*********************************************************************************************
kitchennewsetpoint = string.format("%.1f°",kitchennewsetpoint)
frontnewsetpoint = string.format("%.1f°",frontsetpoint)
bedroomnewsetpoint = string.format("%.1f°",bedroomnewsetpoint)
mumsroomnewsetpoint = string.format("%.1f°",mumsroomnewsetpoint)
kitchentargetdown = string.format("%.1f°",kitchentargetdown)
kitchentargetup = string.format("%.1f°",kitchentargetup)
kitchentemp = string.format("%.1f°",kitchentemp)
fronttargetdown = string.format("%.1f°",fronttargetdown)
fronttargetup = string.format("%.1f°",fronttargetup)
fronttemp = string.format("%.1f°",fronttemp)
bedroomtargetdown = string.format("%.1f°",bedroomtargetdown)
bedroomtargetup = string.format("%.1f°",bedroomtargetup)
bedroomtemp = string.format("%.1f°",bedroomtemp)
mumsroomtargetdown = string.format("%.1f°",mumsroomtargetdown)
mumsroomtargetup = string.format("%.1f°",mumsroomtargetup)
mumsroomtemp = string.format("%.1f°",mumsroomtemp)
if( kitchentemp < kitchentargetdown ) then
kitchenstatus = 'Kitchen below target range-TRV: ' ..kitchennewsetpoint.. ' ' ..boilerstatus.. '<br>' ..kitchentargetdown.. ' < '..kitchentemp.. ' > ' ..kitchentargetup
elseif( kitchentemp > kitchentargetup ) then
kitchenstatus = 'Kitchen above target range-TRV: ' ..kitchennewsetpoint.. ' ' ..boilerstatus.. '<br>' ..kitchentargetdown.. ' < '..kitchentemp.. ' > ' ..kitchentargetup
elseif( kitchentemp >= kitchentargetdown ) and ( kitchentemp <= kitchentargetup ) then
kitchenstatus = 'Kitchen within target range-TRV: ' ..kitchennewsetpoint.. ' ' ..boilerstatus.. '<br>' ..kitchentargetdown.. ' < '..kitchentemp.. ' > ' ..kitchentargetup
end
if( fronttemp < fronttargetdown ) then
frontstatus = 'Front below target range-TRV: ' ..frontnewsetpoint.. ' ' ..boilerstatus.. '<br>' ..fronttargetdown.. ' < '..fronttemp.. ' > ' ..fronttargetup
elseif( fronttemp > fronttargetup ) then
frontstatus = 'Front above target range--TRV: ' ..frontnewsetpoint.. ' ' ..boilerstatus.. '<br>' ..fronttargetdown.. ' < '..fronttemp.. ' > ' ..fronttargetup
elseif( fronttemp >= fronttargetdown ) and ( fronttemp <= fronttargetup ) then
frontstatus = 'Front within target range-TRV: ' ..frontnewsetpoint.. ' ' ..boilerstatus.. '<br>' ..fronttargetdown.. ' < '..fronttemp.. ' > ' ..fronttargetup
end
if( bedroomtemp < bedroomtargetdown ) then
bedroomstatus = 'Bedroom below target range-TRV: ' ..bedroomnewsetpoint.. ' ' ..boilerstatus.. '<br>' ..bedroomtargetdown.. ' < '..bedroomtemp.. ' > ' ..bedroomtargetup
elseif( bedroomtemp > bedroomtargetup ) then
bedroomstatus = 'Bedroom above target range-TRV: ' ..bedroomnewsetpoint.. ' ' ..boilerstatus.. '<br>' ..bedroomtargetdown.. ' < '..bedroomtemp.. ' > ' ..bedroomtargetup
elseif( bedroomtemp >= bedroomtargetdown ) and ( bedroomtemp <= bedroomtargetup ) then
bedroomstatus = 'Bedroom within target range-TRV: ' ..bedroomnewsetpoint.. ' ' ..boilerstatus.. '<br>' ..bedroomtargetdown.. ' < '..bedroomtemp.. ' > ' ..bedroomtargetup
end
if( mumsroomtemp < mumsroomtargetdown ) then
mumsroomstatus = 'Mumsroom below target range-TRV: ' ..mumsroomnewsetpoint.. ' ' ..boilerstatus.. '<br>' ..mumsroomtargetdown.. ' < '..mumsroomtemp.. ' > ' ..mumsroomtargetup
elseif( mumsroomtemp > mumsroomtargetup ) then
mumsroomstatus = 'Mumsroom above target range-TRV: ' ..mumsroomnewsetpoint.. ' ' ..boilerstatus.. '<br>' ..mumsroomtargetdown.. ' < '..mumsroomtemp.. ' > ' ..mumsroomtargetup
elseif( mumsroomtemp >= mumsroomtargetdown ) and ( mumsroomtemp <= mumsroomtargetup ) then
mumsroomstatus = 'Mumsroom within target range-TRV: ' ..mumsroomnewsetpoint.. ' ' ..boilerstatus.. '<br>' ..mumsroomtargetdown.. ' < '..mumsroomtemp.. ' > ' ..mumsroomtargetup
end
commandArray[#commandArray+1] = {['UpdateDevice'] = kitchenrad.. '|0|' ..kitchenstatus}
commandArray[#commandArray+1] = {['UpdateDevice'] = frontrad.. '|0|' ..frontstatus}
commandArray[#commandArray+1] = {['UpdateDevice'] = bedroomrad.. '|0|' ..bedroomstatus}
commandArray[#commandArray+1] = {['UpdateDevice'] = mumsroomrad.. '|0|' ..mumsroomstatus}
end
return commandArray
Domoticz Latest β, RPi 4B with 110Gb SSD for Domoticz, RPi 4B with 110Gb SSD for Node-Red & a RPi 2B for logging / IP addressing. RFXCOM, PiZiGate, Z-Wave, Harmony, Hue lamps and a bit of Broadlink.
-
- Posts: 4
- Joined: Thursday 06 December 2018 16:15
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python Plugin: Smart Virtual Thermostat
Alan, your script is very smart, i will use it as a base for my script. Thank you very much.
-
- Posts: 8
- Joined: Tuesday 11 December 2018 19:54
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python Plugin: Smart Virtual Thermostat
Welcome everybody,
Great job with SVT, thanks anyone involved. I inteend to use it with my Synology. I do have a problem, as such termostat runno problem, I can not change the setpoint temperature by event. Other events like swich on/off work no problem, but setpoint temp not, may you have any advise?
Edit: I,ve soled it this way, time must be set to > or < as event need time to be trigered
Great job with SVT, thanks anyone involved. I inteend to use it with my Synology. I do have a problem, as such termostat runno problem, I can not change the setpoint temperature by event. Other events like swich on/off work no problem, but setpoint temp not, may you have any advise?
Edit: I,ve soled it this way, time must be set to > or < as event need time to be trigered
- Attachments
-
- tempch.JPG (19.7 KiB) Viewed 2552 times
Who is online
Users browsing this forum: No registered users and 1 guest