Python Plugin: Smart Virtual Thermostat

For heating/cooling related questions in Domoticz

Moderator: leecollings

rrozema
Posts: 470
Joined: Thursday 26 October 2017 13:37
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Delft
Contact:

Re: Python Plugin: Smart Virtual Thermostat

Post by rrozema »

I still very much like the idea of svt, this script version just has some errors and limitations in it's implementation, causing it to improperly 'refine' the ConstC and even more the ConstT values.
For example the code suffers from rounding errors: at some point the code just starts 'bouncing' between large constC values because the calculations are rounded too early and the PID as it is implemented can't recover from this situation.

Also the constT calculation is incorrect because the temperature offset is incorrectly defined as the difference between the outside temperature and the setpoint, whereas the heat-loss depends on the difference between the outside temperature and the actual inside temperatue, which may not be the same as the setpoint.

The next thing that seems to go wrong for a lot of people is when the calculated power goes over 100%, the constC and ConstT calculations are done as if 100% power was applied, whereas in reality the power was applied for more than 100%. This I think is a consequence of ignoring a lot of measurements when the needed power is over 100%, and also ignoring the measurements where the temperature is over the setpoint. I think these periods however need to be considered too, as even though the heater may be off, energy applied during previous cycles can still be delivered into the room(s) by the system.

