Does anyone here know how long a flow can stay active if there are active cards in it? When will GC destroy it?
The reason I’m asking is that I’ve made a very useful function in my app (it’s in the test stage now) where the user can tell it to wait for a device to set a certain state.
One use-case could be that you would want to check if the door is opened within 20 minutes of the lights coming on (probably a bad example). Instead of creating another flow activating on “door opened” and then having the hazzle of enabling and disabling it etc, you can now just set my card to wait for 20 minutes to see if the door opens, and if so just continue the flow. The card will be recycled on every flow restart, and you can enable/disable it from wherever. You can even tell it to stop waiting.
So…is this possible? Anyone else seeing any use-cases?
The reason I’m working on my app is that I just hate the usual “it’s not electronics” and “you can’t use boolean algebra” types of answers. It kind of bugs me enough that I just need to find a way around it - and try not to make impractical solutions just because “take that!”
Also, flows don’t get garbage collected. They may get stopped when one takes too long, but you’d have to test to see if that actually happens (should be a simple enough test, instead of waiting for your device, just insert a delay for 20 minutes and see if the flow continues to run after that).
The sustained values feature is actually kind of the opposite of what I’m doing, but I do see the overlap. Mine can check any capability and has the option of of enabling/disabling the card in addition to tell it to stop waiting.
I’ve done a check where I turn a light off, ask it to wait for the light to come back on inside 45 minutes and turn it back on after 30. That works. I’m thinking about how I can test it for many more hours - or even days.
Don’t trust the JS internal timers too much in terms of accuracy (they’re okay for “about 3 days”, but not for “exactly 3 days, nothing more, nothing less”). Also, consider what should happen if Homey gets rebooted (for instance with automatic updates).