Check of 1st second of a minute

Hi there

I try to change an existing app I added to MyApps, but I couldn’t find any hint in the developers guide nor the community forum for the following:

I would like to add a condition, that a code only executes, if it is a particular second of the minute e.g. every 1st second of a minute.

In prosa:
If the second of the actual time equals 1 then do the following.

Can someone assist me in this?

Best regards

I didn’t think anything could be scheduled to run faster then once a minute from what I read.

Whats the use case?

The use case is, that I have a logging extension, which writes events with every change. That’s once a second wich a powermeter, which floods the target. So I would like to write the data only once a minute. Therefore I would like to trigger it on a particular second of every minute to achieve it.

So it is not a scheduler, but a limiter.

Couldn’t you just schedule a routine to run once a minute and push your data, whatever is available, at that time? Or even average out the values over that minute and send the average?

Im already doing this and it’s easier than you think.

Code your SmartApp to cache values from the power events to a state variable. When the first even comes in, execute a runIn(60), set a flag so runIn doesn’t get called again, then write the data to the logger when the function is called by runIn(), at which point you reset the flags the process repeats.

This model uses the actual events received from the power meter as the trigger, eliminating the need to be concerned with a reliable scheduler. It also allows the scheduler to be self-healings once it’s triggered by the power event.