The Call Service node, Data UI field, requires a JSON object.
This object will contain required and optional parameters, each identified by a key/value pair. The parameters are very integration dependent, so the integration documentation will tell you just what is required.
If you want ‘percentage’ then your final data object needs to end up like
{"percentage" : 51}
. The integration docs should tell you if the value is a number or a string, so it could be {"percentage" : "51"}
To pass variable values to this data structure, you can use mustache templates, but they don’t work at all well inside structures as the {{
is confused with the JSON object constructor. Ideally you should use JSONata (the J: option) to build your Data field object.
To build a JSON data object using JSONata is very simple.
{"percentage": payload }
is probably all you need (but use the J: option).
If your end integration is expecting a number and not a string, and your msg.payload is a string (of a valid number) then at bit more work is required.
{"percentage": $number(payload) }
should do the trick, but do experiment first. I think your flow is passing a number, so just
{"percentage": payload}
The best way to sort this out is to use the Home Assistant Developer Tools > Services option. This allows you to set up a service call, to fully test that it works, and then switch from the UI mode to the YAML code mode, and you will see the full data object that the underlying API service call requires. In the WebSocket node, the bit you are interested in is the ‘data’ object field (as a sub-level object). Whatever this is can be converted from the YAML to JSON and used as a template in the node.
You can find extensive documentation on all of this at
https://zachowj.github.io/node-red-contrib-home-assistant-websocket/cookbook/jsonata/call-service.html
Hope this helps!