Cron-plus can't start a paused schedule again

Yeah, ok. I'll cop that. My bad.

I should have been clearer.

I'll download it and see what I see/get.

Um.....

[{"id":"ad1329a369dc4021","type":"link in","z":"489173351d96a294","name":"link in 1","links":["c149ede859fd699d","c5569589359e6a29"],"x":265,"y":300,"wires":[["12218241a361f06f"]]},{"id":"12218241a361f06f","type":"cronplus","z":"489173351d96a294","name":"Solar Events","outputField":"payload","timeZone":"America/New_York","storeName":"","commandResponseMsgOutput":"fanOut","defaultLocation":"37.1881071713213, -80.41689781544531","defaultLocationType":"fixed","outputs":18,"options":[{"name":"Night End - Astronomical Dawn","topic":"Night End - Astronomical Dawn","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"0","solarType":"selected","solarEvents":"nightEnd"},{"name":"Nautical Dawn","topic":"Nautical Dawn","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"0","solarType":"selected","solarEvents":"nauticalDawn"},{"name":"Civil Dawn - Golden Hour","topic":"Civil Dawn - Golden Hour","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"0","solarType":"selected","solarEvents":"civilDawn"},{"name":"Sunrise","topic":"Sunrise","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"0","solarType":"selected","solarEvents":"sunrise"},{"name":"Sunrise End","topic":"Sunrise End","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"0","solarType":"selected","solarEvents":"sunriseEnd"},{"name":"Morning Golden Hour Ends","topic":"Morning Golden Hour Ends","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"0","solarType":"selected","solarEvents":"morningGoldenHourEnd"},{"name":"Solar Noon","topic":"Solar Noon","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"-240","solarType":"selected","solarEvents":"solarNoon"},{"name":"Check EGH","topic":"Check EGH","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"","offset":"-30","solarType":"selected","solarEvents":"eveningGoldenHourStart"},{"name":"Evening Golden Hour Starts","topic":"Evening Golden Hour Starts","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"0","solarType":"selected","solarEvents":"eveningGoldenHourStart"},{"name":"Sunset Start","topic":"Sunset Start","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"0","solarType":"selected","solarEvents":"sunsetStart"},{"name":"Sunset","topic":"Sunset","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"0","solarType":"selected","solarEvents":"sunset"},{"name":"Early GHE","topic":"Early GHE","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"","offset":"-15","solarType":"selected","solarEvents":"civilDusk"},{"name":"Civil Dusk - Golden Hour Ends","topic":"Civil Dusk - Golden Hour Ends","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"-5","solarType":"selected","solarEvents":"civilDusk"},{"name":"Nautical Dusk","topic":"Nautical Dusk","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"0","solarType":"selected","solarEvents":"nauticalDusk"},{"name":"Astronomical Dusk - Night Starts","topic":"Astronomical Dusk - Night Starts","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"0","solarType":"selected","solarEvents":"nightStart"},{"name":"Solar Midnight","topic":"Solar Midnight","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"0","solarType":"selected","solarEvents":"nadir"}],"x":370,"y":300,"wires":[[],[],[],[],[],[],[],["192206f961a65a8f"],[],[],[],[],[],["e61faa0f7b74f9a1"],[],[],[],[]]},{"id":"192206f961a65a8f","type":"change","z":"489173351d96a294","name":"Pause Late Schedules","rules":[{"t":"set","p":"payload","pt":"msg","to":"[{\"command\":\"pause\",\"name\":\"Evening Golden Hour Starts\"},{\"command\":\"pause\",\"name\":\"Civil Dusk - Golden Hour Ends\"}]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":280,"wires":[["c149ede859fd699d"]]},{"id":"c149ede859fd699d","type":"link out","z":"489173351d96a294","name":"link out 1","mode":"link","links":["ad1329a369dc4021"],"x":695,"y":280,"wires":[]},{"id":"e61faa0f7b74f9a1","type":"change","z":"489173351d96a294","name":"Resume Schedules","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"command\":\"start-all\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":360,"wires":[["c5569589359e6a29"]]},{"id":"c5569589359e6a29","type":"link out","z":"489173351d96a294","name":"link out 2","mode":"link","links":["ad1329a369dc4021"],"x":675,"y":360,"wires":[]}]

May be taking it just a bit toooooo far.

There's no start, stop pause inject nodes.

So I kinda can't test what happens when I..... start, stop, pause, etc the schedules.

You can easily add in the injects or the debugs, depending on how you like to perform them, but the sake of making it easier for anyone looking into this, and the fact that I added in more schedules to pause (four total), here's a complete set:

[{"id":"ad1329a369dc4021","type":"link in","z":"67f4fbcd08443ef1","name":"link in 1","links":["c149ede859fd699d","c5569589359e6a29"],"x":465,"y":280,"wires":[["05cdac507d7d11b8"]]},{"id":"c149ede859fd699d","type":"link out","z":"67f4fbcd08443ef1","name":"link out 1","mode":"link","links":["ad1329a369dc4021"],"x":975,"y":240,"wires":[]},{"id":"e61faa0f7b74f9a1","type":"change","z":"67f4fbcd08443ef1","name":"Resume Schedules","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"command\":\"start-all\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":830,"y":360,"wires":[["c5569589359e6a29"]]},{"id":"c5569589359e6a29","type":"link out","z":"67f4fbcd08443ef1","name":"link out 2","mode":"link","links":["ad1329a369dc4021"],"x":955,"y":360,"wires":[]},{"id":"05cdac507d7d11b8","type":"cronplus","z":"67f4fbcd08443ef1","name":"Solar Events","outputField":"payload","timeZone":"America/New_York","storeName":"","commandResponseMsgOutput":"fanOut","defaultLocation":"37.1881071713213, -80.41689781544531","defaultLocationType":"default","outputs":20,"options":[{"name":"Night End - Astronomical Dawn","topic":"Night End - Astronomical Dawn","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"0","solarType":"selected","solarEvents":"nightEnd"},{"name":"Nautical Dawn","topic":"Nautical Dawn","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"0","solarType":"selected","solarEvents":"nauticalDawn"},{"name":"Civil Dawn - Golden Hour","topic":"Civil Dawn - Golden Hour","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"0","solarType":"selected","solarEvents":"civilDawn"},{"name":"Sunrise","topic":"Sunrise","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"0","solarType":"selected","solarEvents":"sunrise"},{"name":"Sunrise End","topic":"Sunrise End","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"0","solarType":"selected","solarEvents":"sunriseEnd"},{"name":"Morning Golden Hour Ends","topic":"Morning Golden Hour Ends","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"0","solarType":"selected","solarEvents":"morningGoldenHourEnd"},{"name":"Solar Noon","topic":"Solar Noon","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"-60","solarType":"selected","solarEvents":"solarNoon"},{"name":"Check EGH","topic":"Check EGH","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"-30","solarType":"selected","solarEvents":"eveningGoldenHourStart"},{"name":"Evening Golden Hour Starts","topic":"Evening Golden Hour Starts","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"0","solarType":"selected","solarEvents":"eveningGoldenHourStart"},{"name":"Sunset Start","topic":"Sunset Start","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"0","solarType":"selected","solarEvents":"sunsetStart"},{"name":"Sunset","topic":"Sunset","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"0","solarType":"selected","solarEvents":"sunset"},{"name":"Sunset 2","topic":"Sunset 2","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"1","solarType":"selected","solarEvents":"sunset"},{"name":"Sunset 3","topic":"Sunset 3","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"2","solarType":"selected","solarEvents":"sunset"},{"name":"Early GHE","topic":"Early GHE","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"-10","solarType":"selected","solarEvents":"civilDusk"},{"name":"Civil Dusk - Golden Hour Ends","topic":"Civil Dusk - Golden Hour Ends","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"-5","solarType":"selected","solarEvents":"civilDusk"},{"name":"Nautical Dusk","topic":"Nautical Dusk","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"0","solarType":"selected","solarEvents":"nauticalDusk"},{"name":"Astronomical Dusk - Night Starts","topic":"Astronomical Dusk - Night Starts","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"0","solarType":"selected","solarEvents":"nightStart"},{"name":"Solar Midnight","topic":"Solar Midnight","payloadType":"default","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"37.1881071713213, -80.41689781544531","offset":"0","solarType":"selected","solarEvents":"nadir"}],"x":630,"y":280,"wires":[[],[],[],[],[],[],[],["f6b28a461d9e231f"],[],[],[],[],[],[],[],[],["e61faa0f7b74f9a1"],[],[],["81c544867f69e963"]]},{"id":"f6b28a461d9e231f","type":"change","z":"67f4fbcd08443ef1","name":"Pause Late Schedules","rules":[{"t":"set","p":"payload","pt":"msg","to":"[{\"command\":\"pause\",\"name\":\"Evening Golden Hour Starts\"},{\"command\":\"pause\",\"name\":\"Civil Dusk - Golden Hour Ends\"},{\"command\":\"pause\",\"name\":\"Sunset 2\"},{\"command\":\"pause\",\"name\":\"Sunset 3\"}]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":240,"wires":[["c149ede859fd699d"]]},{"id":"ab162ea349c2cda2","type":"inject","z":"67f4fbcd08443ef1","name":"List-All","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"command\":\"list-all\"}","payloadType":"json","x":430,"y":340,"wires":[["05cdac507d7d11b8"]]},{"id":"e73bfbabad3a0996","type":"inject","z":"67f4fbcd08443ef1","name":"Start-All","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"command\":\"start-all\"}","payloadType":"json","x":440,"y":380,"wires":[["05cdac507d7d11b8"]]},{"id":"0631fc9bd85c2cd1","type":"inject","z":"67f4fbcd08443ef1","name":"List-Inactive","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"command\":\"list-inactive\"}","payloadType":"json","x":450,"y":420,"wires":[["05cdac507d7d11b8"]]},{"id":"81c544867f69e963","type":"debug","z":"67f4fbcd08443ef1","name":"debug 3","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":810,"y":420,"wires":[]}]

Now, I double checked on today's run that it was correctly pausing all four schedules, before the resume was triggered, and it showed four paused correctly. After the auto resume, only two were resumed correctly although this time, slightly different ones:

  • Evening Golden Hour Starts
  • Civil Dusk - Golden Hour Ends (still paused)
  • Sunset 2
  • Sunset 3 (still paused)

And this time, when I triggered the manual 'start-all', instead of resuming one of the two remaining as it did before, it resumed both of the remaining two, but I also did this almost immediately after they were all paused in the first place on today's run, whereas I investigate yesterday's run this morning.

So it has so far only consistently automatically resumed two of the four, but manually it is inconsistently resuming either one or two.

While preparing the example nodes, I ran into a something I had forgotten about again. In your cron-plus node, if you have the 'Location' set to 'Location Per Schedule', you have an individual long/lat for all of your solar events, all good so far.

If you later change the 'Location' to 'Fixed Location', so you only have one main long/lat setup for all solar events, note that the node still stores the individual long/lat location for each of the solar events you had setup before.

I'm not sure if this would now cause any confusion in the logic of the code, with there being one main long/lat configured along side with an individual long/lat for each solar event.

Additionally, say now I configure two more solar events (which is what I did) while 'Location' is still set to 'Fixed Location', and now after creating those I change 'Location' to 'Location Per Schedule', you'll note that the two newly just created solar events are not populated with an individual long/lat, were as all the OG solar events still are:

I don't know if this makes any difference at all, I just thought it prudent to mention again, since I have fallen foul to the old "previously configured settings that are now supposed to be disabled, are still in play, merely because they have been stored somewhere still".

I'm going to populate mine now, but set the 'Location' back to 'Fixed Location' just in case.

Not trying to show you up, but here's a bit of code to help anyone else.

Replace your debug node with these three.

[{"id":"5e629d2a99159752","type":"function","z":"b25fd092.bcc758","name":"Magic stuff","func":"// Get the array of result entries from the payload\nconst results = msg.payload.result\n\n// Initialize a string to accumulate the human-readable output\nlet output = ''\n\n// Loop through each solar event configuration in the result list\nfor (let i = 0; i < results.length; i++) {\n    const config = results[i].config\n    const status = results[i].status\n\n    // Extract values of interest\n    const name = config.name\n    const isRunning = config.isRunning\n    const nextDescription = status.nextDescription\n    const nextDate = status.nextDateTZ\n\n    // Append formatted data to output string\n    output += `Name: ${name}\\n`\n    output += `  Running: ${isRunning ? 'Yes' : 'No'}\\n`\n    output += `  Description: ${nextDescription}\\n`\n    output += `  Next Time: ${nextDate}\\n\\n`\n}\n\n// Set the final human-readable string as the new payload\nmsg.payload = output.trim()\n\n// Return the modified message object\nreturn msg\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":6440,"y":620,"wires":[["ad91e150f574718d"]]},{"id":"ad91e150f574718d","type":"function","z":"b25fd092.bcc758","name":"split message to acceptable size.","func":"// Split the long string into separate message blocks using double newline\nconst blocks = msg.payload.split('\\n\\n')\n\n// Map each block into a new msg object\nconst messages = blocks.map(block => {\n    return { payload: block }\n})\n\n// Return array of individual messages\nreturn [messages]\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":6560,"y":660,"wires":[["104dac6872f35137"]]},{"id":"104dac6872f35137","type":"debug","z":"b25fd092.bcc758","name":"Human readable","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":6650,"y":620,"wires":[]}]

It makes the messages human readable and breaks the output to small blocks as the debug window is limited to the size of messages displayable.

I hope it helps in some way.

Oh, for people who don't talk GMT, this is a new version of the make human readable node to help with local times.

// Get the array of result entries from the payload
const results = msg.payload.result

// Initialize a string to accumulate the human-readable output
let output = ''

// Loop through each solar event configuration in the result list
for (let i = 0; i < results.length; i++) {
    const config = results[i].config
    const status = results[i].status

    // Extract values of interest
    const name = config.name
    const isRunning = config.isRunning
    const nextDescription = status.nextDescription
    const nextDateRaw = status.nextDate // should be in ISO format or timestamp

    // Convert raw date to local string
    const localDate = new Date(nextDateRaw).toLocaleString(undefined, {
        weekday: 'short',
        year: 'numeric',
        month: 'short',
        day: 'numeric',
        hour: '2-digit',
        minute: '2-digit',
        second: '2-digit',
        hour12: false
    })

    // Append formatted data to output string
    output += `Name: ${name}\n`
    output += `  Running: ${isRunning ? 'Yes' : 'No'}\n`
    output += `  Description: ${nextDescription}\n`
    output += `  Next Time (Local): ${localDate}\n\n`
}

// Set the final human-readable string as the new payload
msg.payload = output.trim()

// Return the modified message object
return msg
1 Like

Nice! Although I'm mainly only providing the debugs for Steve, and he might prefer if they were left untouched.

That being said, I know I can definitely use this for other purposes! Thank you!

It wasn't I was trying to upstage you.

Just to Decode who was doing what and all the states.....
I decided to make it human readable.

ARGH!

One of them was due to do something in a short time and I remembered.

I clicked the list in-active and got nothing. Rather than list all I pressed the start all by mistake.

You got nothing at all?

You should at least see a debug like this:

If the array is 0, then there are no paused/inactive solar events currently. When there are pause/inactive solar events, they'll be listed under the array.

@LondonBenji your latest flow helped me dig in and find the cause. I wont go into detail other than to say it was a loop issue whereby I would loop through each task and call start/update but due to referential changes occurring inside the loop, some items would get skipped over.

I am absolutely, totally, utterly, almost 99.9% confident this is now quashed! :wink:

V2.2.4 is in the flows library (and should be in the Node-RED caletgogue within 30 mins.

4 Likes

(me?) No, I meant I stuffed up getting the correct list and so I lost the option of seeing if any of them were in the wrong state.

I'm confident you have! Sorry I am away on work travel this week so I've missed this!

I updated it today but have missed today's cycle! Will let you know tomorrow!

WE :clap: ARE :clap: GOOD! :clap:

BIG thank you once again to @Steve-Mcl for listening to my insane ramblings once again, and working hard to look into this! I'll see you again in another three years when I find another obscure bug because I'm doing something weird/stupid! Gotta have a three part series right?! :rofl:

2 Likes

So was it resolved by the new release?