Do something (run a macro?) on receipt of an MQTT message?

More
1 year 9 months ago #3543 by andrew
Is it possible to do something such as run a macro on receipt of an MQTT message? I'm using myServer as the MQTT broker and messages are getting sent to it. And I've got the hang of server variables being set from the payload of messages. The problem I have is that I'm using a wireless (battery powered) push switch and each time you press it Zigbee2MQTT sends the following:

Topic: zigbee2mqtt/Kitchen button
Payload: {"action":"single","battery":100,"linkquality":68,"voltage":3100}

Because the action is 'single' each time the message is sent the myServer server variable called 'zigbee2mqtt_kitchen buttonaction' always has the value 'single' so it doesn't change, so I can't use 'changes value' as a trigger in a macro.

Can I run something based on an MQTT message arriving?

Andrew

Please Log in to join the conversation.

More
1 year 9 months ago #3544 by aa6vh
Just brain storming here (and there may be a better way), but couldn't you save off the current time ({{CURRENT_TIME}} or one of the similar server variables) when a MQTT message is received? Then trigger on that variable changing value.

Please Log in to join the conversation.

More
1 year 9 months ago #3545 by andrew

Just brain storming here (and there may be a better way), but couldn't you save off the current time ({{CURRENT_TIME}} or one of the similar server variables) when a MQTT message is received? Then trigger on that variable changing value.
Thanks, but if I could save the current time on receipt of an MQTT message I could probably do the action I want to do instead. I don't know how to do anything on receipt of a message (rather than on a zigbee2mqtt related server variable changing).

Andrew

Please Log in to join the conversation.

More
1 year 9 months ago #3570 by andrew

Just brain storming here (and there may be a better way), but couldn't you save off the current time ({{CURRENT_TIME}} or one of the similar server variables) when a MQTT message is received? Then trigger on that variable changing value.
Thanks, but if I could save the current time on receipt of an MQTT message I could probably do the action I want to do instead. I don't know how to do anything on receipt of a message (rather than on a zigbee2mqtt related server variable changing).

Andrew
@David Li @davep Any ideas about this? Or is it just not doable?

Andrew

Please Log in to join the conversation.

Time to create page: 0.175 seconds