Logic Machine Forum
Scheduled script: reliability of operation - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Scheduled script: reliability of operation (/showthread.php?tid=5783)



Scheduled script: reliability of operation - Domoticatorino - 10.12.2024

Dear all,
I need set a scheduled script which runs only one time at a specific time the first day of the month. Script runs to reset a value of a group address of a energy data consumption. 

In case for any reason (example LM is off in that moment) script can not be done, how can manage the script in order to be sure to erase the data?

Thank you for your suggestion.

Regards.

BR


RE: Scheduled script: reliability of operation - Daniel - 10.12.2024

Just set minute, hour and day of the month as you need. All months and every day of the week.


RE: Scheduled script: reliability of operation - Domoticatorino - 10.12.2024

(10.12.2024, 10:23)Daniel Wrote: Just set minute, hour and day of the month as you need. All months and every day of the week.hI dN

Thank you David but probably I have not been cleared.

Group address I want to erase is related to energy consumption energy. I mean that the first day of the month its value is 0 and after 1 month energy consumption will show.

This is the reason why script to erase the data must run just for one time at the beginning of the month. 

Have you any idea?

Thanks.


RE: Scheduled script: reliability of operation - admin - 10.12.2024

Set the scheduled script to run as often as needed. Add this code block so the reset procedure runs only once per month.
Code:
curr_date = tonumber(os.date('%Y%m'))
prev_date = storage.get('reset_date', 0)

if prev_date < curr_date then
  log('reset')
  storage.set('reset_date', curr_date)
end