I hope someone can help me, Iḿ not very good with scripting.
I found this script that shutdown the heating when the door is opened. That works very good. The problem is that I would make a dependency for this script from a dummy device, in my case Thermo_Pause.
If this device is on the script must not work. If have looked for an example but I couldn find one.
Code: Select all
local scriptVar = 'heatingControl'
local doorContact = 'Achterdeur'
return
{
on =
{
devices =
{
doorContact,
},
customEvents =
{
scriptVar,
},
},
data =
{
lastSetpoint =
{
initial = -99,
},
},
logging =
{
level = domoticz.LOG_ERROR, -- change to LOG_ERROR when all OK
marker = scriptVar,
},
execute = function(dz, item)
local delay = 60
local thermo = dz.devices('Thermo target temperatuur')
local door = dz.devices(doorContact)
if item.isDevice then
dz.log('Contact ' .. item.name .. ' state is ' .. item.state, dz.LOG_DEBUG)
if item.state == 'Open' and dz.data.lastSetpoint == -99 then
dz.emitEvent(scriptVar).afterSec(delay)
elseif item.state ~= 'Open' and dz.data.lastSetpoint ~= -99 then
thermo.updateSetPoint(dz.data.lastSetpoint)
dz.data.lastSetpoint = -99
end
else
if door.state == 'Open' and dz.data.lastSetpoint == -99 then
dz.data.lastSetpoint = thermo.setPoint
thermo.updateSetPoint(15)
end
end
end
}