Sun rise/set inside/outside light control

I love how quickly you can throw together different flows to get stuff done in Node-RED.
Here is a super quick example of a simple flow that has a sun position Node and then turns some lights on and off at sunrise/sunset.

To get started, you will probably need to install a new node for this, so read my post on how to add new nodes, then add the ‘suncalc’ node to your palette.

Once you do that, import the following text;

[{“id”:“74579962.1448b8”,“type”:“sunrise”,“z”:“d71eb7e8.d782a”,“name”:“”,“lat”:“33.50207”,“lon”:“-117.15755”,“start”:“sunrise”,“end”:“sunset”,“x”:144,“y”:108,“wires”:[[“e7663bcf.9b9be8”,“42a6ba00.f1d014”],]},{“id”:“42a6ba00.f1d014”,“type”:“change”,“z”:“d71eb7e8.d782a”,“name”:“invert”,“rules”:[{“t”:“change”,“p”:“payload”,“pt”:“msg”,“from”:“1”,“fromt”:“num”,“to”:“0”,“tot”:“num”}],“action”:“”,“property”:“”,“from”:“”,“to”:“”,“reg”:false,“x”:405,“y”:125,“wires”:[[“d5d22f9.2d18c5”]]},{“id”:“e7663bcf.9b9be8”,“type”:“debug”,“z”:“d71eb7e8.d782a”,“name”:“Inside Lights”,“active”:false,“console”:“false”,“complete”:“payload”,“x”:423,“y”:74,“wires”:},{“id”:“a4aa66e9.7fb5a”,“type”:“debug”,“z”:“d71eb7e8.d782a”,“name”:“Outside Lights”,“active”:false,“console”:“false”,“complete”:“payload”,“x”:788,“y”:124,“wires”:},{“id”:“d5d22f9.2d18c5”,“type”:“delay”,“z”:“d71eb7e8.d782a”,“name”:“”,“pauseType”:“delay”,“timeout”:“5”,“timeoutUnits”:“seconds”,“rate”:“1”,“nbRateUnits”:“1”,“rateUnits”:“second”,“randomFirst”:“1”,“randomLast”:“5”,“randomUnits”:“seconds”,“drop”:false,“x”:561,“y”:126,“wires”:[[“a4aa66e9.7fb5a”]]}]

As I said, pretty simple, we stripped out the PAC Nodes that were connected to the digital outputs, just to make it a nice clean import for you, but you get the idea.
The sun rises, the inside lights go on, the outside lights go off.
The sun sets, the inside lights go off, the outside lights go on.
(The delay is in there just to stop a power surge from going through the switchboard - or, in my case, it makes it look a little nicer).

Oh, and I have set the Lat/Long of the node to be in Temecula, CA, USA… I was tempted to set it for Australia and make it all backwards from most Forum reader locations… You can change it to anything you need.