Page 1 of 1
[HELP] power off heating if windows is open, turn back on when it's closed
Posted: Thursday 05 December 2019 16:55
by TheCondor
Hi, i have this script running since the past winter and works fine. Essentially when the sensors on the windows or on the door is open, if the external temperature is lower then internal (so i'm in the situation to lost heating from my house) it shut down the heating system (it put the Netatmo thermostato on "away mode" which is equal to set 12 Celsius for in-house temperature and in my condition it never start).
The current config send a notify to our smartphone and tell us "I shut down the heating... when you'll close all remember to turn off "Away mode"".
Now i want to refine a bit the script and let it automate this last step: when everything is closed again -> restore the previus status of Away Mode. Somebody more experienced can help me on that? Thanks since now!!!
Code: Select all
return {
active = true,
on = {
devices = {'Sensor window bedroom',
'Sensor window bathroom',
'Sensor window kitchen'
}
},
execute = function(domoticz, switch)
if (domoticz.devices('Sensor window bedroom').state == 'Open' or domoticz.devices('Sensor window bathroom').state == 'Open' or domoticz.devices('Sensor window kitchen').state == 'Open') then
if domoticz.devices('Heat_Away_mode).state ~= 'On' then
if (domoticz.devices('Temperature outside').temperature <= domoticz.devices('Temperature inside').temperature) then
domoticz.devices('Heat_Away_mode').switchOn()
domoticz.notify('Heating off for power saving, keep in mind to turn back on', message, domoticz.PRIORITY_NORMAL)
end
end
end
end
}
Re: [HELP] power off heating if windows is open, turn back on when it's closed
Posted: Friday 06 December 2019 0:51
by waaren
TheCondor wrote: ↑Thursday 05 December 2019 16:55
Now i want to refine a bit the script and let it automate this last step: when everything is closed again -> restore the previous status of Away Mode.
Is this what you mean ? If not please explain in more detail what you expect and translate the relevant strings in your code to English.
Code: Select all
return {
active = true,
on = {
devices = {'Sensore Camerina Porta',
'Sensore Soggiorno Finestra',
'Sensore Camera Finestra'
}
},
execute = function(dz, switch)
if dz.devices('Sensore Camerina Porta').state == 'Open' or
dz.devices('Sensore Soggiorno Finestra').state == 'Open' or
dz.devices('Sensore Camera Finestra').state == 'Open' then
if dz.devices('Heat_Away_mode).state ~= 'On' then
if (dz.devices('Temperatura Terrazzo').temperature <= dz.devices('Temperatura Ingresso').temperature) then
dz.devices('Heat_Away_mode').switchOn()
dz.notify('Riscaldamenti spenti per risparmio energetico, ricordati di riaccenderli manualmente', message, dz.PRIORITY_NORMAL)
end
end
else -- All closed
dz.devices('Heat_Away_mode').switchOff().checkFirst()
end
end
}
Re: [HELP] power off heating if windows is open, turn back on when it's closed [Solved]
Posted: Friday 06 December 2019 9:34
by TheCondor
waaren wrote: ↑Friday 06 December 2019 0:51
TheCondor wrote: ↑Thursday 05 December 2019 16:55
Now i want to refine a bit the script and let it automate this last step: when everything is closed again -> restore the previous status of Away Mode.
Is this what you mean ? If not please explain in more detail what you expect and translate the relevant strings in your code to English.
Hi, thanks for your kind reply. I edited the first topic with the device name in english. I had in mind something that at first launch check the state of 'Away Mode' and put it in a variable. Then do the check over the inside-ouside temperature and eventually stop heating and when is all closed again restore the previous state (variable) but it will not work. I'll go with your suggest and use the inside-outside temperature compare as the only reference for decide if "away mode" should be on or off. It makes sense. Thanks!
Re: [HELP] power off heating if windows is open, turn back on when it's closed
Posted: Friday 06 December 2019 20:53
by TheCondor
Hi again, i need to add a delay, otherwise every time i open/close a Windows It change the state of 'Away mode' and thermostat going Crazy.
How can i script something likes:
If WindowsSensor Is open for X time the
AwayMode.switch(off)
Thanks
Re: [HELP] power off heating if windows is open, turn back on when it's closed
Posted: Friday 06 December 2019 21:17
by waaren
TheCondor wrote: ↑Friday 06 December 2019 20:53
Hi again, i need to add a delay, otherwise every time i open/close a Windows It change the state of 'Away mode' and thermostat going Crazy.
This will add a 5 minute delay before setting 'Away mode' if all windows are closed again within that time frame, the 'Away mode' will not be set.
Code: Select all
return {
active = true,
on = {
devices = {'Sensore Camerina Porta',
'Sensore Soggiorno Finestra',
'Sensore Camera Finestra'
}
},
execute = function(dz, switch)
if dz.devices('Sensore Camerina Porta').state == 'Open' or
dz.devices('Sensore Soggiorno Finestra').state == 'Open' or
dz.devices('Sensore Camera Finestra').state == 'Open' then
if dz.devices('Heat_Away_mode).state ~= 'On' then
if (dz.devices('Temperatura Terrazzo').temperature <= dz.devices('Temperatura Ingresso').temperature) then
dz.devices('Heat_Away_mode').switchOn().afterSec(300) -- 5 minute delay before action
dz.notify('Riscaldamenti spenti per risparmio energetico, ricordati di riaccenderli manualmente', message, dz.PRIORITY_NORMAL)
end
end
else -- All closed
dz.devices('Heat_Away_mode').cancelQueuedCommands()
dz.devices('Heat_Away_mode').switchOff().checkFirst()
end
end
}
Re: [HELP] power off heating if windows is open, turn back on when it's closed
Posted: Saturday 07 December 2019 16:58
by TheCondor
works exactly as i expect!!! Thanks!!!
Re: [HELP] power off heating if windows is open, turn back on when it's closed
Posted: Monday 09 December 2019 16:52
by TheCondor
i post here the final script, maybe someone could find it useful for its setup:
Basically i have 3 contact sensor on 3 windows and a Netatmo thermostat. Netatmo Away Mode put directly the termostat setpoint at 12 Celsius, it is a current netatmo function.
When any of the three windows is open, the current Away Mode status is checked, if alread On (so setpoint is currently at 12 C, a so low temperature in my house is impossible to reach so the heating system is off for sure) it does nothing.
If instead Away Mode is off, so the heating could be working, it compare the current set-point temperature with the currente in house temperature (provided by the netatmo thermostat itself), only if the first over than the second (set point > current home temp) it shut down the system by turning on Away Mode AFTER 10 minutes.
In this way not every time i open the windows the thermostat is touched, just after a concrete time frame which cause a sensible heating power loss (and $$$).
When the windows are back closed the Away Mode turn off.
Code: Select all
return {
active = true,
on = {
devices = {'Sensor Windows 1',
'Sensor Windows 2',
'Sensor Windows 3'
}
},
execute = function(domoticz, switch)
if (domoticz.devices('Sensor Windows 1').state == 'Open' or domoticz.devices('Sensor Windows 2').state == 'Open' or domoticz.devices('Sensor Windows 3').state == 'Open') then
if domoticz.devices('Netatmo Away Mode').state ~= 'On' then
if (domoticz.devices('Temp External').temperature <= domoticz.devices('Temp Netatmo inside').temperature) and domoticz.devices('Netatmo Set-point').setPoint >= domoticz.devices('Temp Netatmo inside').temperature then
domoticz.devices('Netatmo Away Mode').switchOn().afterSec(600)
end
end
else
domoticz.devices('Netatmo Away Mode').cancelQueuedCommands()
domoticz.devices('Netatmo Away Mode').switchOff().checkFirst()
end
end
}