hamsando / node-red-contrib-stoptimer-varidelay

Apache License 2.0
7 stars 2 forks source link

Restart without reset #8

Closed andersonimes closed 3 years ago

andersonimes commented 3 years ago

Hello! I have a scenario where I'd like my lights to:

  1. Turn on for two minutes due to motion
  2. If I press the wall switch for that light, have the light stay on for 20 minutes instead
  3. Have either the two minute time or the 20 minute timeout refreshed with additional motion

So basically I want to have the ability to change the delay (this works!), but additional motion actions I want to merely reset the clock as is, rather than back to the default 2 minutes. What's your recommended way of solving this? It's so close, but motion events completely reset the delay rather than just restarting it to what it was last overriden to.

andersonimes commented 3 years ago

Here is my current flow to show you what I mean. It is super close to working correctly. If it didn't reset the timer and instead just restarted it, it'd be perfect.

door light flow
hamsando commented 3 years ago

Would it work for you if you set a flow variable (lets say currentDelay) in your two function nodes (to 2 or 20 respectively), and have the motion detection outputs go into a change node which sets msg.delay to flow.currentDelay before going into the timer?

Like this (showing just part of your flow above) image

andersonimes commented 3 years ago

Yeah, that will probably work! Thanks!