Script to update temp set points
Moderator: leecollings
-
- Posts: 7
- Joined: Wednesday 16 January 2019 6:35
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10693
- Contact:
Script to update temp set points
New to this forum, thanks for having me.
Also newly transitioned from Vera to Domoticz / Raspberry Pi, and have some basic knowledge of lua.
I have two thermostats, so there are 4 setpoints (heat & cool) to regularly update via Domoticz.
Currently I update uservariables with the setpoint values at every XX:00:00.
I then use lua timer scripts to load these values into the thermostats at every XX:01:00, XX:02:00, XX:03:00, and XX:04:00.
This is done because my thermostats don't like all 4 setpoint values blasted to them simultaneously.
Can somebody suggest a lua script that can tighten up this process from 4 minutes to...let's say 20 seconds...like this:
XX:00:00 - Update uservariables
XX:00:05 - Update Cool SetPoint (east unit)
XX:00:10 - Update Heat SetPoint (east unit)
XX:00:15 - Update Cool SetPoint (west unit)
XX:00:20 - Update Heat SetPoint (west unit)
(FYI: Vera had a delayed function call which was quite handy in this scenario...luup.call_delay("function",5)...where 5 was a delay in SECONDS)
Thank you in advance for any suggestions/recommendations.
Also newly transitioned from Vera to Domoticz / Raspberry Pi, and have some basic knowledge of lua.
I have two thermostats, so there are 4 setpoints (heat & cool) to regularly update via Domoticz.
Currently I update uservariables with the setpoint values at every XX:00:00.
I then use lua timer scripts to load these values into the thermostats at every XX:01:00, XX:02:00, XX:03:00, and XX:04:00.
This is done because my thermostats don't like all 4 setpoint values blasted to them simultaneously.
Can somebody suggest a lua script that can tighten up this process from 4 minutes to...let's say 20 seconds...like this:
XX:00:00 - Update uservariables
XX:00:05 - Update Cool SetPoint (east unit)
XX:00:10 - Update Heat SetPoint (east unit)
XX:00:15 - Update Cool SetPoint (west unit)
XX:00:20 - Update Heat SetPoint (west unit)
(FYI: Vera had a delayed function call which was quite handy in this scenario...luup.call_delay("function",5)...where 5 was a delay in SECONDS)
Thank you in advance for any suggestions/recommendations.
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Script to update temp set points
With pass2php you would just need to add a sleep(3) for seconds or a usleep(100000) for microseconds.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Script to update temp set points
Can you please share your current Lua script(s) here ? That would help to help you.svanni wrote: ↑Wednesday 16 January 2019 6:51 I have two thermostats, so there are 4 setpoints (heat & cool) to regularly update via Domoticz.
Currently I update uservariables with the setpoint values at every XX:00:00.
I then use lua timer scripts to load these values into the thermostats at every XX:01:00, XX:02:00, XX:03:00, and XX:04:00.
This is done because my thermostats don't like all 4 setpoint values blasted to them simultaneously.
Can somebody suggest a lua script that can tighten up this process from 4 minutes to...let's say 20 seconds.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 443
- Joined: Thursday 12 November 2015 10:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: The Netherlands
- Contact:
Script to update temp set points
I don't fully understand what you're trying to do. Why are you putting setpoints in user variables and updating your Domoticz thermostats with them every hour? Why don't you use timers for instance?
By the way, you can do delayed switching in LUA using the AFTER command. The following turns a switch off after 1 minute:
I was expecting something similar to be possible with setpoints, but
doesn't seem to produce the desired result... Maybe a nice future feature for Domoticz...
By the way, you can do delayed switching in LUA using the AFTER command. The following turns a switch off after 1 minute:
Code: Select all
commandArray ['Some switch'] = 'Off AFTER 60'
Code: Select all
commandArray['SetSetPoint:'..otherdevices_idx['Your thermostat']] = '19 AFTER 60'
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
-
- Posts: 7
- Joined: Wednesday 16 January 2019 6:35
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10693
- Contact:
Re: Script to update temp set points
Thank you for your replies.
Here is the current script:
Here is the current script:
This would be a great solution, if it worked:commandArray = {}
local cool = tostring(math.max(uservariables['HVAC Cool SP'] + uservariables['Temperature Adjustment'],22))
local heat = tostring(math.min(uservariables['HVAC Heat SP'] + uservariables['Temperature Adjustment'],23))
if os.date("%M")%60 == 1 then commandArray['UpdateDevice'] = tostring('41|0|'..cool) -- East Cool
elseif os.date("%M")%60 == 2 then commandArray['UpdateDevice'] = tostring('40|0|'..heat) -- East Heat
elseif os.date("%M")%60 == 3 then commandArray['UpdateDevice'] = tostring('68|0|'..cool) -- West Cool
elseif os.date("%M")%60 == 4 then commandArray['UpdateDevice'] = tostring('67|0|'..heat)
-- West Heat
end
return commandArray
commandArray['SetSetPoint:'..otherdevices_idx['Your thermostat']] = '19 AFTER 60'
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Script to update temp set points
Please have a look at the dzVents script below and make sure you read and understand the comment lines about prerequisitessvanni wrote: ↑Wednesday 16 January 2019 17:54 Thank you for your replies.
This would be a great solution, if it worked:Code: Select all
commandArray['SetSetPoint:'..otherdevices_idx['Your thermostat']] = '19 AFTER 60'
When not yet familiar with dzVents please start with reading the quick start of the wiki
Before implementing.
Code: Select all
--[[
-- delayedSetPoints.lua
!! Please note that afterSec(), afterMin() and afterHour() is available for the
!! updateSetPoint function for standard Thermostat setpoint devices (not for Evohome or Zwave yet)
!! in domoticz version V4.10360 (dzVents 2.4.10) or later.
When not yet familiar with dzVents please start with reading
https://www.domoticz.com/wiki/DzVents:_next_generation_LUA_scripting#Using_dzVents_with_Domoticz
Before implementing. Special attention please for
"In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents disabled' is not checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."
]]--
return {
on = { devices = { "at *:01" }},
execute = function(dz, item)
local adjustment = dz.variables("Temperature Adjustment").value
local cool = math.max(dz.variables("HVAC Cool SP").value + adjustment,22)
local heat = math.min(dz.variables("HVAC Heat SP").value + adjustment,23)
dz.devices(41).updateSetPoint(cool)
dz.devices(40).updateSetPoint(heat).afterMin(1)
dz.devices(67).updateSetPoint(cool).afterMin(2)
dz.devices(68).updateSetPoint(heat).afterMin(3)
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 7
- Joined: Wednesday 16 January 2019 6:35
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10693
- Contact:
Re: Script to update temp set points
Waaren,
This is great, thank you for the info.
I suspected this might go the route of DZVents.
I'll give this a test tonight.
Thanks again.
This is great, thank you for the info.
I suspected this might go the route of DZVents.
I'll give this a test tonight.
Thanks again.
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Script to update temp set points
So you'll gonna change the script to tighten up the time from 4 minutes to... 4 minutes?
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Script to update temp set points
Possible. But also to 4 hours.. and yes, 4 seconds would be possible as well. As described in the comments of this example; afterSec(), afterMin(), afterHour() options are available with most recent Beta's in combination with dzVents 2.4.10
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Who is online
Users browsing this forum: No registered users and 1 guest