mh... I have a similar issue.... that I did not really fix, but I used a workaround
Use your dummy device as a PushOn button instead of a switch
Use a Variable with a number value of 1, 2 or 3 hours
any push of the dummy button will move ahead and back to 0 once arrived at 3
pushOn button name: pushButton
variable name: pushTime - NUMBER
heater device name: heater
heater Off device name: heatOff
the script would be something like:
Code: Select all
return {
active = true,
on = {
devices = {
'pushButton'
},
},
execute = function(dz, push)
local varName = 'pushTime'
local varActVal = dz.variables(varName).value
local varObj = dz.variables(varName)
local honObj = dz.devices('heater')
local hofObj = dz.devices('heatOff')
-- This will set the variable as a timer... values are hours
if varActVal >= 0 and varActVal <= 3 then
varActVal = varAcVal + 1
else
varActVal = 0
end
-- Let's Update the variable
-- note that the local varActVal has now the new timer value
varObj.set(varActVal)
-- Now let's operate the heater based on the variable value
-- This could be done in the same if cycle above, but here is much clear
if varActVal >= 0 and varActVal <= 3 then
honObj.switchOn()
hofObj.switchOn().afterMins(varActVal*60)
else
hofObj.switchOn()
end
end
}
the only issue is.... I'm unclear and unsure, what happens if you queue a list of
.afterMins commands... by my understanding there is no way to remove them from the domoticz scheduler, so it could be that the device will be switched off at the wrong time:
if you click once it will go for 1hour.... it will beam up and schedule off after 1 hour
if you click again it will go for 2hour.... it will beam up and schedule off after 2 hour
if you click again it will go for 3hour.... it will beam up and schedule off after 3 hour
...but after 1 hour you have the switchOff scheduled command, than again another off command at the second hour, while you are still in need of it!!
and finally a third off at the 3rd hour....
unless there is a way to avoid this, the script should be moved to a timediff parameter and probably split in 2 different script: a device trigger (like above) and a time script to check the time difference
...Thant's my way to approach it

ciao
M