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

andrew's Avatar Topic Author
User User
  • Posts: 341
  • Thanks: 28

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

1 year 10 months ago
#3543
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 or Create an account to join the conversation.

aa6vh's Avatar
User User
  • Posts: 111
  • Thanks: 7

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

1 year 10 months ago
#3544
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 or Create an account to join the conversation.

andrew's Avatar Topic Author
User User
  • Posts: 341
  • Thanks: 28

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

1 year 10 months ago
#3545
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 or Create an account to join the conversation.

andrew's Avatar Topic Author
User User
  • Posts: 341
  • Thanks: 28

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

1 year 10 months ago
#3570
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 or Create an account to join the conversation.

Time to create page: 0.276 seconds