Is there a way to reset the time that an alarm is called using TimeAlarms library?

@BKO has made available a great tool with TimeAlarms. I am wondering if there is an elegant way to solve changing a recurring alarm’s firing time.

I would like to have an alarm control a thermostat setback time in the morning and evening for my greenhouse.
For example, run a heater or fans to try and achieve a target of 62F between 6PM and 6AM and run fans/heater to target 80F between 6AM and 6PM. At different times of the year I would like to be able to use a spark function to change these times and target temperatures. Passing the parameters is easy, so a little help on the best way to solve the timer issue would be much appreciated.

I can see two ways I might do this:

  1. set up an alarm to fire every day at midnight and in the function called have it set two single use timers that fire at xAM and yPM and pass the values from variable that are set via a spark function. Every day this would be recreated by the first recurring alarm function call. The functions called by the timers would active the desired program.

  2. In looking at the TimeAlarm code, it looks like one can free a timer and put it back into the pool by calling it’s ID number. Could I instead have a spark function that that called the free function for the existing timers and then created two new ones? I only need to do this a few times per year.

Beyond the goal of having this flexibility to reprogram, I want to make sure it is as robust as possible as it is somewhat mission critical to achieve the target temperatures. I live in san diego so it’s not like the plants will freeze or incinerate, but I want to make sure I don’t end up with issues created by running out of memory due to creating new timers without freeing up memory from the destroyed ones. Certainly open to thoughts about which of these might be better or other solutions I haven;t thought of.

Thank you!

1 Like