RGB Array in call service

Hi,

I'm trying to send an array with RGB values to call service -> Data.
I use in Data: {"rgb_color":{{payload}}}.
I get: "Call-service API error. Error Message: extra keys not allowed @ data['0']"
If I copy the values of that array straight into the data field it works...
Would somebody know what I'm doing wrong and how to fix it?

Thanks,
Buva

Hi.

You haven't gave a lot to go on.

What nodes are you using?
What is in payload?
What should you be sending (provide a sample data).

Hi,

Here is the code:

[{"id":"2a4d2487.8ff5fc","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"2ce4f9d.110a806","type":"ui_colour_picker","z":"2a4d2487.8ff5fc","name":"","label":"RGB FL1","group":"9bc5e3b7.87534","format":"rgb","outformat":"object","showSwatch":true,"showPicker":true,"showValue":true,"showHue":false,"showAlpha":false,"showLightness":true,"square":"false","dynOutput":"false","order":4,"width":5,"height":4,"passthru":true,"topic":"","x":160,"y":60,"wires":[["9a7c363e.a2d378"]]},{"id":"87b9b146.0f349","type":"function","z":"2a4d2487.8ff5fc","name":"","func":"var text = msg.payload\nvar len = text.length;\nvar cut = len-3\nvar nw = msg.payload.substring(0,cut)\nmsg.payload=nw\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":400,"y":160,"wires":[["604101cb.0d3a1","c7389bcc.e8a318"]]},{"id":"604101cb.0d3a1","type":"function","z":"2a4d2487.8ff5fc","name":"","func":"var ar =msg.payload.split(',').map(ar => parseInt(ar,10));\nmsg.payload=ar\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":400,"y":220,"wires":[["6bcc7318.fd946c","22de8182.428a8e"]]},{"id":"6bcc7318.fd946c","type":"api-call-service","z":"2a4d2487.8ff5fc","name":"LIGHT BED","server":"5215b5bc.f7c15c","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.bed","data":"{\"rgb_color\":{{payload}}}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":410,"y":300,"wires":[["89a03704.d0dfd8"]]},{"id":"89a03704.d0dfd8","type":"debug","z":"2a4d2487.8ff5fc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":610,"y":300,"wires":[]},{"id":"22de8182.428a8e","type":"debug","z":"2a4d2487.8ff5fc","name":"F2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":590,"y":220,"wires":[]},{"id":"c7389bcc.e8a318","type":"debug","z":"2a4d2487.8ff5fc","name":"F1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":590,"y":160,"wires":[]},{"id":"fbc58201.db4c8","type":"debug","z":"2a4d2487.8ff5fc","name":"RGB out","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":600,"y":100,"wires":[]},{"id":"9a7c363e.a2d378","type":"csv","z":"2a4d2487.8ff5fc","name":"","sep":",","hdrin":"","hdrout":"","multi":"one","ret":"\\n","temp":"r,g,b,a","skip":"0","strings":true,"include_empty_strings":false,"include_null_values":false,"x":310,"y":100,"wires":[["87b9b146.0f349","fbc58201.db4c8"]]},{"id":"9bc5e3b7.87534","type":"ui_group","z":"","name":"HOME","tab":"57c688f9.3fc498","order":1,"disp":true,"width":"6","collapse":false},{"id":"5215b5bc.f7c15c","type":"server","z":"","name":"Home Assistant","addon":true},{"id":"57c688f9.3fc498","type":"ui_tab","z":"","name":"RED Home","icon":"RED dashboard","disabled":false,"hidden":false}]

There is no way I am going to (and likely others) import your code, figure out what nodes you have installed & guess your payload & then attempt to figure out the expected format.

If you answer the questions I posted, I will attempt to help.

OK Steve,

This is my first question in any forum whatsoever so bear with me please.

I'm using the Colour picker and I transform the value into an array eg. [ 62, 156, 193 ]
When I try to put this in the data field of a call service with {"rgb_color":{{payload}}}, I get "Call-service API error. Error Message: None for dictionary value @ data['rgb_color']" in the debugger.
I probably just don't know how to put the payload into the Data field of the call service node...

BR,
Burt.

Using the mustache temple does not like arrays and objects, try converting it to a json string "[56,67,147]". Or use the string value from your second debug, then in the api call use {"rgb_color":[{{payload}}]}

On that data input (the one highlighted, if you click the drop-down on the left of it, what options are available? Is there a msg option?

That did the job! Thanks!

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