Page 1 of 1
Timer trigger for every second day [Solved]
Posted: Thursday 09 July 2020 18:15
by zavjah
Hi there,
I'd like to have my watering started every second day and was wandering is there a trigger similar to 'every odd day' or 'every other day'?
Thanks for help and cheers,
Zavjah
Re: Timer trigger for every second day
Posted: Thursday 09 July 2020 19:39
by waaren
zavjah wrote: Thursday 09 July 2020 18:15
I'd like to have my watering started every second day and was wandering is there a trigger similar to 'every odd day' or 'every other day'?
Code: Select all
-- This one executes on odd days (jan 1 = 1 and feb 1 = 32, etc ) at 19:38
return
{
on =
{
timer = { function(domoticz) return os.date('*t').yday % 2 == 1 and domoticz.time.matchesRule('at 19:38') end },
},
execute = function(dz)
dz.log('Do stuff on odd days',dz.LOG_FORCE)
end
}
Code: Select all
-- This one executes every other day at 19:38 (Thx to @jvdz )
return
{
on =
{
timer = { function(domoticz) return math.floor(os.time()/86400) % 2 == 1 and domoticz.time.matchesRule('at 19:38') end },
},
execute = function(dz)
dz.log('Do stuff every other day',dz.LOG_FORCE)
end
}
Re: Timer trigger for every second day
Posted: Friday 10 July 2020 14:21
by zavjah
Awesome, thank you

Re: Timer trigger for every second day
Posted: Friday 10 July 2020 15:05
by jvdz
Don't think this test is "full-proof":
The last day of this year and first day of next year will both be oneven:
31-12-2020 = 365
1-1-2021 = 1
.. so on 1 - jan - 2021 the script will run without the one day gap.
You probably need to work with the
juliandate days since Epoch.
maybe:
Code: Select all
math.floor(os.time()/60/60/24) % 2 == 1
Jos
Re: Timer trigger for every second day
Posted: Friday 10 July 2020 20:06
by waaren
jvdz wrote: Friday 10 July 2020 15:05
The last day of this year and first day of next year will both be oneven:
maybe:
Code: Select all
math.floor(os.time()/60/60/24) % 2 == 1
Thx. Nice catch. I add this to my post so OP can choose