This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.

The Homey Community has been moved to https://community.athom.com.

This forum is now read-only for archive purposes.

Random time?

Hi,

I can't find an option to trigger a flow by a sort of random timer. Has anyone a workaround to do this?

Example: Start flow at a random time between 10:00h and 12:00h. So it can start at 10, but maybe it starts at 11:06 or 10:42, etc.


Comments

  • EmileEmile Administrator, Athom
    edited August 2016
    You can create a random delay in an action by adding a dash, e.g: 10-50 will fire anywhere between 10s and 50s
  • I'm sure there should be some sort of option feasible with Better Logic; this has $timenow$, the current time since epoch, and can use math.js's features, including math.randomInt([min, max]) .

    Not sure how this should be implemented exactly (I guess getting a variable between 0 and 120 at 10:00, and checking every minute if that variable has passed the $timenow$ after this has been corrected for that day at 10:00, which should be available via a modulo operator ($timenow$ % 1440).
  • keverjeroenkeverjeroen Member
    edited June 2016
    Emile said:
    You can create a random delay in an action by adding a comma, e.g: 10,50 will fire anywhere between 10s and 50s
    That's what I'm looking for! Thanks!

    p.s. I can not type a comma in the delay field! Workaround is to copy -> paste it from a textdocument.

    I'm sure there should be some sort of option feasible with Better Logic; this has $timenow$, the current time since epoch, and can use math.js's features, including math.randomInt([min, max]) .

    Not sure how this should be implemented exactly (I guess getting a variable between 0 and 120 at 10:00, and checking every minute if that variable has passed the $timenow$ after this has been corrected for that day at 10:00, which should be available via a modulo operator ($timenow$ % 1440).
    This sounds really interesting, but for now I'm going to try Emile's suggestion!  ;)
  • @keverjeroen: Haha I would do the same! Emile beat me while I was writing the post ;)
  • Just a quick one for any future finders of this thread.  At some point the random delay changed to be dash rather than comma separated.  Careful as Emile edited the original post but I read the comma version in the quote on @keverjeroen post and just scratched my head for a few mins when it didn't work ;)
Sign In or Register to comment.