Help with node-red-contrib-sunevents

Hello all.

Something easy I am sure. But I don’t know how to use this node. I have read the documentation and I have got a flow and the output on the debug node shows the following.

02/09/2021, 06:00:33node: Sunset
msg : string[59]
"calculating sunevents for lat -26.813529 and lng 153.087156"
02/09/2021, 06:00:34node: 9e0d442f65b38a7f
msg.payload : Object
{ latitude: -26.813529, longitude: 153.087156, sunevent: "sunrise" }
02/09/2021, 06:00:36node: 9e0d442f65b38a7f
msg.payload : Object
{ latitude: -26.813529, longitude: 153.087156, sunevent: "sunriseEnd" }

Now the part I am having an issue with is how do I use that to do stuff at say sunrise or sunset.

I use the sunrise node but its the same concept. When the sunrises it sends 0 and 1 for sunset. You need to use a switch node to filter the sunrise message to one output and sunset to another.

[{"id":"6cd1edae.a9b8b4","type":"sunrise","z":"24e54e48.fd06f2","g":"7873948.5ba166c","name":"","lat":"","lon":"","start":"sunriseEnd","end":"sunsetStart","soff":0,"eoff":0,"x":250,"y":760,"wires":[[],["1d5683bc.0b6ff4"]]},{"id":"1d5683bc.0b6ff4","type":"switch","z":"24e54e48.fd06f2","g":"7873948.5ba166c","name":"on off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":450,"y":760,"wires":[["e78523.b1d82ae","41c8651e.b0337c"],["91ffd29c.a59518"]]}]

Thanks.

I had a switch node with sun events but I still couldn’t get it to work. I will give this a try.

When the message comes through on the debug, go to the sunrise/sunset, where it says copy path and click that button.

image

In the change node paste that to the message path

@Mikefila thanks for that. Now have it working correctly.

Ran into another issue though.

So instead of starting a new thread.

I have a switch block that is now changing the state of an input Boolean. How do I get that same Boolean to toggle again after the sun event has changed?

I tried a change mode but that didn’t work.
This is how it looks at the moment.

You can use the next event