Error call service, home assistant api error. Error Message: Invalid format

I just started with Node RED today. It’s awesome. I have a flow that ALMOST works but I can’t set a input_boolean’s state.

Here is the node that fails:

I can make that same exact call in the dev tools in HA and it works.
I have another node that calls a zwave.set_config_parameter and that works.

I found another thread with a similar error and I did set Output Location to None for the service call node.

Any clues as to why I can’t call input_boolean.turn_off ?

This usually happens because you probably have another service call node before that one so the parameters are passed to the next one. Is that right? Do you have another cs node before ? If so set that node to no output, not the input_boolean one.

1 Like

The previous node is a switch. its output is an object, but none of the properties are named any of, “node_id”, “parameter”, or “value”. I just upgraded to 0.86.1 and its offline for some reason, I’ll get more info about the flow posted when it gets back up and running.

In the meantime, I did test it with a inject node and a fresh new call-service node. This worked. So I connected the injector to my failing node and that failed. When I get a chance, I’ll try putting a node in between the call service and the switch. Maybe a node that sets the parameters for the service…I’ll definitely post up my whole flow later anyway.

My flow looks like this:

[
    {
        "id": "7700f281.36dcac",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "4ca72a5.6412ed4",
        "type": "tail",
        "z": "7700f281.36dcac",
        "name": "ozwlog tail",
        "filetype": "text",
        "split": true,
        "filename": "/config/OZW_Log.txt",
        "x": 80,
        "y": 20,
        "wires": [
            [
                "cf64bab3.f692f8"
            ]
        ]
    },
    {
        "id": "cf64bab3.f692f8",
        "type": "switch",
        "z": "7700f281.36dcac",
        "name": "Only Config Reports",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "regex",
                "v": "Info, Node\\d{3}, Received Configuration report",
                "vt": "str",
                "case": true
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 280,
        "y": 20,
        "wires": [
            [
                "8704eae2.9ca998"
            ]
        ]
    },
    {
        "id": "8704eae2.9ca998",
        "type": "function",
        "z": "7700f281.36dcac",
        "name": "Extract Variables",
        "func": "var regExp =/Info, Node0*(\\d+), Received Configuration report: Parameter=(\\d+), Value=(\\d+)/\nvar results = regExp.exec(msg.payload);\nvar obj =  {data: { nodeId: results[1], parmIndex: results[2], parmValue: results[3]}};\n\nmsg.payload = obj;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 510,
        "y": 20,
        "wires": [
            [
                "c7492ad3.d78348"
            ]
        ]
    },
    {
        "id": "c7492ad3.d78348",
        "type": "switch",
        "z": "7700f281.36dcac",
        "name": "Hold / ESM?",
        "property": "payload.data.parmIndex",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "76",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "77",
                "vt": "str"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 2,
        "x": 110,
        "y": 120,
        "wires": [
            [
                "15645245.205c9e"
            ],
            [
                "d95350c8.ed79b"
            ]
        ]
    },
    {
        "id": "d95350c8.ed79b",
        "type": "switch",
        "z": "7700f281.36dcac",
        "name": "ESM",
        "property": "payload.data.parmValue",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "1",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "0",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 310,
        "y": 160,
        "wires": [
            [],
            []
        ]
    },
    {
        "id": "15645245.205c9e",
        "type": "switch",
        "z": "7700f281.36dcac",
        "name": "Hold/Run",
        "property": "payload.data.parmValue",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "0",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "1",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 320,
        "y": 100,
        "wires": [
            [],
            [
                "1f41e685.8cc809"
            ]
        ],
        "outputLabels": [
            "hold",
            "run"
        ]
    },
    {
        "id": "f83f984c.1a5af8",
        "type": "catch",
        "z": "7700f281.36dcac",
        "name": "",
        "scope": null,
        "x": 700,
        "y": 60,
        "wires": [
            []
        ]
    },
    {
        "id": "1f41e685.8cc809",
        "type": "api-call-service",
        "z": "7700f281.36dcac",
        "name": "",
        "server": "d812fdda.9bbad",
        "service_domain": "input_boolean",
        "service": "turn_off",
        "data": "{\"entity_id\":\"input_boolean.trane_downstairs_hold\"}",
        "render_data": false,
        "mergecontext": "",
        "output_location": "payload",
        "output_location_type": "msg",
        "x": 560,
        "y": 120,
        "wires": [
            []
        ]
    },
    {
        "id": "ccd7f8e7.a2f248",
        "type": "inject",
        "z": "7700f281.36dcac",
        "name": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 320,
        "y": 260,
        "wires": [
            [
                "1f41e685.8cc809"
            ]
        ]
    },
    {
        "id": "d812fdda.9bbad",
        "type": "server",
        "z": "",
        "name": "Home Assistant"
    }
]

Clicking the inject node works, having it run from the flow doesn’t.

Something similar to would’ve happened if you used cs beforem but because you named the object data, and then you nested into the payload

var regExp =/Info, Node0*(\d+), Received Configuration report: Parameter=(\d+), Value=(\d+)/
var results = regExp.exec(msg.payload);
var obj =  {data: { nodeId: results[1], parmIndex: results[2], parmValue: results[3]}};

msg.payload = obj;
return msg;

The returned msg from extract variable has this msg.payload.data structure

Look at the info panel in call service

So the msg from before is overriding the call service data. Just rename data to data1 and that should do it, or don’t put in the payload just msg.datam but you will have to change all switches to match the new msg layout.
Another option just before cs, add a change node and delete the payload

1 Like

Excellent. Thank you! That was it! I had to remove it from both data and payload, so my message is purely the object needed for the switches, no msg.payload at all.

Now I need to do the hard work of making this flow work for a list of devices and associate them with the proper booleans :expressionless:

Thanks again for the help. I’m on my way to wrapping my head around this stuff.