random on / random duration
Posted: Wednesday 18 December 2019 18:08
dzVents allows randomised switch times using withinMin(minutes) etc but I've been unable to find anything in dzVents for a randomised duration. Here's the code to operate a switch with random on times and random duration ...
Code: Select all
return {
on = {
timer = {'every 30 minutes'}
},
execute = function(dz)
local n = tostring(math.random(5, 15))
if( dz.time.matchesRule('between sunset and 23:00') ) then
dz.devices(15).switchOn().withinMin(15).forMin(n)
end
end
}