Variable schedule time

Hi,

I want to set a variable schedule time to execute a flow based on a device command.

With the Timer Trigger Node I can set a time interval, but is there another trigger to change the time interval to one that varies?

There isn’t a way to dynamically update the Timer Trigger itself, but there are workarounds that could get you close to what you are after.

First, set up an edge workflow with something like …

  1. Device: Command Trigger to listen for commands.
  2. A Conditional Node that verifies the command being received is meant to update the timer interval.
  3. A Storage: Set Value Node to store the updated interval.

Then, in the same workflow (this is necessary if you are going to store the interval in workflow storage) …

  1. A Timer Trigger that runs on a very frequent interval (once a second or even faster).
  2. A Storage: Get Value Node to retrieve the interval from workflow storage.
  3. A Conditional Node that compares the current payload time to your interval.
  4. If the condition matches, the true path contains all the rest of your workflow nodes.

For example, say you retrieve the interval and store at a path of working.interval. In the Conditional Node, you could check if the current Epoch second is evenly divisible by your interval with the following expression, which converts the current time to Epoch seconds using the {{formatDate}} helper and the remainder operator:

{{formatDate time 'X'}} % {{working.interval}} === 0
1 Like