@Steve-Mcl
Wow, amazing, really impressive!!!
This will be very nice to enjoy & test right away
Thanks for kind words and offer of testing.
This is the flow I used - might be useful (as I havent updated the built in documentation)
[{"id":"4dc18f72.a1da2","type":"cronplus","z":"21106466.70e60c","name":"","outputField":"payload","timeZone":"America/New_York","commandResponseMsgOutput":"output2","outputs":2,"options":[{"expressionType":"sunrise","topic":"sunrise-uk","payload":"sunrise-uk","type":"str","expression":"","location":"54.99908784547323 -1.4176440238952634","offset":"-600"},{"expressionType":"sunrise","topic":"sunrise-jp","payload":"sunrise-jp","type":"str","expression":"","location":"35.69550407383317 139.74609375","offset":"-600"}],"x":720,"y":160,"wires":[["307b7ae4.ef6026"],["152f8d01.5adb33"]]},{"id":"307b7ae4.ef6026","type":"debug","z":"21106466.70e60c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":930,"y":120,"wires":[]},{"id":"23b2b212.2b673e","type":"inject","z":"21106466.70e60c","name":"describe sunrise in 2 locations","topic":"","payload":"[{\"command\":\"describe\",\"location\":\"54.9992500,-1.4170300\",\"expressionType\":\"sunrise\",\"timeZone\":\"Europe/London\",\"info\":\"Describe sunrise for Bents Park (54.9992500,-1.4170300)\"},{\"command\":\"describe\",\"location\":\"35.45743499930747 139.63778346776962\",\"expressionType\":\"sunrise\",\"timeZone\":\"Europe/London\",\"info\":\"Describe sunrise at yokohama intercontinental (35.45743499930747 139.63778346776962)\"}]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":500,"y":60,"wires":[["4dc18f72.a1da2"]]},{"id":"fe5fa490.233128","type":"inject","z":"21106466.70e60c","name":"status of all","topic":"","payload":"{\"command\":\"status-all\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":450,"y":120,"wires":[["4dc18f72.a1da2"]]},{"id":"ef582828.d98988","type":"inject","z":"21106466.70e60c","name":"add \"sunrise-ny\"","topic":"","payload":"{\"command\":\"add\",\"name\":\"sunrise-ny\",\"payload\":\"sunrise-ny\",\"type\":\"str\",\"limit\":null,\"expressionType\":\"sunrise\",\"location\":\"40.70807700656229 -73.9995288848877\",\"offset\":\"60\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":460,"y":320,"wires":[["4dc18f72.a1da2"]]},{"id":"77a3467.33dc9b8","type":"inject","z":"21106466.70e60c","name":"status of sunrise-uk","topic":"","payload":"{\"command\":\"status\",\"name\":\"sunrise-uk\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":470,"y":240,"wires":[["4dc18f72.a1da2"]]},{"id":"9c4b5010.ae129","type":"inject","z":"21106466.70e60c","name":"status of sunrise-jp","topic":"","payload":"{\"command\":\"status\",\"name\":\"sunrise-jp\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":470,"y":280,"wires":[["4dc18f72.a1da2"]]},{"id":"6cdccc25.580d94","type":"inject","z":"21106466.70e60c","name":"status of sunrise-ny","topic":"","payload":"{\"command\":\"status\",\"name\":\"sunrise-ny\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":470,"y":360,"wires":[["4dc18f72.a1da2"]]},{"id":"152f8d01.5adb33","type":"debug","z":"21106466.70e60c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":930,"y":160,"wires":[]}]
Just a first Q:
I have this configured in the node (see image below). When I ask for status I do get this:
It's correct for my location that next sunrise will be at 05:28 tomorrow and next sunset 20:05 this evening. But I cannot explain the two hours diff in the other values, I have inserted just +/- 60 minutes as offsets. Maybe I do not understand fully but I expected that calculated times should reflect the offsets somehow. And as consequence, I did expect the state to be "set" since time is past 19:05
Can you post your flow please.
Never mind - school boy error - now fixed in V0.6.6 ( in github only for now )
Also I found and squished another bug - areas where there may be no sunrise or sunset for a number of days (for example greenland/antarctica) weren't handled - so happy days.
Demo showing offset in action
Demo showing next sunrise is in Sept.
Flow
[{"id":"4dc18f72.a1da2","type":"cronplus","z":"21106466.70e60c","name":"","outputField":"payload","timeZone":"","commandResponseMsgOutput":"output2","outputs":2,"options":[{"expressionType":"sunrise","topic":"sunrise-uk","payload":"sunrise-uk","type":"str","expression":"","location":"54.9990878447323 -1.4176440238952634","offset":"-60"},{"expressionType":"sunrise","topic":"sunrise-jp","payload":"sunrise-jp","type":"str","expression":"","location":"35.69550407383317 139.7460937","offset":"60"},{"expressionType":"sunrise","topic":"borden","payload":"borden","type":"str","expression":"","location":"80.181440, -99.234332","offset":"0"},{"expressionType":"sunrise","topic":"antarctica","payload":"antarctica","type":"str","expression":"","location":"-82.43033400458337 20.91796875","offset":"0"}],"x":720,"y":160,"wires":[["307b7ae4.ef6026"],["152f8d01.5adb33"]]},{"id":"307b7ae4.ef6026","type":"debug","z":"21106466.70e60c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":930,"y":120,"wires":[]},{"id":"23b2b212.2b673e","type":"inject","z":"21106466.70e60c","name":"describe sunrise in 2 locations","topic":"","payload":"[{\"command\":\"describe\",\"location\":\"54.9992500,-1.4170300\",\"expressionType\":\"sunrise\",\"timeZone\":\"Europe/London\",\"offset\":-60,\"info\":\"Describe sunrise for Bents Park (54.9992500,-1.4170300)\"},{\"command\":\"describe\",\"location\":\"35.45743499930747 139.63778346776962\",\"expressionType\":\"sunrise\",\"timeZone\":\"Europe/London\",\"offset\":60,\"info\":\"Describe sunrise at yokohama intercontinental (35.45743499930747 139.63778346776962)\"}]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":500,"y":60,"wires":[["4dc18f72.a1da2"]]},{"id":"fe5fa490.233128","type":"inject","z":"21106466.70e60c","name":"status of all","topic":"","payload":"{\"command\":\"status-all\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":450,"y":120,"wires":[["4dc18f72.a1da2"]]},{"id":"ef582828.d98988","type":"inject","z":"21106466.70e60c","name":"add \"sunrise-ny\"","topic":"","payload":"{\"command\":\"add\",\"name\":\"sunrise-ny\",\"payload\":\"sunrise-ny\",\"type\":\"str\",\"limit\":null,\"expressionType\":\"sunrise\",\"location\":\"40.70807700656229 -73.9995288848877\",\"offset\":0}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":460,"y":360,"wires":[["4dc18f72.a1da2"]]},{"id":"77a3467.33dc9b8","type":"inject","z":"21106466.70e60c","name":"status of sunrise-uk","topic":"","payload":"{\"command\":\"status\",\"name\":\"sunrise-uk\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":470,"y":240,"wires":[["4dc18f72.a1da2"]]},{"id":"9c4b5010.ae129","type":"inject","z":"21106466.70e60c","name":"status of sunrise-jp","topic":"","payload":"{\"command\":\"status\",\"name\":\"sunrise-jp\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":470,"y":280,"wires":[["4dc18f72.a1da2"]]},{"id":"6cdccc25.580d94","type":"inject","z":"21106466.70e60c","name":"status of sunrise-ny","topic":"","payload":"{\"command\":\"status\",\"name\":\"sunrise-ny\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":470,"y":400,"wires":[["4dc18f72.a1da2"]]},{"id":"152f8d01.5adb33","type":"debug","z":"21106466.70e60c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":930,"y":160,"wires":[]},{"id":"84331372.30af","type":"inject","z":"21106466.70e60c","name":"status of antarctica","topic":"","payload":"{\"command\":\"status\",\"name\":\"antarctica\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":470,"y":320,"wires":[["4dc18f72.a1da2"]]}]
I'd appreciated any constructive feedback please.
Ok, no problems, this is not an easy thing to solve
The offset is now working correctly as you say
There is however something I would like to talk about. Maybe is me misunderstanding or expecting the "wrong" things
If you look at my simple flow below, it has just two entries; one sunrise with offset +60 and one sunset with offset -60. The calculated sunrise and sunset times are now adjusted with the corresponding offsets. So far so good but I don't understand why the "opposite" also is adjusted with the offset? What I mean is if I have a sunrise entry, I would expect only the sunrise time to be adjusted and reported, not the sunset time. And vice versa, if I have a sunset entry, only the sunset time should be adjusted and reported. This is to my personal expectation. As it is now, the sun state information cannot be trusted because one response may say sun is up and the other says down
Which leads me to think further; instead of having sunrise/sunset options, you could have just one single sun option with two offset settings, one for sunrise and one for sunset. Unless this breaks other features you have in mind??
Also, don't know what was planned, but if I disable the node and then enable it again (with deploys for both) I expected a message with sun status somehow but seems nothing is sent out
[{"id":"d498aa83.a261a8","type":"cronplus","z":"dfc839b9.efe028","name":"","outputField":"payload","timeZone":"","commandResponseMsgOutput":"output1","outputs":1,"options":[{"expressionType":"sunset","topic":"sunset","payload":"1","type":"str","expression":"","location":"59.42865078226971 18.005223870277405","offset":"-60"},{"expressionType":"sunrise","topic":"sunrise","payload":"0","type":"str","expression":"","location":"59.42865078226971 18.005223870277405","offset":"60"}],"x":440,"y":120,"wires":[["f05c37a1.0d0468","1651bda.5ca5842","5d42f13c.c6c87"]]},{"id":"a89f6137.7e671","type":"inject","z":"dfc839b9.efe028","name":"status-all","topic":"","payload":"{ \"command\": \"status-all\" }","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":120,"wires":[["d498aa83.a261a8"]]},{"id":"19046fe3.86554","type":"inject","z":"dfc839b9.efe028","name":"remove-all","topic":"","payload":"{\"command\":\"remove-all\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":80,"wires":[["d498aa83.a261a8"]]},{"id":"b046b6a7.728278","type":"comment","z":"dfc839b9.efe028","name":"CRON+ scheduler tests","info":"","x":180,"y":40,"wires":[]},{"id":"f05c37a1.0d0468","type":"debug","z":"dfc839b9.efe028","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.result.status.sun","targetType":"msg","x":740,"y":120,"wires":[]},{"id":"cb4b15f.60859e8","type":"inject","z":"dfc839b9.efe028","name":"status of sunrise-se","topic":"","payload":"{\"command\":\"status\",\"name\":\"sunrise\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":160,"wires":[["d498aa83.a261a8"]]},{"id":"782aa314.2d2cdc","type":"inject","z":"dfc839b9.efe028","name":"status of sunset-se","topic":"","payload":"{\"command\":\"status\",\"name\":\"sunset\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":200,"wires":[["d498aa83.a261a8"]]},{"id":"5d42f13c.c6c87","type":"debug","z":"dfc839b9.efe028","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":660,"y":80,"wires":[]}]
I think there is a fundamental problem if more than one set of sunset/sunrise entries exist. How can you determine which sunrise goes with which sunset? Perhaps that is not allowed.
I have just noticed a typo in the node config. Seperate isn't spelt like that.
They can only match each others if they have exactly the same lon/lat, but don't know if this is considered
That is not quite what I meant, though that is also a factor to be considered. Even with the same lat/lon, to know the status for a sunrise node it is necessary to know whether it has passed sunrise time (with offset) but not yet reached sunset time (with offset). If there are multiple sunset entries with different sunset offsets then it is necessary to know which sunset goes with which sunrise.
Maybe time to stop and think a bit, maybe would be better to follow the hint from @dceejay earlier, not to overreach things. Why not encourage @Steve-Mcl to consider skipping the sun stuff completely. Instead we could try to convince @dceejay to add offset settings to the suncalc node. I mean, the suncalc node has it except for offset settings. Just my thoughts, what do you think?
Oh, yes - I need these please I'm forever getting those wrong.
Coffee Time and Biscuit Time would also be very useful
Wine o'clock too please - every 60 minutes during lock-down otherwise every 5PM, except on Friday where it's 3-4PM and cancelled on days with a hangover! Thanks.
aha right - but which tea time ??? Dinner time or tea time? It depends on where you live | YouGov
Plus, of course, time is an illusion, tea time doubly so.
I have had a look at node-red-node-suncalc to see it if meets my needs, which it does, almost.
Firstly it would be nice (but not essential) if it picked up the lat/lon map selection that @Steve-Mcl has provided.
Secondly and more of a problem is the fact that it does not provide for offsets from sunrise and sunset, which I need. Positive offsets are easy enough to achieve with a Trigger node (or a Switch and two Triggers if different offsets are needed), but a negative offset is more problematic. If the Trigger node allowed for the entry of a -ve interval that would do the job. I tried putting -5 minutes into a Trigger node and it does not complain, but silently converts it to +5. Should I submit a bug report for this?
[Edit] Actually the Trigger node doesn't work even with +ve offsets for the node red restart case as it would delay the repeating output by the offset on startup, so some additional logic would be required to handle that, and it is not a trivial problem, in fact I am not sure it is a solvable problem at all.
You can't ask a node to do something before it is triggered so a -ve offset for a trigger is impossible.We can certainly look to add offsets to the suncalc node.
You can't ask a node to do something before it is triggered
Yes, I did realise that. I was following on from the somewhat light hearted direction that this thread seemed to have taken.
That would be perfect.
aha right - but which tea time
Ah, Northern English "Tea" time is what most people would call "family dinner" - around 6-7pm
As opposed to "Tea and Biscuits" time which is like Garry's Wine time (I'm on strict self-rationing of wine and spirits while on lock-down )
Surprised you find that so difficult to work out!
You can't ask a node to do something before it is triggered so a -ve offset for a trigger is impossible.We can certainly look to add offsets to the suncalc node.
Well, I'm sure that Nick is up to the challenge! Surely a minor time-warp is not beyond his capability? I'm sure I remember seeing a package for that on npm somewhere.