Sunrise / sunset times with night day output node

I'm looking for a node that will give me the sunrise and sunset times for a day plus an output that just says night or day. I've looked at sunevents, bigtimer, sunrise nodes and they will all calculate the times or output a msg at the time or sunrise or sunset but they won't give me the sunset time for tonight or sunrise time for tomorrow. I've looked at several nodes that calculate the times but don't give a simple output of night or day in addition to the time. I can add a function to do the calculations but if there is a node that outputs the data then I'm all in for it. Has anyone run across a node out of the thousands that will give sunrise, sunset times and a simple night or day , true or false output as well?
Thanks.

found one that will work,
Thanks anyway

1 Like

Um,

Yes they do. Or at least I can say bigtimer does.

I use it for just that purpose.

Screenshot from 2020-01-30 15-32-08

That is telling me today the sun rises at 06:16 and sets at 20:clock1030:After 20:03 it tells me tomorrows sun rise time because it will say "Next event in " and how many hours until tomorrow's sun rise.

And you can see the top icon is plainly showing a DAY mode. After sun set it shows NIGHT mode by putting the moon icon there rather than the sun.

@gerry: I think, even if you did not get immediate help regarding your questions, you should always be kind and share the solution you found, to help other board members maybe looking for the same. Anyway, nodes like Darksky and Yr weather data will give you the times for Sunrise/Sunset and much more

@Trying_to_learn: Honestly, this is not possible using the Bigtimer alone, you must have used the data provided and formatted it to be presented like that in the dashboard/html pages. What you typically will get from the Bigtimer is raw data like this:

I shall defer to your knowledge @krambriw
But looking for a specific node to do a specific task is not going to go well.

@Trying_to_learn: I like to add that it looks nice what u have done, if it is a widget in the dashboard, maybe consider sharing it?

NO PROMISES

This uses the weather icons and there is a trick which is done in the load css node (lower right of flow).

I exported and relayed the flow to another machine but now the weather icons for sun rise and sun set don't load.

So try at your own risk.

