Stop Switch Passing through Data

I've had this working for years but something has changed with a recent update where my dimming buttons no longer dim lights.

When I press a button I pass the button action through to a "switch" which then routes based on the input. This works fine based on the button press type present in "payload.action".

The problem is "payload.action" is then passed through to the next node "api-call-service" which says it doesn't understand the payload.action and throws this error

"InputError: Invalid action format: brightness_down_click"

This is the data passed through from switch

{"topic":"zigbee2mqtt/bedroom_buttons","payload":{"action":"brightness_down_click","battery":20,"last_seen":"2024-09-08T09:14:48+10:00","linkquality":25,"update":{"installed_version":604241925,"latest_version":604241925,"state":"idle"},"update_available":null},"qos":0,"retain":false,"_msgid":"839ebdb5c100c484"}

How can I stop the switch from passing this data through?

[
    {
        "id": "ad08df176725d5c3",
        "type": "mqtt in",
        "z": "898fbae0f3586e7c",
        "name": "",
        "topic": "zigbee2mqtt/bedroom_buttons",
        "qos": "2",
        "datatype": "json",
        "broker": "cc06606981aaf0a9",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 220,
        "y": 760,
        "wires": [
            [
                "16ad3d0d74c5983c"
            ]
        ]
    },
    {
        "id": "16ad3d0d74c5983c",
        "type": "switch",
        "z": "898fbae0f3586e7c",
        "name": "",
        "property": "payload.action",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "toggle",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "brightness_up_click",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "brightness_down_click",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "arrow_left_hold",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "arrow_right_hold",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 5,
        "x": 510,
        "y": 760,
        "wires": [
            [
                "c4f6b5696c253458",
                "3d3fcde6213ad06b"
            ],
            [
                "d27251e8c55c2df7"
            ],
            [
                "bcc45c48056685ed",
                "954d1934afefda3f"
            ],
            [],
            []
        ]
    },
    {
        "id": "c4f6b5696c253458",
        "type": "api-call-service",
        "z": "898fbae0f3586e7c",
        "name": "All Bedroom Toggle",
        "server": "33d171f4d54f205e",
        "version": 6,
        "debugenabled": true,
        "action": "light.toggle",
        "floorId": [],
        "areaId": [
            "bedroom"
        ],
        "deviceId": [],
        "entityId": [],
        "labelId": [],
        "data": "",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "domain": "light",
        "service": "toggle",
        "x": 670,
        "y": 640,
        "wires": [
            []
        ]
    },
    {
        "id": "d27251e8c55c2df7",
        "type": "api-call-service",
        "z": "898fbae0f3586e7c",
        "name": "Lights Brighter",
        "server": "33d171f4d54f205e",
        "version": 6,
        "debugenabled": false,
        "action": "light.turn_on",
        "floorId": [],
        "areaId": [
            "bedroom"
        ],
        "deviceId": [],
        "entityId": [],
        "labelId": [],
        "data": "{\"brightness_step_pct\":5,\"transition\":2}",
        "dataType": "json",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "domain": "light",
        "service": "turn_on",
        "x": 720,
        "y": 740,
        "wires": [
            []
        ]
    },
    {
        "id": "bcc45c48056685ed",
        "type": "api-call-service",
        "z": "898fbae0f3586e7c",
        "name": "Lights Dimmer",
        "server": "33d171f4d54f205e",
        "version": 6,
        "debugenabled": true,
        "action": "homeassistant.turn_on",
        "floorId": [],
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "light.bedroom_all"
        ],
        "labelId": [],
        "data": "",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "{\"brightness_step_pct\":10}",
                "valueType": "jsonata"
            }
        ],
        "queue": "none",
        "domain": "homeassistant",
        "service": "turn_on",
        "x": 740,
        "y": 820,
        "wires": [
            []
        ]
    },
    {
        "id": "cc06606981aaf0a9",
        "type": "mqtt-broker",
        "name": "Stafford MQTT",
        "broker": "192.168.64.64",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "sessionExpiry": ""
    },
    {
        "id": "33d171f4d54f205e",
        "type": "server",
        "name": "Home Assistant",
        "version": 5,
        "addon": false,
        "rejectUnauthorizedCerts": false,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true,
        "heartbeat": true,
        "heartbeatInterval": "30",
        "areaSelector": "friendlyName",
        "deviceSelector": "friendlyName",
        "entitySelector": "friendlyName",
        "statusSeparator": "at: ",
        "statusYear": "hidden",
        "statusMonth": "short",
        "statusDay": "numeric",
        "statusHourCycle": "h23",
        "statusTimeFormat": "h:m",
        "enableGlobalContextStore": true
    }
]

It seems that the api-call-service node knows about msg.payload.action, it just does not recognise the particular value brightness_down_click.

So what do you want to send to api_call_service instead?

Generally speaking, the change node is the right way to manipulate the message contents.

Correct that's what I suspected too. This is the flow that used to work before a recent update.

Either the behaviour of switch or api-call-service has changed.

Ideally I'd like api-service-call to ignore whatever was passed to it and just perform the action I configured it to do on the node itself. The other option is if I can tell the switch to not pass through the payload.action that it used to determine which path to trigger.

I'm hoping to avoid putting another node between these to manipulate/neuter the payload passed from switch as that will really make all my flows overly complicated.

Edit: Note the "Current state" node on the right hand side with two paths to turn on/off the lights. I just added that today to "fix" the previous working "All Bedroom Toggle" which is also failing now due to the payload.action being passed with an invalid action from the switch statement. So it went from requiring only one node to 3x nodes now.

Um....

This has caught me a lot of times.

If it is a MQTT message, you need to look at the msg.payload

So what you may think is msg.brightness_down_click is ACTUALLY msg.payload.brightness_down_click

But I am not sure I am reading the problem correctly.

(Got the flu' and it is not easy to think.)

Or perhaps something has changed in whatever publishes to MQTT.

That seems to me eccentric. Isn't it possible to get rid of some of the api_call_service nodes, perhaps leaving only one, and control it's action using the data published to MQTT?
That would eliminate the switch and leave just the mqtt-in and one api_call_service nodes.

I don't use Home Assistant though so I don't know how it works to control lights.

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