I want to convert my mobile phone switches to the amount of people who are at home. At night, I want to trigger the arrival a light to switch on.
Next code gives a log that says who's arriving / leaving. No other logs are given and the User Variable isn't updated. What's wrong?
Code: Select all
return {
on = {
devices = {
'Wouter',
'Marieke'
}
},
logging = {
level = domoticz.LOG_DEBUG,
marker = "iemandThuis - "
},
execute = function(domoticz, device, triggerInfo)
local iemandThuis = domoticz.variables('iemandThuis')
local lamp = domoticz.devices('Banklamp')
domoticz.log('Nu is de bezetting: ', iemandThuis.value)
--local lamp = domoticz.devices('Keukentafellamp')
if device.active then
domoticz.log(device.name .. ' is thuis gekomen', domoticz.LOG_INFO)
if iemandThuis.value == 0 then
domoticz.log('nu moet de uservariable 1 worden')
iemandThuis.set(1)
if domoticz.time.isNightTime then
lamp.switchOn().forMin(20)
--lamp.dimLevel(60)
domoticz.log(device.name .. ' is alleen thuis, daarom keukentafellamp aangezet voor 20 minuten')
end
elseif iemandThuis.value == 1 then
iemandThuis.set(2)
end
else domoticz.log(device.name .. ' is vertrokken', domoticz.LOG_INFO)
if iemandThuis == 2 then
domoticz.variables('iemandThuis').set(1)
elseif iemandThuis == 1 then
domoticz.variables('iemandThuis').set(0)
end
end
end
}