Once a week reset

Hi all.
Looking for a suggestion. I need to reset some counters as soon as 1 second after midnight on a monday or if the system is off for whatever reason, as soon as it comes back on as long as it hasn’t already been done that week. I was trying to get a week number and store that in a persistent file and may have to end up doing that but is there an easier way?

Hi there… I am sure that there are multiple ways in which this can be done. This is one way. Create an input boolean in HA which can be switched on if the reset has been done. This will be useful to check if the reset has been done already. In case of scheduling in node red, you can try something like this.

The below is the code but make sure you change to your relevant parameters

[{"id":"80ba45d7.6785d8","type":"inject","z":"51045e07.bbf87","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 00 * * 1","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":250,"y":120,"wires":[["136ea9b5.1bba56"]]},{"id":"136ea9b5.1bba56","type":"delay","z":"51045e07.bbf87","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":400,"y":120,"wires":[["287bae82.dbca22","b95699bf.0c2038"]]},{"id":"7d1ad844.bb94e8","type":"api-current-state","z":"51045e07.bbf87","name":"Check Input Boolean is On","server":"d177950.2a5aa68","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.notify_home","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":620,"y":180,"wires":[[],["2010ad94.6c2c02","406ab6c3.4666d8"]]},{"id":"287bae82.dbca22","type":"api-call-service","z":"51045e07.bbf87","name":"Call Services to Reset","server":"d177950.2a5aa68","version":1,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":580,"y":120,"wires":[[]]},{"id":"687d88fc.021748","type":"server-state-changed","z":"51045e07.bbf87","name":"Device offline","server":"d177950.2a5aa68","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"switch.adguard_protection","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"offline","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":230,"y":180,"wires":[["9ce738df.b21708"],[]]},{"id":"9ce738df.b21708","type":"ha-wait-until","z":"51045e07.bbf87","name":"Wait For Online","server":"d177950.2a5aa68","outputs":1,"entityId":"switch.adguard_protection","entityIdFilterType":"exact","property":"state","comparator":"is","value":"online","valueType":"str","timeout":0,"timeoutType":"num","timeoutUnits":"seconds","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":400,"y":180,"wires":[["7d1ad844.bb94e8"]]},{"id":"b95699bf.0c2038","type":"api-call-service","z":"51045e07.bbf87","name":"Input Boolean Off","server":"d177950.2a5aa68","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.notify_home","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":570,"y":80,"wires":[[]]},{"id":"2010ad94.6c2c02","type":"api-call-service","z":"51045e07.bbf87","name":"Call Services to Reset","server":"d177950.2a5aa68","version":1,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":860,"y":180,"wires":[[]]},{"id":"406ab6c3.4666d8","type":"api-call-service","z":"51045e07.bbf87","name":"Input Boolean On","server":"d177950.2a5aa68","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_on","entityId":"input_boolean.notify_home","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":850,"y":220,"wires":[[]]},{"id":"d177950.2a5aa68","type":"server","name":"Home Assistant","legacy":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Yep thats a good idea. Can’t believe I didnt think of that. I kind of do that for other stuff…