# Cron plus output

**URL:** <https://discourse.nodered.org/t/cron-plus-output/56417>\
**Category:** General\
**Created:** [10 January 2022 18:32 UTC](https://discourse.nodered.org/t/cron-plus-output/56417 "2022-01-10T18:32:22Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [10 January 2022 18:32 UTC](https://discourse.nodered.org/t/cron-plus-output/56417/1 "2022-01-10T18:32:22Z")

</div>

Trying to setup cron plus for sunrise sunset events outputting boolean-logic, for several days have tried to see what outputs when but due to several missteps haven't had any luck. I am assuming the node will output true at sunset then false at sunrise, can someone verify that please?

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [10 January 2022 18:43 UTC](https://discourse.nodered.org/t/cron-plus-output/56417/2 "2022-01-10T18:43:30Z")

</div>

You need to set 2 events; one for sunset, and a second for sunrise.  
You can set whatever output you want for each event.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [10 January 2022 19:37 UTC](https://discourse.nodered.org/t/cron-plus-output/56417/3 "2022-01-10T19:37:53Z")

</div>

> [@gerry](#):
>
> I am assuming the node will output true at sunset then false at sunrise, can someone verify that please

As @Paul-Reed already stated you can output whatever you wish. To add to that ...

You could add 2 schedules (one for sunrise, one for sunset), each with own topic and whatever payload you care to send - just enter what type and value in the payload field in the list of schedules.

Or

You could have 1 schedule with both sunrise and sunset selected with the default payload (if you check the debug output you will see how you can identify which is which)

If you are struggling, I'll send you a screenshot or example flow

---

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [10 January 2022 23:04 UTC](https://discourse.nodered.org/t/cron-plus-output/56417/4 "2022-01-10T23:04:14Z")

</div>

Got it so close, but.......  
There is a tab on the left side of the node you can press to fire the node. I would like to have the node output every minute or so, is there a way to do that with the solar events selected?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [10 January 2022 23:23 UTC](https://discourse.nodered.org/t/cron-plus-output/56417/5 "2022-01-10T23:23:47Z")

</div>

> [@gerry](#):
>
> every minute or so, is there a way to do that with the solar events selected

Yes, kinda, but why? A solar event happens once per day.

Explain what you are trying to achieve.

Note: you can always store to context the current solar state & use a 1sec pulse to compare it to a desired value.

Additionally you can trigger any Cron-plus schedule by firing a message into it. Read the built in help for how to & try the built in examples (CTRL-I \> examples \> Cron-plus)

---

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [10 January 2022 23:25 UTC](https://discourse.nodered.org/t/cron-plus-output/56417/6 "2022-01-10T23:25:09Z")

</div>

Trying to countdown to sunset, then count down to sunrise

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [10 January 2022 23:29 UTC](https://discourse.nodered.org/t/cron-plus-output/56417/7 "2022-01-10T23:29:22Z")

</div>

Ok, so you can send a status request message to the Cron plus node (it's documented in the built in help and in one of the built in demos)

The resulting msg will have various properties relating to solar state - one of them being the time of the next event. You could poll the Cron node and use this timestamp to determine how long until the solar event.

---

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [11 January 2022 00:29 UTC](https://discourse.nodered.org/t/cron-plus-output/56417/8 "2022-01-11T00:29:56Z")

</div>

Hit a wrinkle, when the node fires on auto pilot it sends msg.cronplus.... when I query status it sends msg.payload....  
That messes with the code downstream

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [11 January 2022 00:51 UTC](https://discourse.nodered.org/t/cron-plus-output/56417/9 "2022-01-11T00:51:44Z")

</div>

> [@gerry](#):
>
> when the node fires on auto pilot it sends msg.cronplus

Hello Gerry .. Show us how you have configured the cron-plus node. (better share an exported flow)  
I suspect you set the node's **Output property** to send the msg to `msg.cronplus` ??

---

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [11 January 2022 01:03 UTC](https://discourse.nodered.org/t/cron-plus-output/56417/10 "2022-01-11T01:03:28Z")

</div>

node setup

```auto
[{"id":"725ce986ad0ed73f","type":"tab","label":"Light Timer","disabled":false,"info":"","env":[]},{"id":"1d722d8e960ff38c","type":"function","z":"725ce986ad0ed73f","name":"on off time","func":"let Z = msg.payload.result[0].status.nextDescription;\nlet MyText = Z;\nlet Result = MyText.replace(\"hour\", \"hr\");\nMyText = Result;\nResult = MyText.replace(\"minutes\", \"min\");\nMyText = Result;\nResult = MyText.replace(\"seconds\", \"sec\");\n\n msg = {\n payload: Result,\n }\n\nnode.status({fill:\"blue\",shape:\"dot\",text: Result});\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":280,"wires":[["5e450ba3197daf5d"]]},{"id":"89a6696b56acaffa","type":"ui_template","z":"725ce986ad0ed73f","group":"e4085d44342e34c2","name":"night or day","order":4,"width":6,"height":1,"format":"<div>\n <md-button class=\"md-button mine-button\"\n data-topic=\"target\"\n data-payload=\"1\">{{msg.payload}}\n </md-button>\n</div>\n","storeOutMessages":true,"fwdInMessages":false,"resendOnRefresh":false,"templateScope":"local","className":"","x":690,"y":220,"wires":[[]]},{"id":"5e450ba3197daf5d","type":"ui_template","z":"725ce986ad0ed73f","group":"e4085d44342e34c2","name":"off on text","order":5,"width":6,"height":1,"format":"<div>\n <md-button class=\"md-button mine-button\"\n data-topic=\"target\"\n data-payload=\"1\">{{msg.payload}}\n </md-button>\n</div>\n","storeOutMessages":true,"fwdInMessages":false,"resendOnRefresh":false,"templateScope":"local","x":680,"y":280,"wires":[[]]},{"id":"708a9b7b39125171","type":"ui_template","z":"725ce986ad0ed73f","group":"e4085d44342e34c2","name":"sunrise","order":2,"width":6,"height":1,"format":"<div>\n <md-button class=\"md-button mine-button\"\n data-topic=\"target\"\n data-payload=\"1\">{{msg.payload}}\n </md-button>\n</div>\n","storeOutMessages":true,"fwdInMessages":false,"resendOnRefresh":false,"templateScope":"local","x":980,"y":320,"wires":[[]]},{"id":"29d0a1e042e45a76","type":"ui_template","z":"725ce986ad0ed73f","group":"e4085d44342e34c2","name":"sunset","order":3,"width":6,"height":1,"format":"<div>\n <md-button class=\"md-button mine-button\"\n data-topic=\"target\"\n data-payload=\"1\">{{msg.payload}}\n </md-button>\n</div>\n","storeOutMessages":true,"fwdInMessages":false,"resendOnRefresh":false,"templateScope":"local","x":970,"y":400,"wires":[[]]},{"id":"882599ddb8c4cca7","type":"ui_template","z":"725ce986ad0ed73f","group":"e4085d44342e34c2","name":"light timers time date","order":1,"width":6,"height":1,"format":"<div>\n <md-button class=\"md-button mine-button\"\n data-topic=\"target\"\n data-payload=\"1\">{{msg.payload}}\n </md-button>\n</div>\n","storeOutMessages":true,"fwdInMessages":false,"resendOnRefresh":false,"templateScope":"local","className":"","x":500,"y":120,"wires":[[]]},{"id":"b59011b8a8159713","type":"function","z":"725ce986ad0ed73f","name":"sunset","func":"let Z = msg.payload.result[0].status.solarTimes[0].time;\n\nnode.status({ fill: \"red\", shape: \"ring\", text:Z});\n\nmsg.payload = Z;\n\nreturn msg;\n\n//payload.result[0].status.solarTimes[0].time","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":470,"y":420,"wires":[["e325f73816856bb7"]]},{"id":"e13f97af6e1c814e","type":"function","z":"725ce986ad0ed73f","name":"sunset fix","func":"msg.payload = 'Sunset is at ' + msg.payload;\nnode.status({fill:\"blue\",shape:\"dot\",text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":820,"y":400,"wires":[["29d0a1e042e45a76"]]},{"id":"1b7d8d6b5dc8c978","type":"function","z":"725ce986ad0ed73f","name":"sunrise","func":"/*\nlet Z = msg.cronplus.status.solarTimes[1].time;\nif (typeof Z == 'undefined') {\n Z = 100;\n}\n*/\nlet X = msg.payload.result[0].status.solarTimes[1].time;\n\nnode.status({ fill: \"red\", shape: \"ring\", text: X });\n\nmsg.payload = X;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":480,"y":340,"wires":[["a615e26278b0e09d"]]},{"id":"4a0e676e30fc1f1e","type":"function","z":"725ce986ad0ed73f","name":"sunrise fix","func":"msg.payload = 'Sunrise is at ' + msg.payload;\nnode.status({fill:\"blue\",shape:\"dot\",text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":820,"y":320,"wires":[["708a9b7b39125171"]]},{"id":"0a1ba7458042281c","type":"link in","z":"725ce986ad0ed73f","name":"light timers time in","links":["8d061b4d19f61c93"],"x":235,"y":120,"wires":[["882599ddb8c4cca7"]]},{"id":"e325f73816856bb7","type":"moment","z":"725ce986ad0ed73f","name":"Sunset","topic":"","input":"","inputType":"msg","inTz":"America/Denver","adjAmount":0,"adjType":"days","adjDir":"add","format":"h:mm A","locale":"en_US","output":"","outputType":"msg","outTz":"America/Denver","x":640,"y":420,"wires":[["e13f97af6e1c814e"]]},{"id":"a615e26278b0e09d","type":"moment","z":"725ce986ad0ed73f","name":"Sunrise","topic":"","input":"","inputType":"msg","inTz":"America/Denver","adjAmount":0,"adjType":"days","adjDir":"add","format":"h:mm A","locale":"en_US","output":"","outputType":"msg","outTz":"America/Denver","x":640,"y":340,"wires":[["4a0e676e30fc1f1e"]]},{"id":"846823ed4e3c45a9","type":"cronplus","z":"725ce986ad0ed73f","name":"Sunrise Sunset","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"schedule1","topic":"schedule1","payloadType":"bool","payload":"true","expressionType":"solar","expression":"0 * * * * * *","location":"50.5,-116","offset":"0","solarType":"selected","solarEvents":"sunrise,sunset"}],"x":180,"y":320,"wires":[["db3908a745229680","1d722d8e960ff38c","1b7d8d6b5dc8c978","b59011b8a8159713","a162fdbf0dd358ef"]]},{"id":"db3908a745229680","type":"function","z":"725ce986ad0ed73f","name":"Night or Day","func":"\n\nlet Z = msg.payload.result[0].status.solarState.night;\n\nlet X = msg.payload.result[0].status.solarState.day;\n\nif (Z == false && X == false) {\n msg = {\n payload: 'It is Nighttime',\n topic: 'Night',\n }\n flow.set('night', true);\n node.status({ fill: \"blue\", shape: \"dot\", text: msg.payload });\n return msg;\n}\n\nif (Z == true) {\n msg = {\n payload: 'It is Nighttime',\n topic: 'Night',\n }\n flow.set('night', true);\n}\n\nif (Z == false) {\n msg = {\n payload: 'It is Daytime',\n topic: 'Day',\n }\n flow.set('night', false);\n}\n\nnode.status({ fill: \"blue\", shape: \"dot\", text: msg.payload });\n\n\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":220,"wires":[["89a6696b56acaffa"]]},{"id":"4d225e0e5a48fd30","type":"link in","z":"725ce986ad0ed73f","name":"Light time 1 sec in","links":["7f96ac88bb8c31aa"],"x":75,"y":500,"wires":[["41b018158254ea5e"]]},{"id":"a162fdbf0dd358ef","type":"debug","z":"725ce986ad0ed73f","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":470,"y":480,"wires":[]},{"id":"41b018158254ea5e","type":"function","z":"725ce986ad0ed73f","name":"","func":"msg = {\n payload: 1,\n topic: 'status-all'\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":190,"y":500,"wires":[["846823ed4e3c45a9"]]},{"id":"af9d0d21e0f24e13","type":"inject","z":"725ce986ad0ed73f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":80,"y":440,"wires":[["41b018158254ea5e"]]},{"id":"e4085d44342e34c2","type":"ui_group","name":"Header","tab":"df1fb04258db07a7","order":1,"disp":false,"width":"6","collapse":false},{"id":"df1fb04258db07a7","type":"ui_tab","name":"Light Timer","icon":"fa-clock-o","order":5,"disabled":false,"hidden":false}]

```

 ![cron](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/d/cdbe1836514f3b91d9960bff01f95b4d4c9f7272.jpeg)

[EDIT] When the node auto fires I don't know what the output looks like, when I fire the node manually it is a different output

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [11 January 2022 01:29 UTC](https://discourse.nodered.org/t/cron-plus-output/56417/11 "2022-01-11T01:29:18Z")

</div>

> [@gerry](#):
>
> when I fire the node manually it is a different output

In this case yes .. when you manually trigger the node, you are right, the node's status and config is in `msg.cronplus` but dont worry about that because when it triggers by itself on sunrise / sunset the msg will be as you configured it (i dont see anything wrong with your configuration)

---

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [11 January 2022 01:31 UTC](https://discourse.nodered.org/t/cron-plus-output/56417/12 "2022-01-11T01:31:51Z")

</div>

Once I got my mind wrapped around that (manual vs auto) it seems to be fine. Just wish I had known that small fact about the differences in payload when I started, oh well.

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [11 January 2022 02:03 UTC](https://discourse.nodered.org/t/cron-plus-output/56417/13 "2022-01-11T02:03:01Z")

</div>

> [@gerry](#):
>
> wish I had known that small fact about the differences in payload when I started

I use the node but i didnt notice the difference either till you mentioned it 😅

It would be better if you set your cron-plus node to send the status messages to a seperate output.  
The top one for the actual event msg payload and the bottom one for the status msgs.  
This way its cleaner to seperate the logic and avoid any errors for the function nodes.

Rewiring :

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/3/e33f64a7ac2db52e33270c0f09ccc85f72af8bd9.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/4/14bd6e642e3e709498fd68330ee709fb7fccc049.png)

---

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [11 January 2022 02:09 UTC](https://discourse.nodered.org/t/cron-plus-output/56417/14 "2022-01-11T02:09:44Z")

</div>

Thanks, will do.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [11 January 2022 08:41 UTC](https://discourse.nodered.org/t/cron-plus-output/56417/15 "2022-01-11T08:41:33Z")

</div>

Excellent demo - might have to add that to the built in examples. 👍

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [11 January 2022 17:45 UTC](https://discourse.nodered.org/t/cron-plus-output/56417/16 "2022-01-11T17:45:55Z")

</div>

> [@gerry](#):
>
> I would like to have the node output every minute or so, is there a way to do that with the solar events selected?

The node-red-node-suncalc only does sunrise and sunset - but does send a 1 (light) or 0 (dark) every minute...

---

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [11 January 2022 17:58 UTC](https://discourse.nodered.org/t/cron-plus-output/56417/17 "2022-01-11T17:58:02Z")

</div>

Thanks for the heads up on the node, I'll put that in my memory bank for future use as I got the cron plus node working like I want  
[EDIT]  
Just as a side note I moved to cron plus in this instance because big timer for others was having trouble and it appears wasn't supported any more. There was a big timer node in the flow but I was concerned that some where down the road that node would quit when some dependency changed then I'd be hooped.  
Is there not some policy/agreement/standard procedure that when a node gets abandoned there should at least be a mention of that on their install for the node?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [11 January 2022 18:37 UTC](https://discourse.nodered.org/t/cron-plus-output/56417/18 "2022-01-11T18:37:05Z")

</div>

Yes. Cron-plus can just about do it all. Great place to start.  
If a node is abandoned then by definition it is unlikely to get and update to its readme to say that it is no longer receiving updates

---

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [11 January 2022 18:46 UTC](https://discourse.nodered.org/t/cron-plus-output/56417/19 "2022-01-11T18:46:23Z")

</div>

I volunteer to find the authors and speed slap them. 🙂

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [11 January 2022 18:54 UTC](https://discourse.nodered.org/t/cron-plus-output/56417/20 "2022-01-11T18:54:56Z")

</div>

> [@gerry](#):
>
> I would like to have the node output every minute or so, is there a way to do that with the solar events selected?

Just add a trigger node to the output of Cron+, it will then repeat the last message every minute, or as often as you want.

![trigger](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/c/2cd8148e0449ede5a8db324696fdc2c43fcabed6.jpeg)

[Next page](https://discourse.nodered.org/t/cron-plus-output/56417.md?page=2)
