Page 1 of 1
ELSEIF thermostat not triggering
Posted: Sunday 14 October 2018 18:30
by EdddieN
Hello
I have an Evohome zone and some Z-Wave thermostats. This kind of works ok, but only the first IF, not the second. What I'm doing wrong?
Basically I can override the temperature from either the Evohome or the Z-wave virtual thermostat. When I override from Evohome it works, but when I override from the virtual thermostant, only the Evohome part triggers.
Code: Select all
--[[
Heating override
]]--
return {
on = { devices = { 'Downstairs', 'Downstairs Thermostat'} }, -- EvoHome trigger or Virtual Thermostat
execute = function(domoticz, Thermostat)
local DownEV = Thermostat.setPoint -- Evohome zone Thermostat
local oldTemp = domoticz.variables('recordTempDown').value -- user variable to record last set temperature
local DownTRV = Thermostat.setPoint -- setpoint of Virtual thermostant
if DownEV ~= oldTemp and domoticz.variables('updateBusy').value == 0 then
domoticz.variables('updateBusy').set(1) -- I'm busy
domoticz.devices('Downstairs Thermostat').updateSetPoint(DownEV)
domoticz.variables('recordTempDown').set(DownEV)
print ("***************** Virtual Thermostat Down UPDATED!! to: " ..DownEV.." ********************")
domoticz.variables('updateBusy').set(0) -- Not busy anymmore
elseif
DownTRV ~= oldTemp and domoticz.variables('updateBusy').value == 0 then
domoticz.variables('updateBusy').set(1) -- Set to busy
local myZone = domoticz.devices('Downstairs') -- Evohome zone
local untilDateTime = os.date("!%Y-%m-%dT%TZ",os.time()+7200) -- current time + 2 hours
myZone.updateSetPoint(DownTRV,"TemporaryOverride",untilDateTime)
domoticz.variables('recordTempDown').set(DownTRV)
print ("************ SETPOINT Evohome zone updated " .. myZone.name .. " to: " .. DownTRV .. " , until: " .. untilDateTime .. " *******")
domoticz.variables('updateBusy').set(0) -- Not busy anymore
end
end
}
Re: ELSEIF thermostat not triggering
Posted: Sunday 14 October 2018 19:21
by waaren
EdddieN wrote: Sunday 14 October 2018 18:30
I have an Evohome zone and some Z-Wave thermostats. This kind of works ok, but only the first IF, not the second. What I'm doing wrong?
Basically I can override the temperature from either the Evohome or the Z-wave virtual thermostat. When I override from Evohome it works, but when I override from the virtual thermostant, only the Evohome part triggers.
I think you got your logic wrong here.
The script is triggered by either the evoHome or the virtual sensor and you evaluate the setpoint of whichever triggered the script. Lua doe not know from which sensor you are getting it because you don't give that information. Result is that either the first if evaluates to true and that block will be executed so no evaluation of the 2nd (else) if will take place. Or the first if evaluates to false and because they are effectively looking at the same the 2nd (else)if is also false.
Also your busy variable is not of any use here. The domoticz event system is single threaded meaning that only one script can be executed at the same time so no chance of interference from another sensor. The 2nd script just have to wait until the 1st finished.
If have not tested the script but can you give it a try ?
Code: Select all
--[[
Heating override
]]--
local EvoHome = 'Downstairs'
local virtualThermostat = 'Downstairs Thermostat'
return {
on = { devices = { EvoHome, virtualThermostat }}, -- EvoHome trigger or Virtual Thermostat
logging = { level = domoticz.LOG_DEBUG,
marker = "Heating override" },
execute = function(domoticz, Thermostat)
local downThermostat = Thermostat.setPoint -- Evohome or Virtual Thermostat.setPoint
local oldTemp = domoticz.variables('recordTempDown').value -- user variable to record last set temperature
local trigger = Thermostat.name
if DownEV ~= oldTemp and Thermostat.trigger == virtualThermostat then
-- domoticz.variables('updateBusy').set(1) -- I'm busy This does not make sense. The update will only take place after the script has finished
-- And there can only be one script active at the same time
domoticz.devices(virtualThermostat).updateSetPoint(downThermostat)
domoticz.variables('recordTempDown').set(downThermostat)
print ("***************** Virtual Thermostat Down UPDATED!! to: " .. downThermostat .." ********************")
-- domoticz.variables('updateBusy').set(0) -- Not busy anymmore This does not make sense. The update will only take place after the script has finished
elseif
downThermostat ~= oldTemp and Thermostat.trigger == EvoHome then
-- domoticz.variables('updateBusy').set(1) -- Set to busy This does not make sense. The update will only take place after the script has finished
local myZone = domoticz.devices('Downstairs') -- Evohome zone
local untilDateTime = os.date("!%Y-%m-%dT%TZ",os.time()+7200) -- current time + 2 hours
myZone.updateSetPoint(downThermostat,"TemporaryOverride",untilDateTime)
domoticz.variables('recordTempDown').set(downThermostat)
print ("************ SETPOINT Evohome zone updated " .. myZone.name .. " to: " .. downThermostat .. " , until: " .. untilDateTime .. " *******")
-- domoticz.variables('updateBusy').set(0) -- Not busy anymore This does not make sense. The update will only take place after the script has finished
end
end
}
Re: ELSEIF thermostat not triggering
Posted: Sunday 14 October 2018 19:48
by EdddieN
Ok I get what you are doing now.
One thing missing is reading the value of the thermostat. How do you read the value of Evohome and virtualThermostate setpoint?
I try this but gives me a invalid parsing nil error:
Code: Select all
--[[
Heating override
]]--
local EvoHome = 'Downstairs'
local virtualThermostat = 'Downstairs Thermostat'
return {
on = { devices = { EvoHome, virtualThermostat }}, -- EvoHome trigger or Virtual Thermostat
logging = { level = domoticz.LOG_DEBUG,
marker = "Heating override" },
execute = function(domoticz, Thermostat)
local downThermostat = Thermostat.setPoint -- Evohome or Virtual Thermostat.setPoint
local oldTemp = domoticz.variables('recordTempDown').value -- user variable to record last set temperature
local trigger = Thermostat.name
local DownEV = Evohome.Thermostat.setPoint
local downThermostat = virtualThermostat.Thermostat.setPoint
if DownEV ~= oldTemp and Thermostat.trigger == virtualThermostat then
domoticz.devices(virtualThermostat).updateSetPoint(downThermostat)
domoticz.variables('recordTempDown').set(downThermostat)
print ("***************** Virtual Thermostat Down UPDATED!! to: " .. downThermostat .." ********************")
elseif
downThermostat ~= oldTemp and Thermostat.trigger == EvoHome then
local myZone = domoticz.devices('Downstairs') -- Evohome zone
local untilDateTime = os.date("!%Y-%m-%dT%TZ",os.time()+7200) -- current time + 2 hours
myZone.updateSetPoint(downThermostat,"TemporaryOverride",untilDateTime)
domoticz.variables('recordTempDown').set(downThermostat)
print ("************ SETPOINT Evohome zone updated " .. myZone.name .. " to: " .. downThermostat .. " , until: " .. untilDateTime .. " *******")
end
end
}
Re: ELSEIF thermostat not triggering
Posted: Sunday 14 October 2018 20:14
by waaren
EdddieN wrote: Sunday 14 October 2018 19:48
Ok I get what you are doing now.
One thing missing is reading the value of the thermostat. How do you read the value of Evohome and virtualThermostate setpoint?
I try this but gives me a invalid parsing nil error:
local downThermostat = Thermostat.setPoint
This line reads the setPoint from the device that triggered the script.
Can you show the relevant loglines ?
Re: ELSEIF thermostat not triggering
Posted: Sunday 14 October 2018 20:23
by EdddieN
waaren wrote: Sunday 14 October 2018 20:14
local downThermostat = Thermostat.setPoint
This line reads the setPoint from the device that triggered the script.
Can you show the relevant loglines ?
I need to read the setpoint of both, the ortherwise there's no way to compare the old value. The log is fine, it does not return errors. What happens is that the temperature does not transfer across neither the recordTempDown
The problem is here:
Code: Select all
if DownEV ~= oldTemp and Thermostat.trigger == virtualThermostat then
domoticz.devices(virtualThermostat).updateSetPoint(downThermostat)
domoticz.variables('recordTempDown').set(downThermostat)
print ("***************** Virtual Thermostat Down UPDATED!! to: " .. downThermostat .." ********************")
elseif
downThermostat ~= oldTemp and Thermostat.trigger == EvoHome then
local myZone = domoticz.devices('Downstairs') -- Evohome zone
local untilDateTime = os.date("!%Y-%m-%dT%TZ",os.time()+7200) -- current time + 2 hours
myZone.updateSetPoint(downThermostat,"TemporaryOverride",untilDateTime)
domoticz.variables('recordTempDown').set(downThermostat)
print ("************ SETPOINT Evohome zone updated " .. myZone.name .. " to: " .. downThermostat .. " , until: " .. untilDateTime .. " *******")
end
DownEV and downThermostat have not been declared?
Re: ELSEIF thermostat not triggering
Posted: Sunday 14 October 2018 20:34
by EdddieN
Ok, I think I narrowed it down to this part of the code that is not triggering:
Code: Select all
and Thermostat.trigger == virtualThermostat then
I have put debug info and I can see that trigger = Downstairs Thermostat but when comparing to the virtualThermostat = 'Downstairs Thermostat' it sees them as not equal. Any idea why?
Re: ELSEIF thermostat not triggering [Solved]
Posted: Sunday 14 October 2018 20:41
by EdddieN
Finally, it works by replacing Thermostat.trigger with just trigger
Code: Select all
--[[
Heating override
]]--
local EvoHome = 'Downstairs'
local virtualThermostat = 'Downstairs Thermostat'
return {
on = { devices = { EvoHome, virtualThermostat }}, -- EvoHome trigger or Virtual Thermostat
logging = { level = domoticz.LOG_DEBUG,
marker = "Heating override" },
execute = function(domoticz, Thermostat)
local downThermostat = Thermostat.setPoint -- Evohome or Virtual Thermostat.setPoint
local oldTemp = domoticz.variables('recordTempDown').value -- user variable to record last set temperature
local trigger = Thermostat.name
-- print ("oldtemp " .. oldTemp)
-- print ("Trigger " .. trigger)
-- print ("Setpoint " .. downThermostat)
if downThermostat ~= oldTemp and trigger == EvoHome then
domoticz.devices(virtualThermostat).updateSetPoint(downThermostat)
domoticz.variables('recordTempDown').set(downThermostat)
print ("***************** Virtual Thermostat Down UPDATED!! to: " .. downThermostat .." ********************")
elseif
downThermostat ~= oldTemp and trigger == virtualThermostat then
local myZone = domoticz.devices('Downstairs') -- Evohome zone
local untilDateTime = os.date("!%Y-%m-%dT%TZ",os.time()+7200) -- current time + 2 hours
myZone.updateSetPoint(downThermostat,"TemporaryOverride",untilDateTime)
domoticz.variables('recordTempDown').set(downThermostat)
print ("************ SETPOINT Evohome zone updated " .. myZone.name .. " to: " .. downThermostat .. " , until: " .. untilDateTime .. " *******")
end
end
}
Thank you!
Re: ELSEIF thermostat not triggering
Posted: Monday 15 October 2018 21:07
by EdddieN
One final thing, I hope there's a solution for this.
My setup is as follows: I have the Evohome interface and then a wall mounted tablet with Imperihome. The thermostat in Imperihome changes by 0.5*C each touch so if I'm at 15 and I want to increase to 20*C, Imperihome sends 10 messages to Domoticz.
Then Domoticz as a good tasker starts to increase to 15.5 but before is finished it gets a new one and starts to get in a very long infinite loop of changes with the temperature UP and DOWN. I actually think that part of the culpit is Evohome being a bit slow to respond.
Is there any way to "buffer" or wait for the last command within the last 5 seconds to execute?