Bigtimer challenge

Hi,

I am using Nodered and Bigtimer for my irrigation. Everything is working fine. However I would like to display the date and time of the next run. I was hoping that this could be calculated based on the combination of the date/time of the Bigtimer node (displayed under the node) and the current date/time. However I don't know how to arrange this. Does anybody have experience with this? Thanks in advance for your reaction.

Schermafbeelding 2022-08-08 om 23.09.20

Not sure you can do that with Bigtimer, you'd be better off with CRON+ for more advanced tasks.

Peter Scargill the author of the Bigtimer node comes here very seldom and has stated before he will only provide support through his Blog - you might want to head over there and ask

Obviously the source code is readily available and you could look at having a go yourself

As Julian has stated - Bigtimer is only one option

Craig

Have you tried the status node? If you use that you can capture the text below the bigtimer node and then use that in an expression

Here an example from my system

1 Like

It seems that the source is only available by installing it and finding it in the node_modules folder. It does not have a github or similar repository where one can view the source, fork it or submit issues or Pull Requests. That is one of the reasons that I switched to using the cron plus node.

1 Like

@Steve-Mcl is it possible to get the forthcoming event in Cron+'s payload?
(It's available in node status)

Yes, poke a topic of "status" and payload of the schedule name.
(or a topic of "status-all" for all schedules)

[{"id":"0cadc70ad80bc89c","type":"cronplus","z":"fc65972c8d3b1d68","name":"","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"fanOut","outputs":4,"options":[{"name":"on_sched","topic":"on","payloadType":"json","payload":"{\"state\": \"on\"}","expressionType":"cron","expression":"0 0 7 * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"off_sched","topic":"off","payloadType":"json","payload":"{\"state\": \"off\"}","expressionType":"cron","expression":"0 0 8 * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":300,"y":180,"wires":[[],[],[],["eadae4b2ac54e6d7","95f8f4acc6461ba2"]]},{"id":"5254c9e3da09bdce","type":"inject","z":"fc65972c8d3b1d68","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"status","payload":"on_sched","payloadType":"str","x":120,"y":160,"wires":[["0cadc70ad80bc89c"]]},{"id":"f22bc02b710b8a43","type":"inject","z":"fc65972c8d3b1d68","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"status","payload":"off_sched","payloadType":"str","x":120,"y":220,"wires":[["0cadc70ad80bc89c"]]},{"id":"eadae4b2ac54e6d7","type":"switch","z":"fc65972c8d3b1d68","name":"","property":"payload.result.config.name","propertyType":"msg","rules":[{"t":"eq","v":"on_sched","vt":"str"},{"t":"eq","v":"off_sched","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":530,"y":200,"wires":[["f4f87ffda42b96e4"],["2e4a8af2f7484c01"]]},{"id":"f4f87ffda42b96e4","type":"debug","z":"fc65972c8d3b1d68","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload.result.status.nextDateTZ","targetType":"msg","statusVal":"payload","statusType":"auto","x":790,"y":200,"wires":[]},{"id":"2e4a8af2f7484c01","type":"debug","z":"fc65972c8d3b1d68","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload.result.status.nextDateTZ","targetType":"msg","statusVal":"payload","statusType":"auto","x":790,"y":260,"wires":[]},{"id":"95f8f4acc6461ba2","type":"debug","z":"fc65972c8d3b1d68","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":550,"y":140,"wires":[]}]

Yes, but I think that the OP wanted the next scheduled event, not a list of events.
(Like what's displayed in node status).

That is exactly what this does Paul. Look at the time stamps...

There is just more info for more advanced users (e.g. the servers time is included as reference so a user can accurately calculate "how long until the next event in ms" and a friendly description of the schedule etc etc.


But I think perhaps I misunderstood & you actually mean next event out of ALL schedules right?

In which case...

[{"id":"0cadc70ad80bc89c","type":"cronplus","z":"fc65972c8d3b1d68","name":"","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"fanOut","outputs":4,"options":[{"name":"on_sched","topic":"on","payloadType":"json","payload":"{\"state\": \"on\"}","expressionType":"cron","expression":"0 0 7 * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"off_sched","topic":"off","payloadType":"json","payload":"{\"state\": \"off\"}","expressionType":"cron","expression":"0 0 8 * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":540,"y":180,"wires":[[],[],[],["95f8f4acc6461ba2","b4f1ebad07b0e870"]]},{"id":"5254c9e3da09bdce","type":"inject","z":"fc65972c8d3b1d68","name":"get status","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"status-all","x":380,"y":180,"wires":[["0cadc70ad80bc89c"]]},{"id":"95f8f4acc6461ba2","type":"debug","z":"fc65972c8d3b1d68","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":770,"y":140,"wires":[]},{"id":"b4f1ebad07b0e870","type":"function","z":"fc65972c8d3b1d68","name":"Select next","func":"\nconst next = msg.payload.result.reduce((a, b) => a.status.nextDate < b.status.nextDate ? a : b)\nmsg.payload = {\n    name: next.config.name,\n    topic: next.config.topic,\n    next: next.status.nextDate,\n    nextLocal: next.status.nextDateTZ,\n    timeZone: next.status.serverTimeZone,\n    when: next.status.description,\n    msUntil: next.status.nextDate.valueOf() - next.status.serverTime.valueOf(),\n    description: next.status.nextDescription,\n}\n\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":790,"y":200,"wires":[["32df337f09c22d4e"]]},{"id":"32df337f09c22d4e","type":"debug","z":"fc65972c8d3b1d68","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload.nextLocal","statusType":"msg","x":970,"y":200,"wires":[]}]
2 Likes

Hi Steve,

Thanks for your help. The result is currently looking like this. Is there a way to change the way the date and time are displayed?

Screenshot 2022-08-09 170337

Of course. there are many ways a date and time can be displayed. You will have to provide the format before anyone can give you an answer though

e.g.

  • YY/MM/DD HH:mm:ss
  • YYYY-MM-DD HH:mm:ss.zzz
  • YYYY, DD MMM hh:mm a
  • DD MMM hh:mm:ss a
  • and so on
1 Like

Yes, insert a change node after Steve's function node (above), and use 'moment to change it to whatever format that you want. (Change the timezone to your own).

$moment(msg.payload.next).tz("Europe/London").format('lll')

tz

Result;

tz1

See https://momentjs.com/ for more formatting examples

NOTE - ensure that you select jasonata in the change node - J:

2 Likes

Thanks @Paul-Reed and @Steve-Mcl for your help! I have added the final version of the flow which includes a couple of nodes to switch on and off a device. However, after switching on and off the device based on the settings of the timer, the input_text sensor is not updating.

It looks like the input_text entity is only updated after using the Inject Node. Any ideas how to solve this?

[{"id":"30e9e18e08e63fd3","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"5b910241fcc70820","type":"cronplus","z":"30e9e18e08e63fd3","name":"","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"fanOut","outputs":4,"options":[{"name":"on_sched","topic":"on","payloadType":"json","payload":"{\"state\": \"on\"}","expressionType":"cron","expression":"0 8 23 ? * TUE *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"off_sched","topic":"off","payloadType":"json","payload":"{\"state\": \"off\"}","expressionType":"cron","expression":"0 10 23 ? * TUE *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":180,"y":240,"wires":[["8f9f537a4c75e40d"],["e9da367b335dbe12"],[],["106cbe4819f840f1"]]},{"id":"f5b9f782d0da3ad9","type":"inject","z":"30e9e18e08e63fd3","name":"get status","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"status-all","x":180,"y":380,"wires":[["5b910241fcc70820"]]},{"id":"106cbe4819f840f1","type":"function","z":"30e9e18e08e63fd3","name":"Select next","func":"\nconst next = msg.payload.result.reduce((a, b) => a.status.nextDate < b.status.nextDate ? a : b)\nmsg.payload = {\n    name: next.config.name,\n    topic: next.config.topic,\n    next: next.status.nextDate,\n    nextLocal: next.status.nextDateTZ,\n    timeZone: next.status.serverTimeZone,\n    when: next.status.description,\n    msUntil: next.status.nextDate.valueOf() - next.status.serverTime.valueOf(),\n    description: next.status.nextDescription,\n}\n\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":350,"y":300,"wires":[["5bca6964d1a2a3a5"]]},{"id":"0a75e7b008ae1c95","type":"api-call-service","z":"30e9e18e08e63fd3","name":"Date & Time","server":"ab0c7805.ea8858","version":5,"debugenabled":false,"domain":"input_text","service":"set_value","areaId":[],"deviceId":[],"entityId":["input_text.tuin_beregening_datum_tijd_volgende_run"],"data":"{\"value\":\"{{payload}}\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","output_location":"","output_location_type":"none","x":690,"y":300,"wires":[[]]},{"id":"5bca6964d1a2a3a5","type":"change","z":"30e9e18e08e63fd3","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$moment(msg.payload.next).lang(\"nl\").tz(\"Europe/Amsterdam\").format('lll')","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":300,"wires":[["0a75e7b008ae1c95"]]},{"id":"21f1db9f6ca0572e","type":"api-call-service","z":"30e9e18e08e63fd3","name":"Pomp: Uit","server":"9d8c9ade.d8af7","version":5,"debugenabled":false,"domain":"homeassistant","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.tuin_verlichting"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","output_location":"","output_location_type":"none","x":620,"y":220,"wires":[[]]},{"id":"b45fe18073ee5efd","type":"api-call-service","z":"30e9e18e08e63fd3","name":"Pomp: Aan","server":"9d8c9ade.d8af7","version":5,"debugenabled":false,"domain":"homeassistant","service":"turn_on","areaId":[],"deviceId":[],"entityId":["switch.tuin_verlichting"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","output_location":"","output_location_type":"none","x":630,"y":140,"wires":[[]]},{"id":"8f9f537a4c75e40d","type":"api-current-state","z":"30e9e18e08e63fd3","name":"Automatische beregening: Aan?","server":"ab0c7805.ea8858","version":3,"outputs":2,"halt_if":"Aan (ma, wo, vr, 07:00-08:00)","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_select.tuin_beregening_automatisch","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":410,"y":140,"wires":[["b45fe18073ee5efd"],[]]},{"id":"e9da367b335dbe12","type":"api-current-state","z":"30e9e18e08e63fd3","name":"Automatische beregening: Aan?","server":"ab0c7805.ea8858","version":3,"outputs":2,"halt_if":"Aan (ma, wo, vr, 07:00-08:00)","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_select.tuin_beregening_automatisch","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":410,"y":220,"wires":[["21f1db9f6ca0572e"],[]]},{"id":"ab0c7805.ea8858","type":"server","name":"Home Assistant","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m"},{"id":"9d8c9ade.d8af7","type":"server","name":"Home Assistant","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m"}]

It looks as though your flow includes Home Assistant, which I don't use, so can't try your flow without installing & configuring HA (which I don't want to do :wink:)
Hopefully a HA user may be able to assist further.

1 Like

Let me try and look at it a little bit later today as i do have HA and all the HA nodes installed

Craig

2 Likes

OK so looking at your flow - if you use the nodes to turn on or off - then your function node is not run at that point - as you have it coming from a different starting point on the CronPlus node - so it will not be fired until the next run through (or a trigger node is fired again)

The simplest way would probably be to put a change_state node that would feed into the cronplus node and act a trigger for it to update its status

You would have to check in developer tools what the state changes look like in HA from your nodes and if there are multiple entities you would need multiple change state nodes

Craig

1 Like

Mission completed! All issues have been solved! Thanks for your help!

At the end I was able to change the output of the node which switches off the device and sent that message back to the cron plus node. The final version of the flow looks like this:

The end result in Home Assistant look like this:

[{"id":"30e9e18e08e63fd3","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"5b910241fcc70820","type":"cronplus","z":"30e9e18e08e63fd3","name":"","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"fanOut","outputs":4,"options":[{"name":"on_sched","topic":"on","payloadType":"json","payload":"{\"state\": \"on\"}","expressionType":"cron","expression":"0 30 14 ? * WED *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"off_sched","topic":"off","payloadType":"json","payload":"{\"state\": \"off\"}","expressionType":"cron","expression":"0 30 14 ? * WED *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":180,"y":240,"wires":[["8f9f537a4c75e40d"],["e9da367b335dbe12"],[],["fa5b15823dd7afe6"]]},{"id":"106cbe4819f840f1","type":"function","z":"30e9e18e08e63fd3","name":"Date Next Run","func":"\nconst next = msg.payload.result.reduce((a, b) => a.status.nextDate < b.status.nextDate ? a : b)\nmsg.payload = {\n    name: next.config.name,\n    topic: next.config.topic,\n    next: next.status.nextDate,\n    nextLocal: next.status.nextDateTZ,\n    timeZone: next.status.serverTimeZone,\n    when: next.status.description,\n    msUntil: next.status.nextDate.valueOf() - next.status.serverTime.valueOf(),\n    description: next.status.nextDescription,\n}\n\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":320,"wires":[["5bca6964d1a2a3a5"]]},{"id":"0a75e7b008ae1c95","type":"api-call-service","z":"30e9e18e08e63fd3","name":"Date & Time","server":"ab0c7805.ea8858","version":5,"debugenabled":false,"domain":"input_text","service":"set_value","areaId":[],"deviceId":[],"entityId":["input_text.tuin_beregening_datum_tijd_volgende_run"],"data":"{\"value\":\"{{payload}}\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","output_location":"","output_location_type":"none","x":710,"y":320,"wires":[[]]},{"id":"5bca6964d1a2a3a5","type":"change","z":"30e9e18e08e63fd3","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$moment(msg.payload.next).lang(\"nl\").tz(\"Europe/Amsterdam\").format('lll')","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":320,"wires":[["0a75e7b008ae1c95"]]},{"id":"21f1db9f6ca0572e","type":"api-call-service","z":"30e9e18e08e63fd3","name":"Pomp: Uit","server":"9d8c9ade.d8af7","version":5,"debugenabled":false,"domain":"homeassistant","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.tuin_verlichting"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"topic","propertyType":"msg","value":"status-all","valueType":"str"}],"queue":"none","output_location":"","output_location_type":"none","x":640,"y":240,"wires":[["5b910241fcc70820"]]},{"id":"b45fe18073ee5efd","type":"api-call-service","z":"30e9e18e08e63fd3","name":"Pomp: Aan","server":"9d8c9ade.d8af7","version":5,"debugenabled":false,"domain":"homeassistant","service":"turn_on","areaId":[],"deviceId":[],"entityId":["switch.tuin_verlichting"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","output_location":"","output_location_type":"none","x":630,"y":160,"wires":[[]]},{"id":"8f9f537a4c75e40d","type":"api-current-state","z":"30e9e18e08e63fd3","name":"Automatische beregening: Aan?","server":"ab0c7805.ea8858","version":3,"outputs":2,"halt_if":"Aan (ma, wo, vr, 07:00-08:00)","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_select.tuin_beregening_automatisch","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":410,"y":160,"wires":[["b45fe18073ee5efd"],[]]},{"id":"e9da367b335dbe12","type":"api-current-state","z":"30e9e18e08e63fd3","name":"Automatische beregening: Aan?","server":"ab0c7805.ea8858","version":3,"outputs":2,"halt_if":"Aan (ma, wo, vr, 07:00-08:00)","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_select.tuin_beregening_automatisch","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":410,"y":240,"wires":[["21f1db9f6ca0572e"],[]]},{"id":"e6e8680f76376f6b","type":"api-call-service","z":"30e9e18e08e63fd3","name":"Date & Time","server":"ab0c7805.ea8858","version":5,"debugenabled":false,"domain":"input_text","service":"set_value","areaId":[],"deviceId":[],"entityId":["input_text.tuin_beregening_datum_tijd_laatste_run"],"data":"{\"value\":\"{{payload}}\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","output_location":"","output_location_type":"none","x":390,"y":440,"wires":[[]]},{"id":"fa5b15823dd7afe6","type":"function","z":"30e9e18e08e63fd3","name":"","func":"var now = new Date().toLocaleString(\"nl\", { year: 'numeric', month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit', hour12: false });\nreturn { payload: now };\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":235,"y":440,"wires":[["8c3fb5f13903a5cc"]],"l":false},{"id":"8c3fb5f13903a5cc","type":"change","z":"30e9e18e08e63fd3","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$moment(msg.payload.next).lang(\"nl\").tz(\"Europe/Amsterdam\").format('lll')","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":380,"wires":[["e6e8680f76376f6b"]]},{"id":"a2adb87ef24caa47","type":"comment","z":"30e9e18e08e63fd3","name":"Option 3","info":"","x":320,"y":520,"wires":[]},{"id":"ab0c7805.ea8858","type":"server","name":"Home Assistant","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m"},{"id":"9d8c9ade.d8af7","type":"server","name":"Home Assistant","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m"}]
2 Likes

So at the end, it was not a Bigtimer challenge (that was simpler to solve), instead it developed into a cron+ challenge with a complex result, so better change the heading/topic of the first post

I'm not certain that is true? The OP wanted the time of the next event (not the description of when it would occur)

But, you are correct in that if the OP simply wanted the status from bigtimer, the status node was the way to go.

FWIW, I believe BigTimer is no longer actively developed and there is no link to the src - maybe pointing the OP to a different tool was worth it in the end.

IMO - leave the title as is, then anyone searching for "how to do something off-piste with BigTimer" can find there are solutions where BigTimer doesnt fit?

2 Likes

Yes, you are right!
Best regards, Walter

1 Like