[{"id":"f30087e6.630f7","type":"bigtimer","z":"d13b9c9d.0e597","outtopic":"DAYTIME","outpayload1":"SUNRISE","outpayload2":"SUNSET","name":"Day Start/End","lat":"-33.51","lon":"151.12","starttime":"5003","endtime":"5004","startoff":0,"endoff":0,"offs":"0","outtext1":"Sun rise","outtext2":"Sun set","timeout":1440,"sun":true,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"jan":true,"feb":true,"mar":true,"apr":true,"may":true,"jun":true,"jul":true,"aug":true,"sep":true,"oct":true,"nov":true,"dec":true,"day1":0,"month1":0,"day2":0,"month2":0,"day3":0,"month3":0,"day4":0,"month4":0,"day5":0,"month5":0,"d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"suspend":false,"random":false,"repeat":true,"atstart":true,"odd":false,"even":false,"x":250,"y":190,"wires":[["f8dec9cd.326d1","94dce004.969c78"],["b29f59f4.784a48","214b4af9.fa4db6","bb776298.80472"],[]]},{"id":"fae06968.8619c","type":"inject","z":"d13b9c9d.0e597","name":"","topic":"","payload":"Sync","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":102,"y":196,"wires":[["f30087e6.630f7"]]},{"id":"3c8a50a.ef0bab","type":"inject","z":"d13b9c9d.0e597","name":"Toggle","topic":"","payload":"toggle","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":101,"y":229,"wires":[["f30087e6.630f7"]]},{"id":"4d4496e6.ae2798","type":"inject","z":"d13b9c9d.0e597","name":"Auto","topic":"","payload":"auto","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":102,"y":265,"wires":[["f30087e6.630f7"]]},{"id":"e724b291.091bd","type":"inject","z":"d13b9c9d.0e597","name":"Off","topic":"","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":300,"wires":[["f30087e6.630f7"]]},{"id":"e6d67273.de871","type":"inject","z":"d13b9c9d.0e597","name":"On","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":340,"wires":[["f30087e6.630f7"]]},{"id":"214b4af9.fa4db6","type":"function","z":"d13b9c9d.0e597","name":"Build message","func":"//  zeroPad(5, 2);\nvar sunrise_H = parseInt(msg.sunrise / 60);\nvar sunrise_M = msg.sunrise % 60;\nvar sunset_H = parseInt(msg.sunset / 60);\nvar sunset_M = msg.sunset % 60;\nmsg.payload = \"Sunrise \";\nif (sunrise_H < 10)\n{\n    msg.payload += 0;\n}\nmsg.payload += sunrise_H;\n//msg.payload = sunrise_H;\nmsg.payload += \":\";\nif (sunrise_M < 10)\n{\n   msg.payload += 0;\n}\nmsg.payload += sunrise_M;\n\nmsg.payload += \"#Sunset \";\nmsg.payload += sunset_H;\n//msg.payload = \"#\";\n//msg.payload += sunset_H;\nmsg.payload += \":\";\nif (sunset_M < 10)\n{\n   msg.payload += 0;\n}\nmsg.payload += sunset_M;\nmsg.payload += \" \\r\\n \";\nmsg.payload += msg.state;\nreturn msg;","outputs":1,"noerr":0,"x":480,"y":230,"wires":[["d2bf9699.f905f"]]},{"id":"d2bf9699.f905f","type":"split","z":"d13b9c9d.0e597","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":450,"y":270,"wires":[["3a9fe372.a066b4"]]},{"id":"3a9fe372.a066b4","type":"string","z":"d13b9c9d.0e597","name":"","methods":[{"name":"trimRight","params":[]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":450,"y":310,"wires":[["6d1e4019.cefb2"]]},{"id":"458aaab9.ea50cc","type":"split","z":"d13b9c9d.0e597","name":"","splt":"#","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":450,"y":410,"wires":[["1c3c6eb2.c0e829"]]},{"id":"1c3c6eb2.c0e829","type":"switch","z":"d13b9c9d.0e597","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"Sunrise","vt":"str"},{"t":"cont","v":"Sunset","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":450,"y":450,"wires":[["75e949b.61f99b8"],["f1c1b16b.8f4858"]]},{"id":"75e949b.61f99b8","type":"string","z":"d13b9c9d.0e597","name":"","methods":[{"name":"delLeftMost","params":[{"type":"str","value":" "}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":590,"y":430,"wires":[["9a7170eb.110f08"]]},{"id":"f1c1b16b.8f4858","type":"string","z":"d13b9c9d.0e597","name":"","methods":[{"name":"delLeftMost","params":[{"type":"str","value":" "}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":590,"y":470,"wires":[["562d0206.beb85c"]]},{"id":"b29f59f4.784a48","type":"debug","z":"d13b9c9d.0e597","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":450,"y":150,"wires":[]},{"id":"f8dec9cd.326d1","type":"ui_switch","z":"d13b9c9d.0e597","name":"","label":"Day/Night status","tooltip":"","group":"e5d0d39c.cf47","order":1,"width":"5","height":"1","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"SUNRISE","onvalueType":"str","onicon":"fa-sun-o fa-2x","oncolor":"yellow","offvalue":"SUNSET","offvalueType":"str","officon":"fa-moon-o fa-2x","offcolor":"black","x":480,"y":190,"wires":[[]]},{"id":"9a7170eb.110f08","type":"ui_text","z":"d13b9c9d.0e597","group":"e5d0d39c.cf47","order":3,"width":"2","height":"1","name":"Sunrise","label":"","format":"{{msg.payload}}","layout":"col-center","x":730,"y":430,"wires":[]},{"id":"562d0206.beb85c","type":"ui_text","z":"d13b9c9d.0e597","group":"e5d0d39c.cf47","order":5,"width":"2","height":"1","name":"Sunset","label":"","format":"{{msg.payload}}","layout":"col-center","x":730,"y":470,"wires":[]},{"id":"3652f8b8.4bef","type":"ui_template","z":"d13b9c9d.0e597","group":"e5d0d39c.cf47","name":"Load CSS","order":8,"width":"0","height":"0","format":"<link rel=\"stylesheet\" href=\"/weather-icons/mycss/weather-icons.min.css\">\n<style>\n .nr-dashboard-theme-dark ui-card-panel {\n \tbackground-color: #222;\n \toutline: 1px solid #cccccc;\n \t }\n</style>\n","storeOutMessages":false,"fwdInMessages":false,"templateScope":"local","x":890,"y":450,"wires":[[]]},{"id":"94dce004.969c78","type":"debug","z":"d13b9c9d.0e597","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":470,"y":110,"wires":[]},{"id":"681cc77b.4c1d4","type":"ui_text","z":"d13b9c9d.0e597","group":"e5d0d39c.cf47","order":7,"width":"5","height":"1","name":"","label":"Timer Mode","format":"{{msg.payload}}","layout":"row-spread","x":720,"y":360,"wires":[]},{"id":"6d1e4019.cefb2","type":"switch","z":"d13b9c9d.0e597","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"Sunrise","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":450,"y":350,"wires":[["458aaab9.ea50cc"],["681cc77b.4c1d4"]]},{"id":"bb776298.80472","type":"function","z":"d13b9c9d.0e597","name":"","func":"//  var sunrise_H = parseInt(msg.sunrise / 60);\n\nvar ttg = msg.duration;\nvar hr = parseInt(ttg / 60);\nvar min = (ttg % 60);\nmsg.payload = hr;\nmsg.payload += \" h \";\nif (min < 10)\n{\n   msg.payload += 0;\n}\nmsg.payload += min;\nmsg.payload += \" m\";\n\nreturn msg;","outputs":1,"noerr":0,"x":670,"y":190,"wires":[["69e40a10.832f4c"]]},{"id":"69e40a10.832f4c","type":"ui_text","z":"d13b9c9d.0e597","group":"e5d0d39c.cf47","order":6,"width":"5","height":"1","name":"Weather (Next event in)","label":"Next event in","format":"{{msg.payload}}","layout":"row-center","x":860,"y":190,"wires":[]},{"id":"e5d0d39c.cf47","type":"ui_group","z":"","name":"Sun Times","tab":"2fdea098.571f88","order":2,"disp":true,"width":"5","collapse":false},{"id":"2fdea098.571f88","type":"ui_tab","z":"","name":"Weather","icon":"cloud_queue","order":4,"disabled":false,"hidden":false}]

Looks very nice indeed, all works except as for the icons as you wrote. Looks like you eventually downloaded them to your first machine somehow ("/weather-icons/mycss/weather-icons.min.css")

weather icons are now built in so should be useable without loading

Weather icons lite are built in, which is a smaller sample of the full weather icon set. Maybe Andrew is using icons that only come with the full set.

1 Like

So, the backstory on this is that I have some remote switches I use to simulate lamp activity at night. Used to have mechanical store bought timers but they don't seem to hold up so I made some nodemcu relays using MQTT and random number generators to cycle them. They seemed to work well and I had a timer that output night day times but not content to leave something working well alone I started to improve it and of course it's now a mess. I wanted (out of curiosity) to see the sunrise sunset times. but that opened up a whole can of worms. I never knew about sunrise, sunset, golden hour, blue hour, dawn, dusk and a whole lot of other stuff. It does turn out there are quite a few timers that output night/day if you dig into their outputs deep enough. So now I have sunrise and sunset times that don't match up to the night/day outputs. It seems to vary by 20 to 30 minutes. However, I'm not enough of a stickler that the time difference bothered me but now I'm trying to understand WHY there is a difference. It still works but why does night not start at sunset? Oh by the way the node I'm using is * node-red-contrib-sun-position

krambriw
Looking at the outputs I see outputs for sunrise and sunset but I don't understand what that means. Is it minutes until sunset or is it the time 9:58 sunset occurs? If that is so is sunrise then at 4:85? I looked at the scargill website and he doesn't explain it further that I have found.

It's the actual time in minutes. So in this case, in my geolocation, 485 means 8:05 and 958 means 15:58

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.