Hi
I have a similar use case to put my heater on low when there is nobody at home and reverse.
And I have very poor info if somebody is home, so I need a lag before triggering the heater.
I have one script to set a evaluate if somebody with 4 values: nobody / perhaps nobody (during your 20 min) / somebody / somebody just arrived
Those 4 values allow to trigger other scripts
Code: Select all
--[[
a dz dzVents Script to evaluate if anybody is at home to trigger something (heater for instance...)
--]]
local DOMAIN = 'YaQuelquUn' -- For logging, as you like!
local SBDY_MANUAL = 425 -- Dummy device to force the presence
local SBDY_RESULT= 451 -- Dummy device to store the result
local SBDY_SENSORS = {395, 385, 369} -- All the SENSORS to detect people
local DEVICES = {395, 385, 369, 203} -- All the devices to trigger the script
local l_maxAuto = 3600*2 -- seconds ; time keep on light on when switch on by SENSORS
local l_maxManual = 3600*4 -- seconds ; time keep on light on when switch on by switch / bigger than l_max_SENSORS
local TIME_INTERVAL = 'every 10 minutes' -- Period to check if nobody, l_maxAuto and l_maxManual to take into accoutn
return {
active = true,
logging = {
level = domoticz.LOG_ERROR, -- Select one of LOG_DEBUG, LOG_INFO, LOG_ERROR, LOG_FORCE to override system log level
marker = DOMAIN
},
on = {
devices = DEVICES,
timer = {TIME_INTERVAL},
},
execute = function(dz, the_device, triggerInfo)
local LOG_LEVEL = dz.LOG_INFO -- LOG_INFO, LOG_DEBUG, LOG_ERROR, LOG_FORCE
dz.log('*** start ' .. triggerInfo.type , dz.LOG_FORCE)
local l_sensorsOn = false
local l_maxOn = l_maxAuto + l_maxManual -- to be sure it is >
for i, f_sensors in pairs(SBDY_SENSORS) do
if dz.devices(f_sensors).active then
l_sensorsOn = true
-- print('active: ' .. dz.devices(f_sensors).name)
else
-- print ('lastupdate.secondsAgo: ' .. dz.devices(f_sensors).lastUpdate.secondsAgo)
if l_maxOn > dz.devices(f_sensors).lastUpdate.secondsAgo then
l_maxOn = dz.devices(f_sensors).lastUpdate.secondsAgo
-- print (' < ' .. dz.devices(f_sensors).name)
end
end
end
local l_sbdy = 0
if l_sensorsOn == true then
dz.log('Somebody there!', LOG_LEVEL)
l_sbdy = 20
else
if l_maxOn < l_maxAuto then
dz.log('Somebody there?', LOG_LEVEL)
l_sbdy = 10
else
dz.log('Nobody', LOG_LEVEL)
end
end
if l_sbdy == 20 then -- Somebody there!
if dz.devices(SBDY_RESULT).level == 0 then -- nobody to somebodymbody
dz.devices(SBDY_RESULT).switchSelector(30)
dz.log('Nobody to somebody there', LOG_LEVEL)
else -- somebody is confirmed
dz.devices(SBDY_RESULT).switchSelector(20) -- other cases to smbody
dz.log('Somebody still there now', LOG_LEVEL)
end
elseif l_sbdy == 10 then -- Somebody there perhaps!
if dz.devices(SBDY_RESULT).level ~= 10 then
dz.devices(SBDY_RESULT).switchSelector(10)
dz.log('Somebody there perhaps!', LOG_LEVEL)
end
elseif l_sbdy == 0 then -- Nobody
if dz.devices(SBDY_RESULT).level ~= 0 then
dz.devices(SBDY_RESULT).switchSelector(0)
dz.log('Nobody now', LOG_LEVEL)
end
end
end}
Note: I started something about a manual mode, but didn't go the end
and another script to pilot my heater
Code: Select all
-- Pilotage Chaudière
local SBDY_RESULT = 451 -- dummy which knows if anyone at home
local PILOT = 427 -- dummy which knows the boiler mode
local TRIGGER = {451, 427, 346} -- {SBDY_RESULT, PILOT, MODE}
local DEVICE = 347 -- device to pilot -- "Saving" Chaudière ECO
local MODE = 346 -- Off 0 ECS 10 Prog. 20 Vac. 30 On 40
local DOMAIN = 'ChaudièreP' -- For logging, as you like!
local TIME_INTERVAL = 'every 1 hours'
return {
active = true,
logging = {
level = domoticz.LOG_ERROR, -- Select one of LOG_DEBUG, LOG_INFO, LOG_ERROR, LOG_FORCE to override system log level
marker = DOMAIN
},
on = {
devices = TRIGGER,
timer = { TIME_INTERVAL },
},
execute = function(dz, the_device, triggerInfo)
local LOG_LEVEL = dz.LOG_FORCE -- LOG_INFO, LOG_DEBUG, LOG_ERROR, LOG_FORCE
local l_status = 'xx' -- status
dz.log('*** start ' .. triggerInfo.type , dz.LOG_LEVEL)
if dz.devices(SBDY_RESULT).level ~= 0 then -- somebody at home
dz.log('Somebody at home' , dz.LOG_LEVEL)
if dz.devices(PILOT).level == 10 and dz.devices(PILOT).level == 20 then -- Normal / Prog.
dz.devices(DEVICE).switchOff().checkFirst() -- suppression du mode saving
l_status = 'Off'
dz.log('ECO to Off' , dz.LOG_LEVEL)
end
else -- nobody at home
dz.log('Nobody at home' , dz.LOG_LEVEL)
if dz.devices(PILOT).level == 10 and dz.devices(PILOT).level == 20 then -- Normal / Prog.
dz.devices(DEVICE).switchOn().checkFirst() -- mode saving
l_status = 'On'
dz.log('ECO to On' , dz.LOG_LEVEL)
end
end
dz.log(dz.devices(DEVICE).name .. ' ' .. dz.devices(DEVICE).state .. ' to ' .. l_status, dz.LOG_FORCE)
end
}
Maybe you could use those scripts for your use case