# Trouble inserting dashboard slider value into JSON payload

**URL:** https://discourse.nodered.org/t/trouble-inserting-dashboard-slider-value-into-json-payload/80303
**Category:** General
**Created:** [3 August 2023 20:27 UTC](https://discourse.nodered.org/t/trouble-inserting-dashboard-slider-value-into-json-payload/80303 "2023-08-03T20:27:38Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![richiep](https://avatars.discourse-cdn.com/v4/letter/r/59ef9b/32.png) [@richiep](https://discourse.nodered.org/u/richiep)
#### Post date: [3 August 2023 20:27 UTC](https://discourse.nodered.org/t/trouble-inserting-dashboard-slider-value-into-json-payload/80303/1 "2023-08-03T20:27:38Z")

</div>

Hey All,  
I've got a dashboard slider that sends 0-255 to an esp8266 using JSON. I can do this from an inject mode with the following payload, it works as intended.

```auto
{"modeBrightness" : 50} // renders 50

```

Next I want to send the brightness from a slider on the dashboard. I'm trying to add it to JSON with a change node with the following code.

```auto
{"modeBrightness" : "{{topic}}"} // renders {{topic}}  

{"modeBrightness" : "{{payload}}"} // renders {{payload}}

```

How can I get the slider values into my JSON payload?  
Thx  
Rich

```auto
[
    {
        "id": "6e4a0e1c3f08a293",
        "type": "debug",
        "z": "cf08cb9713ba9cda",
        "name": "debug 341",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 410,
        "y": 220,
        "wires": []
    },
    {
        "id": "49ed4223b39cd05d",
        "type": "change",
        "z": "cf08cb9713ba9cda",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"modeBrightness\" : \"{{topic}}\"}",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 240,
        "y": 80,
        "wires": [
            [
                "6e4a0e1c3f08a293",
                "902ba5af9d02cea1"
            ]
        ]
    },
    {
        "id": "f77c465a8c64faee",
        "type": "ui_slider",
        "z": "cf08cb9713ba9cda",
        "name": "",
        "label": "brightness",
        "tooltip": "",
        "group": "65963440961b63cc",
        "order": 6,
        "width": 0,
        "height": 0,
        "passthru": true,
        "outs": "end",
        "topic": "topic",
        "topicType": "msg",
        "min": "0",
        "max": "255",
        "step": 1,
        "className": "",
        "x": 70,
        "y": 80,
        "wires": [
            [
                "49ed4223b39cd05d"
            ]
        ]
    },
    {
        "id": "65963440961b63cc",
        "type": "ui_group",
        "name": "HANGING LAMP",
        "tab": "f3a8a67ff0904e39",
        "order": 3,
        "disp": true,
        "width": "6",
        "collapse": true,
        "className": ""
    },
    {
        "id": "f3a8a67ff0904e39",
        "type": "ui_tab",
        "name": "HOME",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

```

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [3 August 2023 21:09 UTC](https://discourse.nodered.org/t/trouble-inserting-dashboard-slider-value-into-json-payload/80303/2 "2023-08-03T21:09:14Z")

</div>

In the change node select JSONata `J:` not `json`, you can use

```auto
{"modeBrightness" : $$.payload} 

```

Or use a template node, set to output js object, and you what you had minus the quotes.

```auto
{"modeBrightness" : {{payload}}} 

```

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [4 August 2023 07:47 UTC](https://discourse.nodered.org/t/trouble-inserting-dashboard-slider-value-into-json-payload/80303/3 "2023-08-04T07:47:10Z")

</div>

Or you can do it like this

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

You can't set msg.payload.modeBrightness directly as it is currently a number, so you can't add a property to it. msg.temp does not exist so the change node allows you to create it as an object, then move it into the payload.

---

<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: [18 August 2023 07:48 UTC](https://discourse.nodered.org/t/trouble-inserting-dashboard-slider-value-into-json-payload/80303/4 "2023-08-18T07:48:12Z")

</div>

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