W_Led mit ESP8266

Hello

I would like to control a WLED via an ESP8266 with a color picker.
Unfortunately I can't get any further, a string comes out of the color picker.
grafik
I shortened it to the bare essentials and added the 4th digit.
grafik
But I need an array in this format.

grafik
grafik

How do I get there. Can someone help me with this????
translated with googlel

[
    {
        "id": "9ab0ef5f789c0c44",
        "type": "http request",
        "z": "363f2541d69f348e",
        "name": "POST to WLED",
        "method": "POST",
        "ret": "obj",
        "paytoqs": "query",
        "url": "http://192.168.1.85/json/state",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "",
        "x": 1220,
        "y": 1880,
        "wires": [
            []
        ]
    },
    {
        "id": "56adea9a670c5309",
        "type": "function",
        "z": "363f2541d69f348e",
        "name": "on: Farbe",
        "func": "var bri = flow.get(\"bri\")\nvar color = flow.get(\"colorDinett\")\n\n\n\nmsg.payload = {\n    \"on\":true,\n    \"bri\": bri ,\n    \"seg\": [{\n      \"start\": 0,\n      \"stop\": 150,\n      \"len\": 150,\n      \"col\": color,\n      \"fx\": 0,\n      \"sx\": 127,\n      \"ix\": 255,\n      \"pal\": 0,\n      \"sel\": true,\n      \"rev\": false,\n      \"cln\": -1\n    }]\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 680,
        "y": 1880,
        "wires": [
            [
                "71a44fd542c86c70",
                "9ab0ef5f789c0c44"
            ]
        ]
    },
    {
        "id": "5cf8a3668641ba76",
        "type": "ui_colour_picker",
        "z": "363f2541d69f348e",
        "name": "Farbe Dinett",
        "label": "Farbe Dinett",
        "group": "b8db3199.f0dbe",
        "format": "rgb",
        "outformat": "string",
        "showSwatch": true,
        "showPicker": false,
        "showValue": false,
        "showHue": false,
        "showAlpha": false,
        "showLightness": true,
        "square": "false",
        "dynOutput": "false",
        "order": 1,
        "width": 0,
        "height": 0,
        "passthru": true,
        "topic": "topic",
        "topicType": "msg",
        "className": "",
        "x": 250,
        "y": 1840,
        "wires": [
            [
                "a27dba35f49416cc",
                "b5d0d0d7836ad245"
            ]
        ]
    },
    {
        "id": "7f11720b8b5e6e11",
        "type": "debug",
        "z": "363f2541d69f348e",
        "name": "Farbe",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 950,
        "y": 1840,
        "wires": []
    },
    {
        "id": "a27dba35f49416cc",
        "type": "change",
        "z": "363f2541d69f348e",
        "name": "",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "rgb",
                "fromt": "str",
                "to": "",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "(",
                "fromt": "str",
                "to": "",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": ")",
                "fromt": "str",
                "to": ",0",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "\"",
                "fromt": "str",
                "to": "",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 450,
        "y": 1840,
        "wires": [
            [
                "ca23b5eea0058ea4",
                "56adea9a670c5309",
                "7f11720b8b5e6e11",
                "f948ed40288da3b0"
            ]
        ]
    },
    {
        "id": "46a4fa682f27a190",
        "type": "ui_slider",
        "z": "363f2541d69f348e",
        "name": "",
        "label": "Helligkeit Dinett",
        "tooltip": "",
        "group": "b8db3199.f0dbe",
        "order": 2,
        "width": 0,
        "height": 0,
        "passthru": true,
        "outs": "all",
        "topic": "topic",
        "topicType": "msg",
        "min": "10",
        "max": "255",
        "step": "10",
        "className": "",
        "x": 260,
        "y": 1880,
        "wires": [
            [
                "7b543a51a49d3b75"
            ]
        ]
    },
    {
        "id": "71a44fd542c86c70",
        "type": "debug",
        "z": "363f2541d69f348e",
        "name": "Farbe",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 830,
        "y": 1880,
        "wires": []
    },
    {
        "id": "7b543a51a49d3b75",
        "type": "function",
        "z": "363f2541d69f348e",
        "name": "Dimmer",
        "func": "var bri = msg.paylod\nflow.set(\"bri\",msg.payload)\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 500,
        "y": 1880,
        "wires": [
            [
                "56adea9a670c5309"
            ]
        ]
    },
    {
        "id": "ca23b5eea0058ea4",
        "type": "function",
        "z": "363f2541d69f348e",
        "name": "Farbe",
        "func": "var color = msg.paylod\nflow.set(\"colorDinett\",msg.payload)\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 730,
        "y": 1800,
        "wires": [
            []
        ]
    },
    {
        "id": "f948ed40288da3b0",
        "type": "split",
        "z": "363f2541d69f348e",
        "name": "",
        "splt": "\\n",
        "spltType": "str",
        "arraySplt": "4",
        "arraySpltType": "len",
        "stream": false,
        "addname": "",
        "x": 730,
        "y": 2000,
        "wires": [
            [
                "907e6a782b533bdd"
            ]
        ]
    },
    {
        "id": "907e6a782b533bdd",
        "type": "debug",
        "z": "363f2541d69f348e",
        "name": "Farbe",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 890,
        "y": 2000,
        "wires": []
    },
    {
        "id": "b5d0d0d7836ad245",
        "type": "debug",
        "z": "363f2541d69f348e",
        "name": "Farbe",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 470,
        "y": 1780,
        "wires": []
    },
    {
        "id": "b8db3199.f0dbe",
        "type": "ui_group",
        "name": "Info",
        "tab": "c77f413b.09f91",
        "order": 3,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "c77f413b.09f91",
        "type": "ui_tab",
        "name": "Info",
        "icon": "mi-info",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

You could do this for example with a change node and a bit of Jsonata:

[
    {
        "id": "dbc0cd4e2e2b5a4c",
        "type": "tab",
        "label": "Flow 29",
        "disabled": false,
        "info": "",
        "env": [],
        "_mcu": {
            "mcu": false
        }
    },
    {
        "id": "862c6cbe712a19cb",
        "type": "inject",
        "z": "dbc0cd4e2e2b5a4c",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "rgb(219, 137, 36)",
        "payloadType": "str",
        "_mcu": {
            "mcu": false
        },
        "x": 240,
        "y": 220,
        "wires": [
            [
                "5432bfd3934393ba",
                "d62a6719c6539124"
            ]
        ]
    },
    {
        "id": "5432bfd3934393ba",
        "type": "change",
        "z": "dbc0cd4e2e2b5a4c",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "$substring(payload, 4, $length(payload)-5)\t",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "$split(payload, \", \", 4)\t",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "_mcu": {
            "mcu": false
        },
        "x": 440,
        "y": 220,
        "wires": [
            [
                "a29e56fb150c3299"
            ]
        ]
    },
    {
        "id": "a29e56fb150c3299",
        "type": "debug",
        "z": "dbc0cd4e2e2b5a4c",
        "name": "debug 94",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "_mcu": {
            "mcu": false
        },
        "x": 620,
        "y": 220,
        "wires": []
    },
    {
        "id": "d62a6719c6539124",
        "type": "debug",
        "z": "dbc0cd4e2e2b5a4c",
        "name": "debug 95",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "_mcu": {
            "mcu": false
        },
        "x": 420,
        "y": 160,
        "wires": []
    }
]

Just be aware that there're many other ways to achieve the same result.

Another possibility:

A CSV node to convert strings to numbers
Split and join to create an array.

[{"id":"3cb113e7937f12e4","type":"inject","z":"03d21a528957832c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"219,137,36,0","payloadType":"str","x":150,"y":280,"wires":[["e800a7192d403949"]]},{"id":"fbc082df04b9eebd","type":"split","z":"03d21a528957832c","name":"","splt":",","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":410,"y":280,"wires":[["7b245f9e51cf32ad"]]},{"id":"7229d33bdc765ea6","type":"debug","z":"03d21a528957832c","name":"debug 392","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":280,"wires":[]},{"id":"7b245f9e51cf32ad","type":"join","z":"03d21a528957832c","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"4","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":530,"y":280,"wires":[["7229d33bdc765ea6"]]},{"id":"e800a7192d403949","type":"csv","z":"03d21a528957832c","name":"","sep":",","hdrin":"","hdrout":"none","multi":"one","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":290,"y":280,"wires":[["fbc082df04b9eebd"]]}]

Or split and convert to number with one JSONata expression
Example flow

[{"id":"862c6cbe712a19cb","type":"inject","z":"dbc0cd4e2e2b5a4c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"rgb(219, 137, 36)","payloadType":"str","x":240,"y":220,"wires":[["5432bfd3934393ba"]]},{"id":"5432bfd3934393ba","type":"change","z":"dbc0cd4e2e2b5a4c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$split(payload, /\\(|,|\\)/)[[1..3]].$number($trim($))\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":220,"wires":[["a29e56fb150c3299"]]},{"id":"a29e56fb150c3299","type":"debug","z":"dbc0cd4e2e2b5a4c","name":"debug 94","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":620,"y":220,"wires":[]}]

Expression

$split(payload, /\(|,|\)/)[[1..3]].$number($trim($))	

Output

[219,137,36]

[edit] Thinking about it and looking at your flow, you seem to be using context when it is not really needed, maybe this example will help you.

[{"id":"ccc5b5139d249b28","type":"ui_colour_picker","z":"dbc0cd4e2e2b5a4c","name":"Farbe Dinett","label":"Farbe Dinett","group":"40efc08bf376fd16","format":"rgb","outformat":"object","showSwatch":true,"showPicker":false,"showValue":false,"showHue":false,"showAlpha":false,"showLightness":true,"square":"false","dynOutput":"false","order":1,"width":0,"height":0,"passthru":true,"topic":"colour","topicType":"str","className":"","x":70,"y":360,"wires":[["4f63ac2d0aeab560"]]},{"id":"4f63ac2d0aeab560","type":"join","z":"dbc0cd4e2e2b5a4c","name":"","mode":"custom","build":"merged","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"5","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":370,"y":360,"wires":[["93e2510270e3c6d0"]]},{"id":"03ad4b8d7bfda4be","type":"change","z":"dbc0cd4e2e2b5a4c","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.bri","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":400,"wires":[["4f63ac2d0aeab560"]]},{"id":"93e2510270e3c6d0","type":"change","z":"dbc0cd4e2e2b5a4c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t    \"on\":true,\t    \"bri\": $$.payload.bri ,\t    \"seg\": [{\t      \"start\": 0,\t      \"stop\": 150,\t      \"len\": 150,\t      \"col\": [$$.payload.r, $$.payload.g ,$$.payload.b, 0],\t      \"fx\": 0,\t      \"sx\": 127,\t      \"ix\": 255,\t      \"pal\": 0,\t      \"sel\": true,\t      \"rev\": false,\t      \"cln\": -1\t    }]\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":360,"wires":[["960de9c4103819fd","28de185ca11f9ec3"]]},{"id":"cd55787a521e7ff1","type":"ui_slider","z":"dbc0cd4e2e2b5a4c","name":"","label":"Helligkeit Dinett","tooltip":"","group":"40efc08bf376fd16","order":2,"width":0,"height":0,"passthru":true,"outs":"all","topic":"brightness","topicType":"str","min":"10","max":"255","step":"10","className":"","x":80,"y":400,"wires":[["03ad4b8d7bfda4be"]]},{"id":"960de9c4103819fd","type":"debug","z":"dbc0cd4e2e2b5a4c","name":"Farbe","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":670,"y":340,"wires":[]},{"id":"28de185ca11f9ec3","type":"ui_text","z":"dbc0cd4e2e2b5a4c","group":"40efc08bf376fd16","order":2,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload}}","layout":"row-spread","className":"","style":false,"font":"","fontSize":16,"color":"#000000","x":630,"y":480,"wires":[]},{"id":"40efc08bf376fd16","type":"ui_group","name":"Info","tab":"c77f413b.09f91","order":3,"disp":true,"width":"6","collapse":false,"className":""},{"id":"c77f413b.09f91","type":"ui_tab","name":"Info","icon":"mi-info","order":1,"disabled":false,"hidden":false}]
2 Likes

Great thank you
this seems to be the solution.
From the debug output it's OK.
Tonight I'll try that on the WLED controller.
How do you get a CODE like this "$split(payload, /(|,|)/)[[1..3]].$number($trim($))"
madness!!!! :roll_eyes: :wink:
Greeting Arno

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