Device acting on real-time triggers?

Hello? Can the imp device call a function for a predetermined time? Say I create a 5:00PM trigger, how can I make the imp act at that time? Do I have to poll the time, say every minute, until the time is reached, then call the function? Thanks!

I suspect you’ll be interested in server.sleepuntil… give it a go, and let us know if you have any questions :slight_smile:

You may also want to consider the imp.wakeup option which can set a timer at a predetermined time. Works on number of seconds before wakeup etc. link explains in more detail.

I need the imp running continuously though… DMX… I don’t think sleep will work out. I can poll the time every minute I assume. Thanks.

If it’s wall powered (i.e. power isn’t an issue) then imp.wakeup is the way to go.

If I recall, the imp.wakeup API isn’t super accurate over long periods of time (it’s not meant for things like “wake up in exactly 12 hours, 3 minutes, and 53.4 seconds”). A strategy of checking how far the target time is every hour or half hour (and doing shorter imp.wakeups as you get closer) would probably work well if timings are really critical.

@beardedinventor - is the long period accuracy still an issue in Release 32?

“Improved imp.wakeup() accuracy over long wake-up periods” is listed on the release notes…

The wakeup accuracy is indeed bang on in release 32 :slight_smile:

Huzzah! Please feel free to throw my previous comment in the garbage :slight_smile: