How do I only pass a motion sensor change between dusk and dawn?


The question mark in the diagram shows where I want to stop the msg from passing through unless it is between dusk and dawn.

Click HERE for a diagram of the flow.

I'm trying to use the BigTimer node. The problem is the status change used as an input also serves as an override. I think BigTimer is more for actually trigging stuff and the input is only used for overrides. I don't think it's made to pass inputs through if the BigTimer node is ON (during the scheduled on period).

1 Like
Telegram + 9x gpio-multi-function-lights + P.I.R + dash all working ;) but need help with a function
Time control using a switch

There are several different ways to do this.

The one I find easiest to understand when I look back at a flow is to use a global variable

Have a separate flow that starts with a sunrise sunset node (there are several) and using a switch node and a change node to set a global variable to true/false

In your existing flow you can then have a switch node that checks to see if the global variable is true or false and only passes messages forward if true


Another idea is:
use a gate node
Connect BigTimer to it so it switches the gate on and off


Bigtimer outputs dusk and dawn times (and many more). Put a debug node set to show the complete message on the middle output and have a look.


I'm working on a general solution for such use cases to make it easy to use. Just install the dsm node and import the flow from the Wiki. Like all NR-nodes you can use it as black box without any knowledge of its internal workings.

It's a first version, so there is no error-handling yet and it can be only used for a day-range.


1 Like

Hi @TheZeke

as you can see, lots of possible ways to do it. The suggestion from @ukmoose can also be seen in action in the node-red cookbook recipe:

The recipe talks about routing a message based on a context value - in this instance, as Mark describes, you'd use the Bigtimer node to keep the context value updated to indicate if it is within the desired time period, and then the Switch node to pass a message on only if the context value set to the desired value.


You may want to try node-red-contrib-sun-position, more especifically the node within-time-switch from the set.

A simple node that routes messages depending on the time. If the current time falls within the range specified in the node configuration, the message is routed to output 1. Otherwise the message is routed to output 2.


I went with this idea... Works well. Thank you!

1 Like