An improvement I have been working on -but never got to really work correctly- is to keep the re-evaluation period fixed at a 10 minute interval (I found this suggested as a reasonable period by many heating specialists) to make sure the thermostat responds quickly to changes in the room temperature, but the measuring period can be longer or shorter than that based on the characteristics of the room/building/heating system. For this the power calculated must be able to go over 100%: when power >= 100% this just means our heat-source is going to be firing for the full 10 minutes, but still after 10 minutes we're going to re-evaluate the result of our effort so far. When doing this re-evaluation we have to take into account however that we have actually applied only 100% power even if more was calculated; i.e. we need to adjust the power applied accordingly in our constC refinement. For example: if power needed was calculated at time t as 150%, we would have had to switch the heater on for 1,50 * 10 * 60 seconds = 900 seconds. Because we re-evaluate every 10 minutes however, only 600 seconds will have passed at our next time t+1: we have applied only 100 of the 150% = 100/150 = 2/3. The constC refinement will be performed every 10 minutes, but the power applied must be corrected for this shorter period by that factor of 2/3. I am making one assumption here that is not completely true: I am assuming temperature raises and falls linear, which is not the case in real life. If however temperature differences are small enough, it is almost true. So by doing this assumption I make our calculations a lot easier, at the cost of a some precision when the difference between setpoint and actual temperature is large. Since we're mostly going to want our thermostat to keep the temperature close to the setpoint I think we can safely make this assumption. The benefits of doing this change -I think- are: the svt will perform better with a long feedback loop (for example with floor heating) while still responding quickly to outside changes and it can also better refine the constC values (because it takes into the account the periods the heater wasn't on too: the constC will contain a component for both on and off periods). What I wanted to achieve is that the svt always calculates how much power to apply to make sure the temperature is going to be at the setpoint at the next interval t+1, regardless of the actual temperature at time t, the setpoint value or if the heater was on during the previous cycle. i.e. no limitations should be applied on the decision whether to re-calculate needed power nor on whether to refine constC.
jake
Posts: 742
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: Python Plugin: Smart Virtual Thermostat

Post by jake »

What I have done last year to improve svt drastically:
-Rounding at 3 digits
-reduce the average of 50 values to 25
-Cutting the calculation cycle in half when there is no heading in the previous cycle
-redefine the constC and T values:
At the end of an heading cycle, I recalculate these values, based on the actual achieved temperature.

We were not at home last weekend for an afternoon and evening and with the floor heating as source, SVT was able to achieve a total tolerance of 0.1 degrees (16.9-17'C). With the Remeha iSense this would be close to 16.5-17.5'C
ssk17051980
Posts: 112
Joined: Thursday 08 December 2022 22:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: ROMANIA
Contact:

Re: Python Plugin: Smart Virtual Thermostat

Post by ssk17051980 »

Hello,

can you be a little more precise? we are technical terms that you say and they are difficult to translate/interpret.

i put a print screen whit my settings.


for example: I don't know what this could mean. I can translate but I can't interpret.
"Apply minimum heating per cycle"
Attachments
domoticz.jpg
domoticz.jpg (81.6 KiB) Viewed 4166 times
jake
Posts: 742
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: Python Plugin: Smart Virtual Thermostat

Post by jake »

ssk17051980 wrote: Wednesday 14 December 2022 13:22 Hello,

can you be a little more precise? we are technical terms that you say and they are difficult to translate/interpret.

i put a print screen whit my settings.


for example: I don't know what this could mean. I can translate but I can't interpret.
"Apply minimum heating per cycle"
Did you read the wiki and GitHub help page?

Apply minimum heating per cycle means that no matter what the calculated heating time is, a minimum heating time will be applied for each cycle.

If you specify the minimum at 20, than every calculation result between 1-20 percent will be upgraded to 20 percent.
'always' means that at each cycle the 20 percent will be applied, no matter what the current temperature is (not advised)
Cdzn
Posts: 18
Joined: Monday 02 March 2020 10:09
Target OS: -
Domoticz version:
Contact:

Re: Python Plugin: Smart Virtual Thermostat

Post by Cdzn »

After updating get this
Error calling 'http://192.168.0.108:8080/json.htm?type ... order=Name'
none of the devices in the 'heaters' parameter is a switch... no action !
jake
Posts: 742
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: Python Plugin: Smart Virtual Thermostat

Post by jake »


Cdzn wrote:After updating get this
Error calling 'http://192.168.0.108:8080/json.htm?type ... order=Name'
none of the devices in the 'heaters' parameter is a switch... no action !
Well, check what it says:none of the devices in the 'heaters' parameter is a switch

You have defined which idx number is your boiler switch and obviously the supplied number is not a switch
Cdzn
Posts: 18
Joined: Monday 02 March 2020 10:09
Target OS: -
Domoticz version:
Contact:

Re: Python Plugin: Smart Virtual Thermostat

Post by Cdzn »

But i did nothing except update Domoticz. And the boiler switch is still the same IDX as before update
jake
Posts: 742
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: Python Plugin: Smart Virtual Thermostat

Post by jake »

Cdzn wrote:But i did nothing except update Domoticz. And the boiler switch is still the same IDX as before update
When you run the command in your browser:

http://192.168.0.108:8080/json.htm?type ... trueℴ=Name'

Do you see your idx number in between there and does it mention there as subtype 'switch'?
Stiv32
Posts: 10
Joined: Sunday 08 September 2019 7:38
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Smart Virtual Thermostat

Post by Stiv32 »

I have this same problem -bubtype is switch

PlanIDs
0 0
Protected false
ShowNotifications true
SignalLevel "-"
Status "Off"
StrParam1 ""
StrParam2 ""
SubType "Switch"
SwitchType "On/Off"
SwitchTypeVal 0
Timers "false"
Type "Light/Switch"
TypeImg "lightbulb"
Unit 1
Used 1
UsedByCamera false
XOffset "0"
YOffset "0"
idx "8"
Skippiemanz
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

Post by Skippiemanz »

Same problem here, on a fresh install.

Triple checked everything
jake
Posts: 742
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: Python Plugin: Smart Virtual Thermostat

Post by jake »

I wonder if it has to do with the new domoticz 2023 version which requires login. Could it be that the plugin is not allowed, or set up to do that?

I am still on an older beta version (2022.2) and my (virtual) boiler switch is shown the same as yours:

Code: Select all

{
			"AddjMulti" : 1.0,
			"AddjMulti2" : 1.0,
			"AddjValue" : 0.0,
			"AddjValue2" : 0.0,
			"BatteryLevel" : 255,
			"CustomImage" : 15,
			"Data" : "Off",
			"Description" : "",
			"DimmerType" : "none",
			"Favorite" : 0,
			"HardwareDisabled" : false,
			"HardwareID" : 3,
			"HardwareName" : "Virtual Devices",
			"HardwareType" : "Dummy (Does nothing, use for virtual switches only)",
			"HardwareTypeVal" : 15,
			"HaveDimmer" : true,
			"HaveGroupCmd" : true,
			"HaveTimeout" : false,
			"ID" : "00014178",
			"Image" : "Heating",
			"IsSubDevice" : false,
			"LastUpdate" : "2023-02-15 07:15:02",
			"Level" : 0,
			"LevelInt" : 0,
			"MaxDimLevel" : 100,
			"Name" : "SVT Heater",
			"Notifications" : "false",
			"PlanID" : "2",
			"PlanIDs" : 
			[
				2
			],
			"Protected" : false,
			"ShowNotifications" : true,
			"SignalLevel" : "-",
			"Status" : "Off",
			"StrParam1" : "",
			"StrParam2" : "",
			"SubType" : "Switch",
			"SwitchType" : "On/Off",
			"SwitchTypeVal" : 0,
			"Timers" : "false",
			"Type" : "Light/Switch",
			"TypeImg" : "lightbulb",
			"Unit" : 1,
			"Used" : 1,
			"UsedByCamera" : false,
			"XOffset" : "0",
			"YOffset" : "0",
			"idx" : "296"
		},
jake
Posts: 742
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: Python Plugin: Smart Virtual Thermostat

Post by jake »

jake wrote: Wednesday 15 February 2023 18:15 I wonder if it has to do with the new domoticz 2023 version which requires login. Could it be that the plugin is not allowed, or set up to do that?

I am still on an older beta version (2022.2)...
OK, I think I know where the problem is (not how to solve it, since my coding skills are limited and python skills are next to none. Anyway, as stated above, it has to do with the security of domoticz:

In my 2022.2 version I still have in Settings-Security the option for 'Local Networks (no username/password):' In my case this is is filled in with a 192 and 127 IP range. When I remove both IP-ranges and go to 'Hardware' and choose to 'update' SVT (by doing so, Domoticz will reload the hardware), I get the following errors in the log:

Code: Select all

2023-02-15 18:40:22.311 Status: SVT: Heaters = [296]
2023-02-15 18:40:22.358 Error: SVT: Error calling 'http://127.0.0.1:8080/json.htm?type=command&param=getuservariables'
2023-02-15 18:40:22.359 Error: SVT: Cannot read the uservariable holding the persistent variables
2023-02-15 18:40:31.079 Status: SVT: Next calculation time will be : 2023-02-15 20:30:31.079019
2023-02-15 18:40:31.089 Error: SVT: Error calling 'http://127.0.0.1:8080/json.htm?type=devices&filter=temp&used=true&order=Name'
2023-02-15 18:40:31.089 Error: SVT: No Inside Temperature found: Switching heating Off
2023-02-15 18:40:31.093 Error: SVT: Error calling 'http://127.0.0.1:8080/json.htm?type=devices&filter=light&used=true&order=Name'
2023-02-15 18:40:31.094 Error: SVT: none of the devices in the 'heaters' parameter is a switch... no action !
2023-02-15 18:40:31.144 Error: SVT: Error calling 'http://127.0.0.1:8080/json.htm?type=devices&filter=light&used=true&order=Name'
2023-02-15 18:40:31.145 Error: SVT: none of the devices in the 'heaters' parameter is a switch... no action !
As soon as I plug both IP-ranges for access without username/pw back into Settings and reload SVT again, the plugin works as it is supposed.

When I add my username and password to the SVT plugin!!! and remove the interal IP-ranges once again, SVT reloads perfectly fine.

Conclusion is: add user/pw to the SVT hardware and click 'Update'. This will reload SVT with a supplied user/pw
etampes
Posts: 4
Joined: Wednesday 29 November 2017 17:02
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Smart Virtual Thermostat

Post by etampes »

Unfortunately adding my admin username and password to the SVT hardware settings did not resolve these errors for me :o
Cdzn
Posts: 18
Joined: Monday 02 March 2020 10:09
Target OS: -
Domoticz version:
Contact:

Re: Python Plugin: Smart Virtual Thermostat

Post by Cdzn »

etampes wrote: Wednesday 15 February 2023 20:39 Unfortunately adding my admin username and password to the SVT hardware settings did not resolve these errors for me :o
For me too, don’t work. And i filled the ip tables without login before update, so there is something wrong with new update or plugin have not enough permissions to login.
Cdzn
Posts: 18
Joined: Monday 02 March 2020 10:09
Target OS: -
Domoticz version:
Contact:

Re: Python Plugin: Smart Virtual Thermostat

Post by Cdzn »

Cdzn wrote: Thursday 16 February 2023 4:59
etampes wrote: Wednesday 15 February 2023 20:39 Unfortunately adding my admin username and password to the SVT hardware settings did not resolve these errors for me :o
For me too, don’t work. And i filled the ip tables without login before update, so there is something wrong with new update or plugin have not enough permissions to login.
I solved the problem. In changelog they said
- Changed: Implicit adding local IP to 'trusted networks' has been removed. Needs to be set explicitly for security reasons!
so You should change your ip in settings, don`t use 127.0.0.*;192.168.0.*, Set IP explicitly, example:127.0.0.1;192.168.0.40 e.t.c, don`t forget to divide them by ;
rockyt
Posts: 5
Joined: Tuesday 12 December 2017 16:17
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Smart Virtual Thermostat

Post by rockyt »

It worked in my system. I had to add "localhost" to the list too
Thanks
Guido
Skippiemanz
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

Post by Skippiemanz »

Unfortunetly no succes here,

i Have one setup witch runs 2023.1 build 15082 and has been update from previous versions witch works ok.

And a fresh install with 2023.1 stable and gives the error. settings all the same.
Cdzn
Posts: 18
Joined: Monday 02 March 2020 10:09
Target OS: -
Domoticz version:
Contact:

Re: Python Plugin: Smart Virtual Thermostat

Post by Cdzn »

Skippiemanz wrote: Thursday 16 February 2023 23:04 Unfortunetly no succes here,

i Have one setup witch runs 2023.1 build 15082 and has been update from previous versions witch works ok.

And a fresh install with 2023.1 stable and gives the error. settings all the same.
Could you do screenshots svt config and domoticz too.
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python Plugin: Smart Virtual Thermostat

Post by waltervl »

Perhaps an important new setting is the "Allow Basic Authentication over plain HTTP" in menu setup -> settings -> security
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Skippiemanz
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

Post by Skippiemanz »

waltervl wrote: Friday 17 February 2023 10:48 Perhaps an important new setting is the "Allow Basic Authentication over plain HTTP" in menu setup -> settings -> security

Unfortunetly not the Answer. Will post screens of setting here net post
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests