How do I use NR to work with a MQTT device trigger?

Apparently v2.0 of Zigbee2MQTT disables HA from recieving the ACTION entity of a button (which I dont understand why as thats the main point of a button. Now I all get is a battery entity).

Anyway, the new recommended “solution” is to use MQTT device triggers. They show an example here. What would I use in NR to accomplish the trigger portion of this?

There are new event entities that replace the button press action.

But is that only with the experimental path (which may break)? Because I did that and now yes, I do see a event for that button. But what if that experiment breaks and I need to go to the recommended way.

It was experimental prior to 2.0, it was added permanently to z2m 2.0. You should have the new entities under the mqtt integration.

So I shouldent take take the wording of this feature to be true then? Its not experimental anymore?

It’s an “experiment” as far as the Z2M team considers its current implementation of it. As far as the HA team is concerned, the event entity is here to stay and represents one of two ways to model a remote-control’s button.


See my reply to your same concerns in the other topic regarding how Z2M’s implementation of it may change.

Yeah I saw but didnt know if your speculation meant I would probably need to go to the recommend way as described in the Z2M 2.0 release notes (my original post here using device id, etc).

I’ll just stick with how I have it now and hope i dont have to change anything else.

I believe the suggestion to use MQTT Device Trigger is directed to users of Home Assistant’s native automations (not Node-Red users).


FWIW, you can also have Node-Red subscribe to the topic representing the button events. You eliminate the middleman (Home Assistant) and get the events directly from Z2M.

1 Like

The device node is used to replicate device trigger automations from Home Assistant.

1 Like

I had no time to answer promptly, but I recently made use of it (while I’m still in pre-2025 version). It’s pretty straightforward

Here are screenshots (See this pink node)

Any ideas on easiest way to change my WAIT UNTIL node? Previously I would have it wait until the button entity state is “double”. But now that the button entity is replaced with an event, how can I have the WAIT UNTIL node watch msg.data.new_state.attributes.event_type
??

