Open westerduin3451 opened 2 years ago
Hi Johan,
What time zone are you in? The data suggests that you have a ,"timezone":60 60 min offset added to your timezone - change that to 0 and you should be back on track with the values. Mat Zolnierczyk
Maker, Robotics Engineer
Owner | NotEnoughTech @.*** notenoughtech.com Teesside, North Yorkshire, UK [image: facebook] https://www.facebook.com/NotEnoughTECH/ [image: twitter] https://twitter.com/NotEnoughTECH [image: linkedin] https://www.linkedin.com/in/mat-zolnierczyk/ [image: instagram] https://www.instagram.com/notenoughtech/
On Thu, Jan 6, 2022 at 9:42 AM westerduin3451 @.***> wrote:
Hi Mat,
thanks for your work, it helps me a lot with my home automation.
At the moment I am struggling with your project "Tracking daylight in NodeRED".
My setup is Home Assistant (Hassio) with the node-red add-on. When I entre my coordinates and enable timezone the daylight tracker calculation of day and night is one hour off?
SunSet/SunRise info: {"sunrise":"2022-01-06T08:45:03.000Z" ,"noon":"2022-01-06T12:45:45.000Z" ,"sunset":"2022-01-06T16:46:27.000Z", "day_lenght":{"in_sec":28884,"in_hhmmss":"08h 01min"} ,"civil_twiligh_start":"2022-01-06T08:07:00.000Z" ,"civil_twiligh_stop":"2022-01-06T17:24:30.000Z" ,"nautical_twilight_start":"2022-01-06T07:23:44.000Z" ,"nautical_twilight_stop":"2022-01-06T18:07:46.000Z" ,"astronomical_twilight_start":"2022-01-06T06:42:44.000Z" ,"astronomical_twilight_stop":"2022-01-06T18:48:47.000Z" ,"timezone":60}
This information seems right/ok. But the daylight tracker is one hour off / late?.
Did I do something wrong? Do you have any suggestions, on how I can fix this?
Thanks in advance. Regards Johan
— Reply to this email directly, view it on GitHub https://github.com/notenoughtech/NodeRED-Projects/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKDRL224FWCYZLUOZS2IQ23UUVPZLANCNFSM5LL5PSLQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you are subscribed to this thread.Message ID: @.***>
Hi Mat,
thanks for the quick response. My timezone = Europe/Amsterdam How and where do I change 60 into 0? Will this still work with daylight saving?
Hi Johan,
In the setting node (On Start) you should have the timezone = true
value which uses your local computer zone to calculate the offset including the current daylight setting. Can you give me your coords you are working with, and what is the result reporting for today's sunset vs what you would expect to see?
Hi Mat,
The date and time of the Pi I am running shows correct date and time and the current settings in On Start are as follows
var latitude = "52.10743999864968"; var longitude = "5.011243974118552"; var timezone = true; //set true to use local timezone offset, set false to get values in UTC without daylight saving
flow.set("timezone", timezone); global.set("longitude", longitude); global.set("latitude", latitude);
Both values in the tracker report the time in seconds
node.warn(timeNow); node.warn(new Date(sunset).getTime())
You can use these to get the live output but looking at the payloads in debug - all seems to be fine - the most you should get is a delay of 1 min caused by the interval update
Hmm node.warn(new Date(sunset).getTime()) reports the same time over and over?
06/01/2022, 11:59:21node: Is it night time yet? function : (warn) 1641466761578 06/01/2022, 11:59:21node: Is it night time yet? function : (warn) 1641487587000 06/01/2022, 11:59:21node: 819883bf552b1c33 msg.payload : string[41] "According to my calculations it's daytime" 06/01/2022, 11:59:22node: Is it night time yet? function : (warn) 1641466762485 06/01/2022, 11:59:22node: Is it night time yet? function : (warn) 1641487587000 06/01/2022, 11:59:22node: 819883bf552b1c33 msg.payload : string[41] "According to my calculations it's daytime"
code of "is it night time yet?"
var time = global.get("Time");
var sunrise = time.sunrise; var sunset = time.sunset;
var now = new Date(); var timeNow = now.getTime();
//from sunrise to sunset if(timeNow >= new Date(sunrise).getTime() && timeNow <= new Date(sunset).getTime()){ msg.payload = "According to my calculations it's daytime"; global.set("time_of_Day", "day"); }
//from sunset to sunrise if(timeNow > new Date(sunset).getTime() || timeNow < new Date(sunrise).getTime()){ msg.payload = "According to my calculations it's nighttime"; global.set("time_of_Day", "night"); }
node.warn(timeNow); node.warn(new Date(sunset).getTime())
return msg;
The debug values will show you current (in this case) time and sunrise time - obviously sunrise time will be the same for 24h period
Sorry Mat, I have no idea what I was thinking silly of me ;-)
Don't worry about it. I have my silly moments about 20 times a day :)
On Thu, 6 Jan 2022, 13:09 westerduin3451, @.***> wrote:
Sorry Mat, I have no idea what I was thinking silly of me ;-)
— Reply to this email directly, view it on GitHub https://github.com/notenoughtech/NodeRED-Projects/issues/1#issuecomment-1006578263, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKDRL2YKLS6MI7WC3DXCJ2DUUWH73ANCNFSM5LL5PSLQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you commented.Message ID: @.***>
OK it's 17:02 and it's still daytime, should it not be night time?
06/01/2022, 17:02:20node: 819883bf552b1c33 msg.payload : string[41] "According to my calculations it's daytime" 06/01/2022, 17:02:46node: 0de22e8d93416a14 msg.payload : Object object sunrise: "2022-01-06T08:45:03.000Z" noon: "2022-01-06T12:45:45.000Z" sunset: "2022-01-06T16:46:27.000Z" day_lenght: object civil_twiligh_start: "2022-01-06T08:07:00.000Z" civil_twiligh_stop: "2022-01-06T17:24:30.000Z" nautical_twilight_start: "2022-01-06T07:23:44.000Z" nautical_twilight_stop: "2022-01-06T18:07:46.000Z" astronomical_twilight_start: "2022-01-06T06:42:44.000Z" astronomical_twilight_stop: "2022-01-06T18:48:47.000Z" timezone: 60
What the wanr messages say on your end ?
On Thu, 6 Jan 2022, 16:07 westerduin3451, @.***> wrote:
OK it's 17:02 and it's still daytime, should it not be night time?
06/01/2022, 17:02:20node: 819883bf552b1c33 msg.payload : string[41] "According to my calculations it's daytime" 06/01/2022, 17:02:46node: 0de22e8d93416a14 msg.payload : Object object sunrise: "2022-01-06T08:45:03.000Z" noon: "2022-01-06T12:45:45.000Z" sunset: "2022-01-06T16:46:27.000Z" day_lenght: object civil_twiligh_start: "2022-01-06T08:07:00.000Z" civil_twiligh_stop: "2022-01-06T17:24:30.000Z" nautical_twilight_start: "2022-01-06T07:23:44.000Z" nautical_twilight_stop: "2022-01-06T18:07:46.000Z" astronomical_twilight_start: "2022-01-06T06:42:44.000Z" astronomical_twilight_stop: "2022-01-06T18:48:47.000Z" timezone: 60
— Reply to this email directly, view it on GitHub https://github.com/notenoughtech/NodeRED-Projects/issues/1#issuecomment-1006709678, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKDRL24RHD5QAMC34SJIQBTUUW42RANCNFSM5LL5PSLQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you commented.Message ID: @.***>
here are the warn msg
node.warn(timeNow); node.warn(new Date(sunrise).getTime()) node.warn(new Date(sunset).getTime())
06/01/2022, 17:02:09node: 819883bf552b1c33 msg.payload : string[41] "According to my calculations it's daytime" 06/01/2022, 17:02:20node: Is it night time yet? function : (warn) 1641484940068 06/01/2022, 17:02:20node: Is it night time yet? function : (warn) 1641458703000 06/01/2022, 17:02:20node: Is it night time yet? function : (warn) 1641487587000
according to your flow the time in node.warn(timeNow); = 1641484940068 which is Thu Jan 06 2022 16:02:20 - before the sunset - please check your RPI or whatever is hosting your NodeRED timezone and current time Mat Zolnierczyk
Maker, Robotics Engineer
Owner | NotEnoughTech @.*** notenoughtech.com Teesside, North Yorkshire, UK [image: facebook] https://www.facebook.com/NotEnoughTECH/ [image: twitter] https://twitter.com/NotEnoughTECH [image: linkedin] https://www.linkedin.com/in/mat-zolnierczyk/ [image: instagram] https://www.instagram.com/notenoughtech/
On Thu, Jan 6, 2022 at 4:15 PM westerduin3451 @.***> wrote:
here are the warn msg
node.warn(timeNow); node.warn(new Date(sunrise).getTime()) node.warn(new Date(sunset).getTime())
06/01/2022, 17:02:09node: 819883bf552b1c33 msg.payload : string[41] "According to my calculations it's daytime" 06/01/2022, 17:02:20node: Is it night time yet? function : (warn) 1641484940068 06/01/2022, 17:02:20node: Is it night time yet? function : (warn) 1641458703000 06/01/2022, 17:02:20node: Is it night time yet? function : (warn) 1641487587000
— Reply to this email directly, view it on GitHub https://github.com/notenoughtech/NodeRED-Projects/issues/1#issuecomment-1006716016, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKDRL265ZRHA5K2LFAQGI63UUW5Z3ANCNFSM5LL5PSLQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you commented.Message ID: @.***>
Checked the timezone of the pi and it was correct. Found out that you have to specify a timezone in the config files of node red as well. Also set timezone On Start to false and it works.
Thanks for your help Mat.
I'll add this info to the write up thanks for letting me know
On Sun, 9 Jan 2022, 09:57 westerduin3451, @.***> wrote:
Checked the timezone of the pi and it was correct. Found out that you have to specify a timezone in the config files of node red as well. Also set timezone On Start to false and it works.
Thanks for your help Mat.
— Reply to this email directly, view it on GitHub https://github.com/notenoughtech/NodeRED-Projects/issues/1#issuecomment-1008266015, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKDRL2YNCSNBBFMYWAY4HO3UVFL2NANCNFSM5LL5PSLQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you commented.Message ID: @.***>
Hi Mat,
thanks for your work, it helps me a lot with my home automation.
At the moment I am struggling with your project "Tracking daylight in NodeRED".
My setup is Home Assistant (Hassio) with the node-red add-on. When I entre my coordinates and enable timezone the daylight tracker calculation of day and night is one hour off?
SunSet/SunRise info: {"sunrise":"2022-01-06T08:45:03.000Z" ,"noon":"2022-01-06T12:45:45.000Z" ,"sunset":"2022-01-06T16:46:27.000Z", "day_lenght":{"in_sec":28884,"in_hhmmss":"08h 01min"} ,"civil_twiligh_start":"2022-01-06T08:07:00.000Z" ,"civil_twiligh_stop":"2022-01-06T17:24:30.000Z" ,"nautical_twilight_start":"2022-01-06T07:23:44.000Z" ,"nautical_twilight_stop":"2022-01-06T18:07:46.000Z" ,"astronomical_twilight_start":"2022-01-06T06:42:44.000Z" ,"astronomical_twilight_stop":"2022-01-06T18:48:47.000Z" ,"timezone":60}
This information seems right/ok. But the daylight tracker is one hour off / late?.
Did I do something wrong? Do you have any suggestions, on how I can fix this?
Thanks in advance. Regards Johan