csuermann/node-red-contrib-suncron

RangeError: Invalid time value

chrisg2003 opened this issue · 18 comments

Hi

This node has been working great.

This morning the node didn't report Sunrise and the log shows an error RangeError: Invalid time value.

I haven't changed anything so can you help with a possible explanation.

I have rebooted Pi but the problem persists, Pi is showing correct date and time.

Many thanks

Hi @chrisg2003,
Thanks for reaching out! Which version do you currently use? Could you please share the node's JSON with me?
Thank you!
C.

@chrisg2003, Thanks for your reply, but I cannot find your attachment?! C.

@chrisg2003, there's still no attachment ;-) but I did some research and it seems that depending on your location certain sun events simply may not exist at this time of the year. Sounds really strange, I know. Check these comments on an issue of the suncalc dependency I'm using. Could that explain the strange behavior you're observing? If so, how do you think suncron should handle those cases?

Sorry. Not used to github protocols, I was just answering emails with an attachment.
[
{
"id": "5ae1933e.b4c87c",
"type": "suncron",
"z": "51ccb1d4.eae9e",
"name": "",
"replay": false,
"lat": "50.9757",
"lon": "-1.3862",
"sunrisePayload": "true",
"sunrisePayloadType": "bool",
"sunriseTopic": "Dawn",
"sunriseOffsetType": 1,
"sunriseOffsetHours": 0,
"sunriseOffsetMinutes": 0,
"sunriseOffset": 0,
"sunriseEndPayload": "",
"sunriseEndPayloadType": "str",
"sunriseEndTopic": "",
"sunriseEndOffsetType": 1,
"sunriseEndOffsetHours": 0,
"sunriseEndOffsetMinutes": 0,
"sunriseEndOffset": 0,
"goldenHourEndPayload": "true",
"goldenHourEndPayloadType": "bool",
"goldenHourEndTopic": "Sunrise",
"goldenHourEndOffsetType": 1,
"goldenHourEndOffsetHours": 0,
"goldenHourEndOffsetMinutes": 0,
"goldenHourEndOffset": 0,
"solarNoonPayload": "",
"solarNoonPayloadType": "str",
"solarNoonTopic": "",
"solarNoonOffsetType": "-1",
"solarNoonOffsetHours": 0,
"solarNoonOffsetMinutes": "0",
"solarNoonOffset": "0",
"goldenHourPayload": "",
"goldenHourPayloadType": "str",
"goldenHourTopic": "",
"goldenHourOffsetType": 1,
"goldenHourOffsetHours": 0,
"goldenHourOffsetMinutes": 0,
"goldenHourOffset": 0,
"sunsetStartPayload": "",
"sunsetStartPayloadType": "str",
"sunsetStartTopic": "",
"sunsetStartOffsetType": 1,
"sunsetStartOffsetHours": 0,
"sunsetStartOffsetMinutes": 0,
"sunsetStartOffset": 0,
"sunsetPayload": "true",
"sunsetPayloadType": "bool",
"sunsetTopic": "LightingUptime",
"sunsetOffsetType": "-1",
"sunsetOffsetHours": "0",
"sunsetOffsetMinutes": "0",
"sunsetOffset": "0",
"duskPayload": "true",
"duskPayloadType": "bool",
"duskTopic": "Dusk",
"duskOffsetType": 1,
"duskOffsetHours": 0,
"duskOffsetMinutes": 0,
"duskOffset": 0,
"nauticalDuskPayload": "",
"nauticalDuskPayloadType": "str",
"nauticalDuskTopic": "",
"nauticalDuskOffsetType": 1,
"nauticalDuskOffsetHours": 0,
"nauticalDuskOffsetMinutes": 0,
"nauticalDuskOffset": 0,
"nightPayload": "true",
"nightPayloadType": "bool",
"nightTopic": "DeadOfNight",
"nightOffsetType": 1,
"nightOffsetHours": 0,
"nightOffsetMinutes": 0,
"nightOffset": 0,
"nadirPayload": "",
"nadirPayloadType": "str",
"nadirTopic": "",
"nadirOffsetType": "1",
"nadirOffsetHours": "0",
"nadirOffsetMinutes": 0,
"nadirOffset": "0",
"nightEndPayload": "",
"nightEndPayloadType": "str",
"nightEndTopic": "",
"nightEndOffsetType": 1,
"nightEndOffsetHours": 0,
"nightEndOffsetMinutes": 0,
"nightEndOffset": 0,
"nauticalDawnPayload": "",
"nauticalDawnPayloadType": "str",
"nauticalDawnTopic": "",
"nauticalDawnOffsetType": 1,
"nauticalDawnOffsetHours": 0,
"nauticalDawnOffsetMinutes": 0,
"nauticalDawnOffset": 0,
"dawnPayload": "",
"dawnPayloadType": "str",
"dawnTopic": "",
"dawnOffsetType": 1,
"dawnOffsetHours": 0,
"dawnOffsetMinutes": 0,
"dawnOffset": 0,
"x": 280,
"y": 360,
"wires": [
[
"6aa18c7e.04d4a4",
"292555bd.60a12a"
]
]
}
]

Hi

I have looked at the comments and don't quite understand. I'm in the UK and Sunrise was at 05:01 today according to Google at my location.

Chris

Sorry didn't mean to close it, not having a great day today.

🎉 This issue has been resolved in version 1.4.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@chrisg2003, In your case the error seemed to be triggered by the 'night' event, which simply does not exist at your location at this time of the year. The error might have put the node in an error state that stopped it from functioning altogether. I fixed this by skipping 'invalid' sun events. They will simply be ignored and not be contained in the schedule for the day.

Thank you for resolving this so promptly.

My bad, Node-Red changed the way they pick up updates. I now triggered a re-index manually and expect the update to become visible shortly.

Looks like your code is expecting the schedule object to contain certain sun events, which is no longer the case. Try guarding those sections like so:

if (msg.schedule.night) {
    dstr = msg.schedule.night.sunEventTime;
}