[
    {
        "id": "4ed6cf89bce2e5ff",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "b4e8b6cb9ecffcc6",
        "type": "server-state-changed",
        "z": "4ed6cf89bce2e5ff",
        "name": "Button pressed",
        "server": "ab3e2c53.e3491",
        "version": 6,
        "outputs": 1,
        "exposeAsEntityConfig": "",
        "entities": {
            "entity": [
                "event.button_hvac_filter"
            ],
            "substring": [],
            "regex": []
        },
        "outputInitially": false,
        "stateType": "str",
        "ifState": "",
        "ifStateType": "str",
        "ifStateOperator": "is",
        "outputOnlyOnStateChange": true,
        "for": "0",
        "forType": "num",
        "forUnits": "minutes",
        "ignorePrevStateNull": false,
        "ignorePrevStateUnknown": false,
        "ignorePrevStateUnavailable": false,
        "ignoreCurrentStateUnknown": false,
        "ignoreCurrentStateUnavailable": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "eventData"
            },
            {
                "property": "topic",
                "propertyType": "msg",
                "value": "",
                "valueType": "triggerId"
            }
        ],
        "x": 140,
        "y": 300,
        "wires": [
            [
                "9392d25a8c04f7d8"
            ]
        ]
    },
    {
        "id": "9392d25a8c04f7d8",
        "type": "switch",
        "z": "4ed6cf89bce2e5ff",
        "name": "Number of taps",
        "property": "data.new_state.attributes.event_type",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "single",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "double",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "triple",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "quadruple",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "many",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "hold",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 6,
        "x": 355,
        "y": 300,
        "wires": [
            [
                "dfa84b7c4df72a3d",
                "aaadfaab1f43cd01"
            ],
            [],
            [],
            [],
            [],
            []
        ]
    },
    {
        "id": "aaadfaab1f43cd01",
        "type": "alexa-remote-routine",
        "z": "4ed6cf89bce2e5ff",
        "name": "Speak: Press button 2x",
        "account": "f0ce5fbc.18734",
        "routineNode": {
            "type": "speakAtVolume",
            "payload": {
                "type": "regular",
                "text": {
                    "type": "str",
                    "value": "Press button two times to confirm filter change. You have 15 seconds."
                },
                "volume": {
                    "type": "num",
                    "value": "60"
                },
                "mode": "set",
                "devices": [
                    "G6G0XG1212520DA7"
                ]
            }
        },
        "x": 610,
        "y": 270,
        "wires": [
            []
        ]
    },
    {
        "id": "dfa84b7c4df72a3d",
        "type": "ha-wait-until",
        "z": "4ed6cf89bce2e5ff",
        "name": "",
        "server": "ab3e2c53.e3491",
        "version": 3,
        "outputs": 2,
        "entities": {
            "entity": [
                "sensor.button_hvac_filter"
            ],
            "substring": [],
            "regex": []
        },
        "property": "state",
        "comparator": "is",
        "value": "double",
        "valueType": "str",
        "timeout": "20",
        "timeoutType": "num",
        "timeoutUnits": "seconds",
        "checkCurrentState": true,
        "blockInputOverrides": true,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "date"
            },
            {
                "property": "reset",
                "propertyType": "msg",
                "value": "",
                "valueType": "str"
            }
        ],
        "entityLocation": "data",
        "entityLocationType": "none",
        "x": 560,
        "y": 330,
        "wires": [
            [
                "b457c521fc087442",
                "6950666d41645b66"
            ],
            [
                "6e7ecb238c46b213"
            ]
        ]
    },
    {
        "id": "b457c521fc087442",
        "type": "moment",
        "z": "4ed6cf89bce2e5ff",
        "name": "add 30 days",
        "topic": "",
        "input": "payload",
        "inputType": "msg",
        "inTz": "ETC/UTC",
        "adjAmount": "30",
        "adjType": "days",
        "adjDir": "add",
        "format": "YYYY-MM-DD HH:mm:ss",
        "locale": "En",
        "output": "payload",
        "outputType": "msg",
        "outTz": "America/Chicago",
        "x": 770,
        "y": 330,
        "wires": [
            [
                "ae52754ffbca445d"
            ]
        ]
    },
    {
        "id": "ae52754ffbca445d",
        "type": "api-call-service",
        "z": "4ed6cf89bce2e5ff",
        "name": "Set filter due date time",
        "server": "ab3e2c53.e3491",
        "version": 7,
        "debugenabled": false,
        "action": "input_datetime.set_datetime",
        "floorId": [],
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "input_datetime.hvac_filter_change_due_date",
            "input_datetime.hvac_filter_change_due_date_nag"
        ],
        "labelId": [],
        "data": "{\"datetime\": payload }",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "blockInputOverrides": false,
        "domain": "input_datetime",
        "service": "set_datetime",
        "x": 965,
        "y": 330,
        "wires": [
            []
        ]
    },
    {
        "id": "6950666d41645b66",
        "type": "alexa-remote-routine",
        "z": "4ed6cf89bce2e5ff",
        "name": "Speak: Filter change date updated",
        "account": "f0ce5fbc.18734",
        "routineNode": {
            "type": "speakAtVolume",
            "payload": {
                "type": "regular",
                "text": {
                    "type": "str",
                    "value": "Filter change date updated. Reminder in 30 days."
                },
                "volume": {
                    "type": "num",
                    "value": "60"
                },
                "mode": "set",
                "devices": [
                    "G6G0XG1212520DA7"
                ]
            }
        },
        "x": 840,
        "y": 375,
        "wires": [
            []
        ]
    },
    {
        "id": "6e7ecb238c46b213",
        "type": "alexa-remote-routine",
        "z": "4ed6cf89bce2e5ff",
        "name": "Speak: Timed out",
        "account": "f0ce5fbc.18734",
        "routineNode": {
            "type": "speakAtVolume",
            "payload": {
                "type": "regular",
                "text": {
                    "type": "str",
                    "value": "Timed out.  The date has not been updated."
                },
                "volume": {
                    "type": "num",
                    "value": "60"
                },
                "mode": "set",
                "devices": [
                    "G6G0XG1212520DA7"
                ]
            }
        },
        "x": 790,
        "y": 420,
        "wires": [
            []
        ]
    },
    {
        "id": "ab3e2c53.e3491",
        "type": "server",
        "name": "AvilaSmartHome",
        "version": 5,
        "addon": true,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true,
        "heartbeat": false,
        "heartbeatInterval": 30,
        "areaSelector": "friendlyName",
        "deviceSelector": "friendlyName",
        "entitySelector": "friendlyName",
        "statusSeparator": "at: ",
        "statusYear": "hidden",
        "statusMonth": "short",
        "statusDay": "numeric",
        "statusHourCycle": "h23",
        "statusTimeFormat": "h:m",
        "enableGlobalContextStore": true
    },
    {
        "id": "f0ce5fbc.18734",
        "type": "alexa-remote-account",
        "name": "",
        "authMethod": "proxy",
        "proxyOwnIp": "192.168.86.200",
        "proxyPort": "3456",
        "cookieFile": "",
        "refreshInterval": "15",
        "alexaServiceHost": "pitangui.amazon.com",
        "amazonPage": "amazon.com",
        "acceptLanguage": "en-US",
        "userAgent": "",
        "useWsMqtt": "on",
        "autoInit": "on"
    }
]

Figued out my own question.

After setting the entity to the event, I had to change the from “wait until state is double” to “wait until attributes.event_type is double”

image