Trigger at given time

I think it would be very handy to have something like device.ontime(yr,mo,da,hr,min,sec) to trigger an event at an entered time. If the more significant date parts are left blank the function would assume the current value of those parameters. For instance device.ontime(12) would trigger on second 12 of the current minute (if it hasn’t already passed). Whereas device.ontime(27,36) would trigger at minute 27, second 36 of the current hour (if not already passed). It would be a variation of imp.wakeup that is tied to a fixed time rather than an elapsed time.

Of course, depending on time stamps would limit to +/- 1 sec. which would generally be okay for the type of applications I envision.

This functionality can be implemented in code, of course. But it would be a nice feature.

Yes that would be a nice feature.

An alternative is to use an external web-service such as cron job via https request.

Good idea. It adds the complication of an external server (service), but a nice simple approach. Think I’ll give that a try.

The limitation of using cron (for my application) just occurred to me. I need to run a job on my device. The cron can only communicate with the agent. That introduces a (sometimes significant) delay to get the agent to in turn message the device. So it’s a bit more involved than it first seemed.

My request for device.ontime(yr,mo,da,hr,min,sec) stands.

This would be a nice thing to implement as a Squirrel library…


For device is there anything wrong with using a separate RTC. I see there is already a device library for the Dallas/Maxim DS3234 real time clock.

Added as a feature to a cron/timer library in the backlog.

Yes, I’m using a separate RTC in other applications. But it adds another chip and increases board density. It seems to me that it should not be a difficult item to add to the imp/squirrel capabilities. The chip is certainly capable of the task. And it impresses me as being useful to many. I’ve also written some code which approximates the function. But it isn’t very precise and wastes processor resources.