Hi all,
Thanks to the great help of this forum Inwas able to use dzvents for my energy meter. I have a script to copy the current week total to another device to store it as last week. A timer running each saturday at 23:55 does that job.
Now I want something similar for the month values. Like “rune every last day of the month at 23:55”. Should be possible but I am not able to figure that out.
Can’t be difficult, but I don’t see it...
Help appeciated. As always
How to set timer to last day of the month
Moderator: leecollings
-
- Posts: 60
- Joined: Wednesday 29 May 2019 14:39
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Location: Zwolle
- Contact:
-
- Posts: 505
- Joined: Sunday 01 November 2015 22:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: Twente
- Contact:
Re: How to set timer to last day of the month
Cron does the job.
Take a look over here.
I'm testing this one:
If you're lucky to be using one of those implementations, it's as simple as:
55 23 L * * ?
Take a look over here.
I'm testing this one:
If you're lucky to be using one of those implementations, it's as simple as:
55 23 L * * ?
Bugs bug me.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: How to set timer to last day of the month
This could do itKranendijk wrote: ↑Thursday 28 January 2021 18:53 Now I want something similar for the month values. Like “rune every last day of the month at 23:55”. Should be possible but I am not able to figure that out.
Code: Select all
return
{
on =
{
timer =
{
'at 23:55 on 28/2,29/2,30/*,31/*',
},
},
execute = function(dz, item)
if os.date("%d", os.time() + 24 * 3600 ) ~= '01' then
dz.log(item.trigger .. " ==>> today is not the last day of the month" , dz.LOG_FORCE)
return
else
dz.log(item.trigger .. " ==>> today is the last day of the month" , dz.LOG_FORCE)
end
dz.log('rest of the script below this line', dz.LOG_FORCE )
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 60
- Joined: Wednesday 29 May 2019 14:39
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Location: Zwolle
- Contact:
Re: How to set timer to last day of the month
Really. That simple??
I’ll give it a shot, big thanks!
I’ll give it a shot, big thanks!
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: How to set timer to last day of the month
True but in the execute part of the script there is an extra check that will stop the execution of the script if it is not the last day of the month, before the scripts real work starts.
Do you know a better way in pure dzVents ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 505
- Joined: Sunday 01 November 2015 22:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: Twente
- Contact:
Re: How to set timer to last day of the month
Correct @waaren
For simplicity you could trigger it every day as well, like:
For simplicity you could trigger it every day as well, like:
Code: Select all
return
{
on =
{
timer =
{
'at 23:55',
},
},
execute = function(dz, item)
if os.date("%d", os.time() + 24 * 3600 ) ~= '01' then
dz.log(item.trigger .. " ==>> today is not the last day of the month" , dz.LOG_FORCE)
return
else
dz.log(item.trigger .. " ==>> today is the last day of the month" , dz.LOG_FORCE)
end
dz.log('rest of the script below this line', dz.LOG_FORCE )
end
}
Bugs bug me.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: How to set timer to last day of the month
The time rule looks indeed a bit intricate at first but that is only once and you save 365 - 19 = 346 unnecessary script triggers yearly by using it.
I can live with both approaches
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 505
- Joined: Sunday 01 November 2015 22:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: Twente
- Contact:
Re: How to set timer to last day of the month
Correct again @Waaren
I like script simplicity and computers don't care about repetition.
How many times a day is this script being run to check if it's 23:55?
I like script simplicity and computers don't care about repetition.
How many times a day is this script being run to check if it's 23:55?
Bugs bug me.
Who is online
Users browsing this forum: No registered users and 1 guest