Node-Red flow help/ideas

I need some help/ideas to fix a flow issue im having. So i have a flow that locks my car every night at 9 if its detected home, and not running. If the car is not detected home, the flow stops. That part of the flow works good. I also have a flow that connects to this flow that if it detects the car home between 9-6, then to wait 10 min, and then lock the car as long as its not running. The issue I’m having with that pat of the flow is that throughout the night the car is detected away and then back home, thus its triggering that flow, and locking my car multiple times a night.

My question is, is there a node, or maybe some json code, that i don’t know about that could detect if the lock has already been called within the past coupe of hours, and cancel the flow. Or maybe I’m looking at this to complicated, and theres maybe a more simpler/complex way to accomplish what I’m trying to do. Anyone have any ideas?

You could use a change node to set a global variable when the car first arrives home. You can then compare the current status to the variable and bypass the lock execution node. And then reset the variable when the car leaves.

I assume you can see if the car is locked, yes? Right before the call service add another current state that only sends the lock command if the car is unlocked.