Question about the schedex node

I do have a question.
What happens if the schedule is from 6:00 hr until sunrise and the sunrise is before 6:00?
Will at 6:00 the light go on and stops next sunrise? (A day later?)
Or will there nothing happening, because sunrise is before 6:00?

Nobody knows the result?

When asking about a particular contrib- node it is helpful to provide the exact name, or better still the link to the node in the NR library, so as to avoid confusion.

Assuming that you are talking about the node-red-contrib-schedex (node) - Node-RED node (there are two nodes with this name) …

The documentation specifically mentions that:

Times

Note that on and off times are independent.

therefore there is no implied relationship between the “on” event and the corresponding node “off” event. This node cannot provide a schedule such as “on between 06:00 and sunrise” but rather two separate and independent events - “on at 06:00” and “off at sunrise”. Hence, when sunrise occurs just before 06:00, the off will precede the on rather than the other way around.

A simple experiment around sunset (more convenient than dawn) does indeed show that a fixed “on” at 17:00, with an “off” at sunset when sunset is 16:50 (10 minutes prior) has the outcome of being “on” for 23 hours and 50 minutes.

So no, the node does not have magical powers to associate the on and off times in a given rule-order.

However…

This node offers a range of input control methods, which can be used to suspend the ‘schedule’ in the situation where a “sunrise off” precedes a “fixed time on” event.

Sending input message payload as “info_local” to the node returns an object with the next on and off times (local not UTC). Providing this is done either before or after both sunrise and 06:00, the ISO format times returned can be compared to test for “sunrise time < fixed 06:00 time”, where both times will be upcoming and for the next sunrise period. This node, like many others, updates the ‘sunrise’ event to show the next one, so before sunrise it will be sunrise today, and after sunrise it will be sunrise tomorrow.

If it is the case that the ‘off’ precedes the ‘on’, an input message with payload.suspend set to true can be used disable the node schedule.

Hence a trigger node set to inject “payload.info” at say 10:00 after sunrise, then a change node to compare the outcome object times and return a boolean value in “payload.suspend” provides the necessary additional logic.

Since this requires a loop back into the same node, care is required to ensure that this does not form an infinite loop (ie the feed-back suspension command must not generate a further output message, which it does not).

Once the node has been set to ‘suspended’, the info_local return shows “suspended” in the node state and both on and off times, and the comparison test no longer works. It therefore requires two actions - 1) to un-suspend the node first, so that 2) use of info_local will return the next on/off times, then a simple comparison test for off-time < on-time, and send the suspend boolean back to the node.

I have set this up and tested, and it seems to work nicely. The ‘reset and test’ trigger needs to occur either before the ‘on’ (test for upcoming today) or well after any ‘sunset off’ (test for tomorrow).

Not necessarily something that anyone would want to use, but an interesting exercise nevertheless.

[{"id":"b33fe30cfb11a59d","type":"inject","z":"dc25556591dc08be","name":"after 'sunrise off' - restore & test","props":[{"p":"payload.suspended","v":"false","vt":"bool"}],"repeat":"","crontab":"00 10 * * *","once":false,"onceDelay":0.1,"topic":"","x":200,"y":3400,"wires":[["bdc6da460d258c3c","755321ed2b37353b"]]},{"id":"bdc6da460d258c3c","type":"schedex","z":"dc25556591dc08be","name":"","passthroughunhandled":false,"suspended":false,"lat":"","lon":"","ontime":"07:00","ontopic":"ON","onpayload":"turn-on","onoffset":0,"onrandomoffset":0,"offtime":"sunrise","offtopic":"OFF","offpayload":"turn-off","offoffset":0,"offrandomoffset":0,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":620,"y":3400,"wires":[["7e01b3dc11d966aa"]]},{"id":"a45b79c40795226b","type":"debug","z":"dc25556591dc08be","name":"info output","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1150,"y":3400,"wires":[]},{"id":"755321ed2b37353b","type":"delay","z":"dc25556591dc08be","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":440,"y":3360,"wires":[["409b991b037f741b"]]},{"id":"409b991b037f741b","type":"change","z":"dc25556591dc08be","name":"read info_local","rules":[{"t":"set","p":"payload","pt":"msg","to":"info_local","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":3360,"wires":[["bdc6da460d258c3c"]]},{"id":"7e01b3dc11d966aa","type":"switch","z":"dc25556591dc08be","name":"","property":"topic","propertyType":"msg","rules":[{"t":"neq","v":"info","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":770,"y":3400,"wires":[["4b0e56c53e93841e"],["fdcb0cc8fc242a84"]]},{"id":"4b0e56c53e93841e","type":"debug","z":"dc25556591dc08be","name":"schedule output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":960,"y":3320,"wires":[]},{"id":"fdcb0cc8fc242a84","type":"change","z":"dc25556591dc08be","name":"set suspended","rules":[{"t":"set","p":"payload.suspended","pt":"msg","to":"payload.off<payload.on","tot":"jsonata"},{"t":"delete","p":"payload.lon","pt":"msg"},{"t":"delete","p":"payload.lat","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":940,"y":3400,"wires":[["a45b79c40795226b","bdc6da460d258c3c"]]},{"id":"adea945c1a8b4a16","type":"global-config","env":[],"modules":{"node-red-contrib-schedex":"1.10.7"}}]

Thanks for the effort. You made it very Clear. I did expect such, but you proofed it.
I do need a minimum amount of of light time a day for my birds. Thats the reason i want this option