# Cron json as variables

**URL:** https://discourse.nodered.org/t/cron-json-as-variables/97222
**Category:** General
**Created:** [23 May 2025 07:26 UTC](https://discourse.nodered.org/t/cron-json-as-variables/97222 "2025-05-23T07:26:23Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Herbert](https://avatars.discourse-cdn.com/v4/letter/h/ce73a5/32.png) [@Herbert](https://discourse.nodered.org/u/Herbert)
#### Post date: [23 May 2025 07:26 UTC](https://discourse.nodered.org/t/cron-json-as-variables/97222/1 "2025-05-23T07:26:23Z")

</div>

Hello I´m using some cron with fix values.  
I want to refer to two Dashboard object for both variables toGrid and toSolar to adjust these values easier.

How is that possible?

Cron field:

```auto
{"toGrid":20.3,"toSolar":22.0}

```

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

```auto
[
    {
        "id": "0336f4fd93f378eb",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "421982f94b43cd4a",
        "type": "cronplus",
        "z": "0336f4fd93f378eb",
        "name": "Jede Minute Feb 1. bis 20.",
        "outputField": "payload",
        "timeZone": "",
        "storeName": "",
        "commandResponseMsgOutput": "output1",
        "defaultLocation": "",
        "defaultLocationType": "default",
        "outputs": 1,
        "options": [
            {
                "name": "schedule1",
                "topic": "Minute",
                "payloadType": "json",
                "payload": "{\"toGrid\":20.3,\"toSolar\":22.0}",
                "expressionType": "cron",
                "expression": "0 * * 1-20 FEB *",
                "location": "",
                "offset": "0",
                "solarType": "all",
                "solarEvents": "sunrise,sunset"
            }
        ],
        "x": 460,
        "y": 180,
        "wires": [
            []
        ]
    }
]

```

---

<div class="post-metadata">

### Author: ![Herbert](https://avatars.discourse-cdn.com/v4/letter/h/ce73a5/32.png) [@Herbert](https://discourse.nodered.org/u/Herbert)
#### Post date: [6 June 2025 16:10 UTC](https://discourse.nodered.org/t/cron-json-as-variables/97222/2 "2025-06-06T16:10:57Z")

</div>

No answer here? Is my wish not possible? Maybe there are better solutions as my?

---

<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: [6 June 2025 16:36 UTC](https://discourse.nodered.org/t/cron-json-as-variables/97222/3 "2025-06-06T16:36:52Z")

</div>

cronplus is 100% dynamic. Your dashboard would need to "create dynamic schedules".

Alternatively, you could use a change node to update the values to those created by your dashboard.

e.g. `cron-plus` --\> `change` (update `msg.payload.toGrid`, update `msg.payload.toSolar`) --\> next node

Alternatively, you could use a JSONata payload and dynamically create the payload using `$flowContext` for example!

---

<div class="post-metadata">

### Author: ![Herbert](https://avatars.discourse-cdn.com/v4/letter/h/ce73a5/32.png) [@Herbert](https://discourse.nodered.org/u/Herbert)
#### Post date: [6 June 2025 16:39 UTC](https://discourse.nodered.org/t/cron-json-as-variables/97222/4 "2025-06-06T16:39:27Z")

</div>

Thanks for your feedback. In the meantime I thought it would be better to have a number from an MQTT device. But how I can integrate any number in the cron?

---

<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: [6 June 2025 16:40 UTC](https://discourse.nodered.org/t/cron-json-as-variables/97222/5 "2025-06-06T16:40:12Z")

</div>

store the number in context

retrieve the number from context - use a change node or the other methods mentioned in last post.

---

<div class="post-metadata">

### Author: ![Herbert](https://avatars.discourse-cdn.com/v4/letter/h/ce73a5/32.png) [@Herbert](https://discourse.nodered.org/u/Herbert)
#### Post date: [6 June 2025 16:41 UTC](https://discourse.nodered.org/t/cron-json-as-variables/97222/6 "2025-06-06T16:41:11Z")

</div>

OK thanks I will try that - I´m not an expert, but I do my best 😉

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [6 June 2025 16:43 UTC](https://discourse.nodered.org/t/cron-json-as-variables/97222/7 "2025-06-06T16:43:19Z")

</div>

> [@Herbert](#):
>
> But how I can integrate any number in the cron?

Have Cron-plus inject a simple message at your sheduled times.  
Use a change node, or other means, to insert the current values for msg.payload.toGrid and msg.payload.toSolar.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [4 September 2025 16:43 UTC](https://discourse.nodered.org/t/cron-json-as-variables/97222/8 "2025-09-04T16:43:35Z")

</div>

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