Help with cronplus node

I'm wanting to add schedules via injections and need to specify more than what I have so far.

As is this is an exert from what the flow is:

[
    {
        "id": "c54780ea787c649c",
        "type": "link out",
        "z": "26262ba1.62dcbc",
        "name": "Start",
        "mode": "link",
        "links": [
            "acc270c1bcd7d96c",
            "6a1a5b0be6b0ddb0"
        ],
        "x": 655,
        "y": 6820,
        "wires": []
    },
    {
        "id": "86d37c82b96d5dbd",
        "type": "change",
        "z": "26262ba1.62dcbc",
        "name": "SET/Start",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "add",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "[{\"command\":\"add\",\"name\":\"Charging when away\",\"expression\":\"0 0 10 * * Wed\",\"payloadType\":\"default\",\"payload\":\"\",\"type\":\"str\"}]",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 520,
        "y": 6820,
        "wires": [
            [
                "c54780ea787c649c"
            ]
        ]
    },
    {
        "id": "6a1a5b0be6b0ddb0",
        "type": "link in",
        "z": "26262ba1.62dcbc",
        "name": "Schedule input",
        "links": [
            "c54780ea787c649c",
            "87b618aa689ab36c"
        ],
        "x": 655,
        "y": 6890,
        "wires": [
            [
                "30db0e7b74e0fa99"
            ]
        ]
    },
    {
        "id": "30db0e7b74e0fa99",
        "type": "cronplus",
        "z": "26262ba1.62dcbc",
        "name": "Away Charger control",
        "outputField": "payload",
        "timeZone": "",
        "storeName": "",
        "commandResponseMsgOutput": "output2",
        "defaultLocation": "",
        "defaultLocationType": "default",
        "outputs": 2,
        "options": [],
        "x": 830,
        "y": 6890,
        "wires": [
            [
                "5b96290ecb9a7a02"
            ],
            [
                "e5eeee3e0ca6ba2b"
            ]
        ]
    }
]

The important part is this in the change node:
[{"command":"add","name":"Charging when away","expression":"0 0 10 * * Wed","payloadType":"default","payload":"","type":"str"}]

I am needing to add more to the output.

I need a topic set too.

Indulge the village idiot and help me with how to set a topic.

This is just the first step of a somewhat complicated flow I'm making.

I won't dump it all on you here, as I think this is all that is needed.

Oh, for now it is set to daily - testing.
But I will need it to trigger weekly rather than daily.
Doesn't matter what day/time.

Thanks in advance.

adding this to the change node json ...

[
    {
        "command": "add",
        "name": "Charging when away",
        "expression": "*/10 * * * * Wed",
        "payloadType": "default",
        "payload": "",
        "type": "str",
        "topic": "I_am_the_topic"
    }
]

.. result in sending this output:

{
	"topic": "I_am_the_topic",
	"scheduledEvent": true,
	"payload": {
		"triggerTimestamp": 1773217940000,
		"status": {
			"type": "dynamic",
			"modified": false,
			"isRunning": true,
			"count": 30,
			"limit": 0,
			"nextDescription": "in 9 seconds",
			"nextDate": "2026-03-11T08:32:30.000Z",
			"nextDateTZ": "11. März 2026, 09:32:30 MEZ",
			"timeZone": "Europe/Berlin",
			"serverTime": "2026-03-11T08:32:20.002Z",
			"serverTimeZone": "Europe/Berlin",
			"description": "Every 10 seconds, only on Wednesday"
		},
		"config": {
			"topic": "I_am_the_topic",
			"name": "Charging when away",
			"index": 0,
			"payloadType": "default",
			"payload": "",
			"limit": null,
			"expressionType": "cron",
			"expression": "*/10 * * * * Wed"
		}
	},
	"_msgid": "eafd5acccea54c0b"
}
1 Like

From the built in help

Adding a CRON expression

  • Multiple schedules can be added if the payload is an array of objects
  • command: (string|required) The operation to perform - in this case "add"
  • name: (string|required) This will identify schedule
  • topic: (string|required) This will be used as the topic when the schedule triggers
  • expression: (string|required) A CRON expression, a date, a comma separated list of dates or an array of dates
  • expressionType: (string|optional) specify the schedule type. (if omitted, "cron" is the default)
  • payloadType: (string|optional) The payload type (e.g. 'default', 'flow', 'global', 'str', 'num', 'bool', 'json', 'bin', 'date' or 'env')
  • payload: (any|optional) What to send when schedule triggers
  • limit: (number|optional) Maximum number of times the schedule should trigger

Set payloadType to "json" and set payload to an object { } and you will "add more to the output" when it fires

e.g.

[ 
  {
    "command":"add",
    "name":"Charging when away",
    "expression":"0 0 10 * *   Wed",
    "payloadType":"json",
    "topic": "The topic to send in the msg",
    "payload": {
      "info": "I am the payload that will be sent in the msg",
      "a_number": 123,
      "a_string": "hello",
      "a_nested_object": {
        "a_boolean": true
      }
    }
  }
]
1 Like

Thanks both.

This code is to control a TASMOTA device via MQTT.

I am sending many schedules (5) from different function nodes.

(Excuse the digression)
ORIGINALLY I had 5 cronplusnodes and the block of code was fairly complicated.

As I am learning more and more I am rationalising the code/flow/nodes to ge better use.

The output is then sent to another function node that tweaks things then sends the message into a trigger node.
That then sends a Pulse output that goes into a switch node that sorts the message on the topic and then to the MQTT OUT`` node. I now think that the switch` node isn't needed.

So there are up to 5 schedules which could be running.

As each is started the posted code is run to start the respective schedule.
Obviously certain things are changed. :wink:

Then when device is offline the schedule is removed.
(That was fun getting that bit working)

I'd post the code but I think that is not really needed - only to show he bigger picture and how I've optimised it.

It seems to be working now.
Again: Thanks.

Ah, just for the fun of it, here is a picture of that part of the code:
And yeah, there is a bit of old code in there.
This code is on my testing machine.