Timeout for lights

Hi,
I am trying to build some sort of a generic flow that will act as a timer.
The idea is for example when I turn the lamp on, and link to that flow (with the link out - link in nodes), with the time and service to call when timeout reached - lamp off, as input, the lamp will turn off on timeout.

I was trying to use the delay node. The thing is that when I turn the lamp off and on again I want the timer to start all over. The first intuition is to use the reset option, but that might reset another timer that runs on another lamp.

Is there any smart idea out there to do that?
I am a programmer, so writing an entire function that holds the state of each timer and manages it is always an option, but it seems to me like a big overkill for that use case.

Thanks :slight_smile:

Use the node-red trigger node. This node can handle multiple messages by topic, so should handle different timeouts without other entities resetting each other.

Thanks for your reply :slight_smile:
The thing is that part of the idea is that I can set the timeout dynamically from the msg object.
Can’t seem to get it to work with the trigger node…

Thanks

Ah ok. The node cannot set different time-outs programmatically. It will handle different inputs I mean. a reset with a specific topic should only reset messages from that topic.

Again, thanks for your reply.
I did manage to a delay for programmatic timeouts, and the trigger for different topics, but I couldn’t find the right combination of nodes to get a programmatic timeouts by topic.