Cronplus - 2 static sun events with different offsets

I have cronplus running since nearly a year with about 30 dynamic schedules. Now I have include 2 sun events with different offsets for an outside light. One is sunrise with offset -30 and the other one is sunset with offset +15.
I have chosen fan out to separate outputs.
dynamic schedules work ok,
sunrise work ok
but sunset does not trigger its output at the right time.
status-all-static does show sunset schedule

What could be the reason for this?

Don't know the answer but I will say that I no longer use CRON+ for that as I found it a bit too complex for my simple brain. Instead I use the nodes in node-red-contrib-sun-position.

This runs at startup:
image

That both updates a global var and outputs to MQTT every minute.

Sounds like a question for @Steve-Mcl

@juntiedt can you provide a minimal flow that describes this issue?

(to export a flow, select the nodes you wish to export, then press CTRL+E & copy to clipboard)

Hi Steve,

the problem is, that sunset only works once and not repeatedly all days. In order to test it I have to wait at least 2 days. As I started it yesterday night, first trigger will be today at sunset. Then I have to wait another day to see if it triggers again or fails. At least it should give you an idea what exactly is the problem.
Please find attached my flow and a file with my dynamic schedules which I load into Cron+

Standard.txt (5.9 KB)

[{"id":"70489757.9ad0d8","type":"cronplus","z":"4e969c7c.f77dc4","name":"Heating","outputField":"payload","timeZone":"","persistDynamic":true,"commandResponseMsgOutput":"fanOut","outputs":4,"options":[{"name":"Sunrise","topic":"Sunrise","payloadType":"date","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"48.38157356491496 10.437845885753632","offset":"-30","solarType":"selected","solarEvents":"sunrise"},{"name":"Sunset","topic":"Sunset","payloadType":"date","payload":"","expressionType":"solar","expression":"0 * * * * * *","location":"48.38157356491496 10.437845885753632","offset":"15","solarType":"selected","solarEvents":"sunset"}],"x":260,"y":800,"wires":[["273220ca.4f9ed"],["5995faa0.49adc4"],["e381ec2d.78eb2"],["4fec987f.72b318"]]},{"id":"5355c793.e8c0b8","type":"ui_template","z":"4e969c7c.f77dc4","group":"8784088a.4ec318","name":"","order":8,"width":16,"height":22,"format":"<style type=\"text/css\">\n.t1  {border-collapse:collapse;border-spacing:0;border-color:#ccc;}\n.t1 td{font-family:Arial, sans-serif;font-size:14px;padding:8px 3px;border-style:solid;border-width:0px;overflow:hidden;word-break:normal;border-top-width:1px;border-bottom-width:1px;border-color:#ccc;color:#333;background-color:#fff;}\n.t1 th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#ccc;color:#333;background-color:#f0f0f0;}\n.t1 .t1-36r9{background-color:#000000;color:#ffffff;text-align:left;vertical-align:top}\n.t1 .t1-x2zo{background-color:#c0c0c0;font-size:small;text-align:left;vertical-align:top}\n.t1 .t1-o73e{background-color:#c0c0c0;font-size:small;text-align:center;vertical-align:top}\n.t1 .t1-5qt9{font-size:small;text-align:left;vertical-align:top}\n.t1 .t1-5qta{font-size:small;text-align:center;vertical-align:middle}\n</style>\n<table class=\"t1\">\n  <tr>\n    <th class=\"t1-36r9\" colspan=\"9\">CRON Schedules</th>\n  </tr>\n  <tr>\n    <td class=\"t1-x2zo\">Name</td>\n    <td class=\"t1-x2zo\">Expression</td>\n    <td class=\"t1-x2zo\">Payload</td>\n    <td class=\"t1-x2zo\">Description</td>\n    <td class=\"t1-x2zo\">Next run</td>\n    <td class=\"t1-x2zo\">State</td>\n    <!-- <td class=\"t1-o73e\">Delete</td>\n    <td class=\"t1-o73e\">Pause</td>\n    <td class=\"t1-o73e\">Resume</td> -->\n  </tr>\n  <tr  ng-repeat=\"item in msg.payload\">\n    <td class=\"t1-5qt9\">{{item.config.name}}</td>\n    <td class=\"t1-5qt9\" style=\"white-space: nowrap\" nowrap>{{item.config.expression}}</td>\n    <td class=\"t1-5qt9\">{{item.config.payload}}</td>\n    <td class=\"t1-5qt9\">{{item.status.description}}</td>\n    <td class=\"t1-5qt9\">{{item.status.nextDescription}}</td>\n    <td class=\"t1-5qta\"><i class=\"fa fa-{{item.status.isRunning ? 'play' : 'pause'}}\"> </i></td>\n\n   <!-- <td class=\"t1-5qta\">\n       <md-button class=\"md-raised\"\n        ng-click=\"send([[{payload:{command:'remove', name: item.config.name}}, {payload:{command:'list-all'}}]]);\"> <i class=\"fa fa-trash\"> </i></md-button>\n   </td>\n   <td class=\"t1-5qta\">\n       <md-button class=\"button\" \n       ng-click=\"send([[{payload:{command:'pause', name: item.config.name}}, {payload:{command:'list-all'}}]]);\"> <i class=\"fa fa-pause\"> </i></md-button>\n   </td>\n   <td class=\"t1-5qta\">\n       <md-button class=\"button\" \n       ng-click=\"send([[{payload:{command:'start', name: item.config.name}}, {payload:{command:'list-all'}}]]);\"> <i class=\"fa fa-play\"> </i></md-button>\n   </td> -->\n\n  </tr>\n\n </tbody>\n</table>\n\n<!--<table id=\"table\" class=\"table table-striped table-responsive-md btn-table\" >-->\n<!--     <tr>-->\n<!--        <th>Name</th> -->\n<!--        <th>Expression</th> -->\n<!--        <th>Payload</th> -->\n<!--        <th>Description</th>-->\n<!--        <th>Next run</th>-->\n<!--        <th>State</th>-->\n<!--        <th>Delete</th>-->\n<!--        <th>Pause</th>-->\n<!--        <th>Resume</th>-->\n<!-- </tr>-->\n<!-- <tbody>-->\n<!-- <tr ng-repeat=\"item in msg.payload\">-->\n<!--   <td >{{item.config.name}}</td>-->\n<!--   <td style=\"white-space: nowrap\" nowrap>{{item.config.expression}}</td>-->\n<!--   <td >{{item.config.payload}}</td>-->\n<!--   <td >{{item.status.description}}</td>-->\n<!--   <td >{{item.status.nextDescription}}</td>-->\n<!--   <td >{{item.status.isRunning ? 'Running' : 'Paused'}}</td>-->\n<!--   <td>-->\n<!--       <md-button class=\"md-raised\"-->\n<!--        ng-click=\"send([[{payload:{command:'remove', name: item.config.name}}, {payload:{command:'list-all'}}]]);\"> <i class=\"fa fa-trash\"> </i></md-button>-->\n<!--   </td>-->\n<!--   <td>-->\n<!--       <md-button class=\"button\" -->\n<!--       ng-click=\"send([[{payload:{command:'pause', name: item.config.name}}, {payload:{command:'list-all'}}]]);\"> <i class=\"fa fa-pause\"> </i></md-button>-->\n<!--   </td>-->\n<!--   <td>-->\n<!--       <md-button class=\"button\" -->\n<!--       ng-click=\"send([[{payload:{command:'start', name: item.config.name}}, {payload:{command:'list-all'}}]]);\"> <i class=\"fa fa-play\"> </i></md-button>-->\n<!--   </td>-->\n<!-- </tr>-->\n<!-- </tbody>-->\n<!--</table>-->\n\n","storeOutMessages":false,"fwdInMessages":false,"resendOnRefresh":false,"templateScope":"local","x":820,"y":1020,"wires":[[]]},{"id":"3b9c3e39.b0eaf2","type":"function","z":"4e969c7c.f77dc4","name":"status-all","func":"if(!msg.payload || !msg.payload.result || !msg.payload.result.length){\n    msg.payload = [];\n    return msg;\n}\nmsg.payload = msg.payload.result;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":1020,"wires":[["5355c793.e8c0b8"]]},{"id":"3dba72ab.a9c45e","type":"ui_button","z":"4e969c7c.f77dc4","name":"Status all-dynamic","group":"8784088a.4ec318","order":2,"width":4,"height":1,"passthru":true,"label":"Heizprofilstatus","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"status-all","topicType":"str","x":510,"y":200,"wires":[["8ed2d296.e5771"]]},{"id":"59f8dec0.63298","type":"ui_button","z":"4e969c7c.f77dc4","name":"Remove all dynamic","group":"8784088a.4ec318","order":4,"width":4,"height":1,"passthru":true,"label":"Heizprofil löschen","tooltip":"","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"remove-all-dynamic","x":220,"y":280,"wires":[["93efb1f9.b065f","9c5dd9ca.052698"]]},{"id":"fe876335.8d72c","type":"ui_button","z":"4e969c7c.f77dc4","name":"Load all dynamic","group":"8784088a.4ec318","order":3,"width":4,"height":1,"passthru":true,"label":"Heizprofil laden","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"date","topic":"","x":230,"y":340,"wires":[["bee78fa3.da3b6","ce5507d1.7ea898"]]},{"id":"ce186cd3.00ed4","type":"function","z":"4e969c7c.f77dc4","name":"","func":"msg.payload = {\"command\":\"describe\",\n               \"expressionType\":\"solar\",\n               \"location\":\"48.38157356491496 10.437845885753632\",\n               \"solarType\":\"selected\",\n               \"solarEvents\":\"sunrise,sunset\",\n               \"timeZone\":\"Europe/Berlin\"\n              };\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":480,"y":100,"wires":[["6e94c237.fde8dc"]]},{"id":"be95831c.56938","type":"inject","z":"4e969c7c.f77dc4","name":"at 00:01","props":[{"p":"payload"}],"repeat":"","crontab":"01 00 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":260,"y":80,"wires":[["ce186cd3.00ed4"]]},{"id":"4fec987f.72b318","type":"switch","z":"4e969c7c.f77dc4","name":"","property":"payload.command.command","propertyType":"msg","rules":[{"t":"eq","v":"describe","vt":"str"},{"t":"eq","v":"status-all","vt":"str"},{"t":"eq","v":"status-all-static","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":470,"y":980,"wires":[["8cf018fb.860648"],["3b9c3e39.b0eaf2"],["984d98ad8e343a08"]]},{"id":"8cf018fb.860648","type":"function","z":"4e969c7c.f77dc4","name":"get sr + ss items","func":"\nvar sunrise = msg.payload.result.eventTimes.find(e => {\n    return e.event == \"sunrise\"\n})\n\nvar sunset = msg.payload.result.eventTimes.find(e => {\n    return e.event == \"sunset\"\n})\n\nmsg.payload = {\n    sunrise : sunrise.time,\n    sunset : sunset.time\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":640,"y":940,"wires":[["eddd2a47.4c59d8","698182eb.6b7f3c"]]},{"id":"3c9082b6.02527e","type":"moment","z":"4e969c7c.f77dc4","name":"timestamp","topic":"","input":"","inputType":"msg","inTz":"Europe/Berlin","adjAmount":0,"adjType":"days","adjDir":"add","format":"x","locale":"de-DE","output":"","outputType":"msg","outTz":"Europe/Berlin","x":970,"y":900,"wires":[["89731ed5.1eaa","89878eaf.1f54e"]]},{"id":"14a096a8.7cfa79","type":"moment","z":"4e969c7c.f77dc4","name":"timestamp","topic":"","input":"","inputType":"msg","inTz":"Europe/Berlin","adjAmount":0,"adjType":"days","adjDir":"add","format":"x","locale":"de-DE","output":"","outputType":"msg","outTz":"Europe/Berlin","x":970,"y":980,"wires":[["57a09140.7e8e1","c7211032.45a01"]]},{"id":"b009ed30.c3d08","type":"ui_dropdown","z":"4e969c7c.f77dc4","name":"","label":"Heizungsprofile","tooltip":"","place":"Select option","group":"8784088a.4ec318","order":1,"width":0,"height":0,"passthru":false,"multiple":false,"options":[{"label":"Standard","value":1,"type":"num"},{"label":"Gäste","value":2,"type":"num"},{"label":"DG 18 Grad","value":3,"type":"num"},{"label":"Urlaub","value":4,"type":"num"}],"payload":"","topic":"","x":500,"y":40,"wires":[["37fd8f27.715"]]},{"id":"37fd8f27.715","type":"change","z":"4e969c7c.f77dc4","name":"","rules":[{"t":"set","p":"profilenummer","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":40,"wires":[["9cb0f7c5.74fd78"]]},{"id":"93efb1f9.b065f","type":"delay","z":"4e969c7c.f77dc4","name":"20 ms","pauseType":"delay","timeout":"20","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":270,"y":220,"wires":[["3dba72ab.a9c45e"]]},{"id":"ec3a1a4e.dfa0e8","type":"link in","z":"4e969c7c.f77dc4","name":"Status","links":["a21f9d7c.8aa0b","3448e26.76c571e"],"x":55,"y":220,"wires":[["93efb1f9.b065f"]]},{"id":"5f636878.66aff8","type":"file in","z":"4e969c7c.f77dc4","name":"","filename":"/home/pi/Heizungsprofile/Standard.txt","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":570,"y":480,"wires":[["13483ad5.b67f65"]]},{"id":"33b32bc9.a11024","type":"json","z":"4e969c7c.f77dc4","name":"","property":"payload","action":"","pretty":true,"x":1030,"y":540,"wires":[["4a9fce4d.54d75","a21f9d7c.8aa0b","3f76705c.b36e5"]]},{"id":"4a9fce4d.54d75","type":"debug","z":"4e969c7c.f77dc4","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1190,"y":540,"wires":[]},{"id":"13483ad5.b67f65","type":"switch","z":"4e969c7c.f77dc4","name":"","property":"payload","propertyType":"msg","rules":[{"t":"nempty"}],"checkall":"true","repair":false,"outputs":1,"x":910,"y":540,"wires":[["33b32bc9.a11024"]]},{"id":"3b6dab5.be4ea54","type":"file in","z":"4e969c7c.f77dc4","name":"","filename":"/home/pi/Heizungsprofile/Gaeste.txt","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":560,"y":520,"wires":[["13483ad5.b67f65"]]},{"id":"cdc555ba.a9b5e8","type":"file in","z":"4e969c7c.f77dc4","name":"","filename":"/home/pi/Heizungsprofile/DG-18-Grad.txt","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":580,"y":560,"wires":[["13483ad5.b67f65"]]},{"id":"a2ee7cd9.983b3","type":"file in","z":"4e969c7c.f77dc4","name":"","filename":"/home/pi/Heizungsprofile/Urlaub.txt","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":560,"y":600,"wires":[["13483ad5.b67f65"]]},{"id":"bee78fa3.da3b6","type":"switch","z":"4e969c7c.f77dc4","name":"flow profilenummer","property":"profilenummer","propertyType":"flow","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"eq","v":"3","vt":"num"},{"t":"eq","v":"4","vt":"num"}],"checkall":"true","repair":false,"outputs":4,"x":250,"y":540,"wires":[["5f636878.66aff8"],["3b6dab5.be4ea54"],["cdc555ba.a9b5e8"],["a2ee7cd9.983b3"]]},{"id":"a21f9d7c.8aa0b","type":"link out","z":"4e969c7c.f77dc4","name":"load done","links":["ec3a1a4e.dfa0e8"],"x":1135,"y":500,"wires":[]},{"id":"89731ed5.1eaa","type":"change","z":"4e969c7c.f77dc4","name":"","rules":[{"t":"set","p":"sunrise","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1180,"y":880,"wires":[["e4da9af1.a16978"]]},{"id":"57a09140.7e8e1","type":"change","z":"4e969c7c.f77dc4","name":"","rules":[{"t":"set","p":"sunset","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1180,"y":1000,"wires":[[]]},{"id":"89878eaf.1f54e","type":"mqtt out","z":"4e969c7c.f77dc4","name":"","topic":"sun/rise","qos":"0","retain":"","broker":"565c5225.bce5ac","x":1160,"y":920,"wires":[]},{"id":"c7211032.45a01","type":"mqtt out","z":"4e969c7c.f77dc4","name":"","topic":"sun/set","qos":"","retain":"","broker":"565c5225.bce5ac","x":1160,"y":960,"wires":[]},{"id":"21386ae0.1c6dd6","type":"function","z":"4e969c7c.f77dc4","name":"","func":"delete msg.topic;\nlet room = msg.payload.room;\nlet type = msg.payload.type;\nlet temp = msg.payload.value;\nmsg.payload = msg.time + \": \" + room + \" \" + type + \" \" + temp;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":820,"y":780,"wires":[["c1463448.066898"]]},{"id":"59b54d7f.fed3d4","type":"ui_toast","z":"4e969c7c.f77dc4","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"","raw":false,"topic":"","name":"Soll-Temperaturwechsel","x":1190,"y":780,"wires":[]},{"id":"9c5dd9ca.052698","type":"link out","z":"4e969c7c.f77dc4","name":"","links":["f1362681.3482f8"],"x":635,"y":280,"wires":[]},{"id":"8ed2d296.e5771","type":"link out","z":"4e969c7c.f77dc4","name":"","links":["f1362681.3482f8"],"x":635,"y":200,"wires":[]},{"id":"3f76705c.b36e5","type":"link out","z":"4e969c7c.f77dc4","name":"","links":["f1362681.3482f8"],"x":1135,"y":580,"wires":[]},{"id":"f1362681.3482f8","type":"link in","z":"4e969c7c.f77dc4","name":"CRON PLUS","links":["3f76705c.b36e5","6e94c237.fde8dc","8ed2d296.e5771","9c5dd9ca.052698"],"x":95,"y":800,"wires":[["70489757.9ad0d8"]]},{"id":"eddd2a47.4c59d8","type":"change","z":"4e969c7c.f77dc4","name":"sunrise","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.sunrise","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":900,"wires":[["3c9082b6.02527e"]]},{"id":"698182eb.6b7f3c","type":"change","z":"4e969c7c.f77dc4","name":"sunset","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.sunset","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":980,"wires":[["14a096a8.7cfa79"]]},{"id":"6e94c237.fde8dc","type":"link out","z":"4e969c7c.f77dc4","name":"","links":["f1362681.3482f8"],"x":635,"y":100,"wires":[]},{"id":"9cb0f7c5.74fd78","type":"link out","z":"4e969c7c.f77dc4","name":"profil out","links":["3bbc34a9.cfd8bc","e767c620.4102b8"],"x":875,"y":40,"wires":[]},{"id":"e767c620.4102b8","type":"link in","z":"4e969c7c.f77dc4","name":"load dynamic","links":["9cb0f7c5.74fd78","bdc9d93.69b7f28"],"x":55,"y":340,"wires":[["fe876335.8d72c"]]},{"id":"b1d3a5cd.458c88","type":"link in","z":"4e969c7c.f77dc4","name":"remove all dynamic","links":["63c75b60.30bb04"],"x":55,"y":280,"wires":[["59f8dec0.63298"]]},{"id":"a35ed99c.1f34c8","type":"link out","z":"4e969c7c.f77dc4","name":"","links":["12480e97.570921"],"x":775,"y":820,"wires":[]},{"id":"1b9cda61.b7a3f6","type":"comment","z":"4e969c7c.f77dc4","name":"to room-router --->","info":"","x":1030,"y":820,"wires":[]},{"id":"c1463448.066898","type":"delay","z":"4e969c7c.f77dc4","name":"","pauseType":"rate","timeout":"4","timeoutUnits":"seconds","rate":"1","nbRateUnits":"2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":980,"y":780,"wires":[["59b54d7f.fed3d4"]]},{"id":"a0d6c44.a702438","type":"moment","z":"4e969c7c.f77dc4","name":"HH:mm","topic":"","input":"xyz","inputType":"flow","inTz":"Europe/Berlin","adjAmount":0,"adjType":"days","adjDir":"add","format":"HH:mm","locale":"de-DE","output":"time","outputType":"msg","outTz":"Europe/Berlin","x":660,"y":780,"wires":[["21386ae0.1c6dd6"]]},{"id":"defdf4d8.0e4288","type":"change","z":"4e969c7c.f77dc4","name":"no topic","rules":[{"t":"delete","p":"topic","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":820,"wires":[["a35ed99c.1f34c8"]]},{"id":"3448e26.76c571e","type":"link out","z":"4e969c7c.f77dc4","name":"","links":["ec3a1a4e.dfa0e8"],"x":635,"y":340,"wires":[]},{"id":"ce5507d1.7ea898","type":"delay","z":"4e969c7c.f77dc4","name":"10 ms","pauseType":"delay","timeout":"10","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":470,"y":340,"wires":[["3448e26.76c571e"]]},{"id":"b1013812.06a738","type":"link in","z":"4e969c7c.f77dc4","name":"cron init","links":["35ca8d8a.b96ce2","e51bdc1c.bb49a"],"x":295,"y":120,"wires":[["ce186cd3.00ed4","494b9af3.0911c4"]]},{"id":"494b9af3.0911c4","type":"delay","z":"4e969c7c.f77dc4","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":260,"y":180,"wires":[["3dba72ab.a9c45e"]]},{"id":"e381ec2d.78eb2","type":"function","z":"4e969c7c.f77dc4","name":"if cron true","func":"if (global.get('cron') === true){\n    node.status({fill:\"green\",shape:\"ring\",text:\"true\"});\n    return msg;\n}\nelse {\n    node.status({fill:\"red\",shape:\"ring\",text:\"false\"});\n}\nreturn null;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":800,"wires":[["a0d6c44.a702438","defdf4d8.0e4288"]]},{"id":"273220ca.4f9ed","type":"function","z":"4e969c7c.f77dc4","name":"Aussenlampe aus","func":"//msg.payload = timeString_hm() + \": Aussenlicht aus\";\nlet t = date_time_string(\"dayhm\") + \" aus\";\nnode.status({fill:\"green\", shape:\"ring\", text:t});\nreturn{payload:{'room':\"Aussenlampe\", 'switch': \"off\"}};\n\n\nfunction date_time_string(type){\n    let date = new Date(Date.now());\n    let year = date.getFullYear();\n    let month = (\"0\" + (date.getMonth() + 1)).slice(-2);\n    let day = (\"0\" + date.getDate()).slice(-2);\n    let hours = (\"0\" + date.getHours()).slice(-2);\n    let minutes = (\"0\" + date.getMinutes()).slice(-2);\n    let seconds = (\"0\" + date.getSeconds()).slice(-2);\n    let datetimestring = \"\";\n    switch(type) {\n        case \"full\":\n            datetimestring = day + \"-\" + month + \"-\" + year + \" \" + hours + ':' + minutes + ':' + seconds;  \n        break\n        case \"dayhm\":\n            datetimestring = day + \".\" + month + \" @ \" + hours + ':' + minutes;  \n        break        \n        case \"hm\": \n            datetimestring = hours + ':' + minutes;  \n        break\n        case \"hms\":\n            datetimestring = hours + ':' + minutes + ':' + seconds;  \n        break  \n        case \"ts\":\n            datetimestring = Date.now();  \n        break\n        default:\n            datetimestring = null;        \n    }\n    return datetimestring;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":660,"wires":[["3e9b5919.48a6d6","c4b8f661.8eb868"]]},{"id":"5995faa0.49adc4","type":"function","z":"4e969c7c.f77dc4","name":"Aussenlampe an","func":"//msg.payload = timeString_hm() + \": Aussenlicht an\";\nlet t = date_time_string(\"dayhm\") + \" an\";\nnode.status({fill:\"red\",shape:\"ring\",text:t});\nreturn{payload:{'room':\"Aussenlampe\", 'switch': \"on\"}};\n\nfunction date_time_string(type){\n    let date = new Date(Date.now());\n    let year = date.getFullYear();\n    let month = (\"0\" + (date.getMonth() + 1)).slice(-2);\n    let day = (\"0\" + date.getDate()).slice(-2);\n    let hours = (\"0\" + date.getHours()).slice(-2);\n    let minutes = (\"0\" + date.getMinutes()).slice(-2);\n    let seconds = (\"0\" + date.getSeconds()).slice(-2);\n    let datetimestring = \"\";\n    switch(type) {\n        case \"full\":\n            datetimestring = day + \"-\" + month + \"-\" + year + \" \" + hours + ':' + minutes + ':' + seconds;  \n        break\n        case \"dayhm\":\n            datetimestring = day + \".\" + month + \" @ \" + hours + ':' + minutes;  \n        break        \n        case \"hm\": \n            datetimestring = hours + ':' + minutes;  \n        break\n        case \"hms\":\n            datetimestring = hours + ':' + minutes + ':' + seconds;  \n        break  \n        case \"ts\":\n            datetimestring = Date.now();  \n        break\n        default:\n            datetimestring = null;        \n    }\n    return datetimestring;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":720,"wires":[["3e9b5919.48a6d6","c4b8f661.8eb868"]]},{"id":"bb06b69c.864748","type":"file","z":"4e969c7c.f77dc4","name":"","filename":"/home/pi/logs/crontest.txt","appendNewline":true,"createDir":true,"overwriteFile":"false","encoding":"none","x":1270,"y":660,"wires":[[]]},{"id":"3e9b5919.48a6d6","type":"link out","z":"4e969c7c.f77dc4","name":"","links":["4aa91ee5.08bf2"],"x":675,"y":720,"wires":[]},{"id":"c4b8f661.8eb868","type":"json","z":"4e969c7c.f77dc4","name":"","property":"payload","action":"","pretty":false,"x":710,"y":660,"wires":[["f8ff54b893b7b872"]]},{"id":"60882f6c.803ac","type":"comment","z":"4e969c7c.f77dc4","name":"to output router --->","info":"","x":930,"y":720,"wires":[]},{"id":"a1dcf39b.e4e5c","type":"function","z":"4e969c7c.f77dc4","name":"","func":"let day = 1000*60*60*24;\nlet sr = parseInt (flow.get('sunrise'));\nlet ss = parseInt(flow.get('sunset'));\nlet dif = (ss - sr);\n//msg.topic = \"debug\"  \n//msg.payload = dif;\n//node.send(msg);\nlet dauer_tag = runtime_str(dif);\ndif = day - dif;\nlet dauer_nacht = runtime_str(dif);\nflow.set('tag', dauer_tag);\nflow.set('nacht', dauer_nacht);\nmsg.payload = dauer_tag + \" : \" + dauer_nacht; \nreturn msg;\n\n//----------------------------------\n\n//  HH:MM:SS\n\nfunction runtime_str(ms){\n    let t = ms / 1000;\n    let h = (Math.floor(t / 3600)).toString();\n    let m = (Math.floor(t%3600 / 60)).toString();\n    let s = (Math.floor(t%3600 % 60)).toString();\n//    let r = h + \":\" + (\"0\" + m).slice(-2) + \":\" + (\"0\" + s).slice(-2);\n    let r = h + \":\" + (\"0\" + m).slice(-2);    \n    return r;  \n}\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1500,"y":880,"wires":[["21b33ac3.087866"]]},{"id":"e4da9af1.a16978","type":"delay","z":"4e969c7c.f77dc4","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1350,"y":880,"wires":[["a1dcf39b.e4e5c"]]},{"id":"21b33ac3.087866","type":"debug","z":"4e969c7c.f77dc4","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1650,"y":880,"wires":[]},{"id":"f8ff54b893b7b872","type":"moment","z":"4e969c7c.f77dc4","name":"HH:mm:ss DD-MM-YYYY","topic":"","input":"","inputType":"date","inTz":"Europe/Berlin","adjAmount":0,"adjType":"days","adjDir":"add","format":"HH:mm:ss DD-MM-YYYY","locale":"de-DE","output":"time","outputType":"msg","outTz":"Europe/Berlin","x":890,"y":660,"wires":[["f6485f97095ec635"]]},{"id":"f6485f97095ec635","type":"function","z":"4e969c7c.f77dc4","name":"","func":"msg.payload = msg.time + \": \" + msg.payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1080,"y":660,"wires":[["bb06b69c.864748"]]},{"id":"3af96d9249140f37","type":"inject","z":"4e969c7c.f77dc4","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"status-all-static","payloadType":"str","x":130,"y":920,"wires":[["70489757.9ad0d8"]]},{"id":"984d98ad8e343a08","type":"debug","z":"4e969c7c.f77dc4","name":"status-all-static","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":430,"y":1040,"wires":[]},{"id":"8784088a.4ec318","type":"ui_group","name":"CRON","tab":"9920c734.9de2a8","order":3,"disp":false,"width":"16","collapse":false},{"id":"565c5225.bce5ac","type":"mqtt-broker","name":"MQTT server","broker":"10.0.0.43","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"9920c734.9de2a8","type":"ui_tab","name":"CRON Plus","icon":"dashboard","order":22,"disabled":false,"hidden":false}]````

I just found that "status-all" does not show sunrise at now 10:30 in the morning. It shows sunset which should be ok. I asume, that at midnight one have to reinitialise sunrise and sunset. Could it be that this is not the case for sunset?

Hallo Steve,

latest status:

  • after deployment static sunrise and sunset work only once.

  • both times are available in Status all

  • when one static item was executed it disapears from status-all

  • when sunset (second item) was triggered no static item shows up in status-all (all dynamic schedules are shown in status-all)

  • shortly after midnight both, sunset and sunrise, are again in status-all and the times shown seem to be ok

  • unfortunately both are not triggered a that time the second day

I have removed sunset and surise from CRON+ and started a test on another raspi without dynamic schedules. will see what happens and will keep you updated.

In mean time I went back to SunCron, which I used before for my outside light, but it would be nice to have just one node for all timing issues - CRON+.

Thanks for the feedback. Keep it coming. I am also running tests logging to file. Hopefully we can get to the bottom of this.

Ps, when replying to me specifically, either click the reply button attached to my comment or tag me using @Steve-Mcl (otherwise I don't get a notification)

Also, can you confirm what versions you are using?

  • node-red version
  • nodejs version
  • cron+ version

thanks.

Node Red : 2.0.5
CRON+ 1.5.4
node js 12.22.5

1 Like

Update:
I have run CRON+ with only 2 static schedules (sunrise and sunset) and no dynamic schedules and it works ok.

The problem must occur when dynamic and static schedules are in one CRON+ node.

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