MQTT Publisher Plugin

1,155 views
Skip to first unread message

janwille...@gmail.com

unread,
Apr 3, 2017, 6:16:43 AM4/3/17
to Automate
Does any one has experience with this Tasker MQTT Publisher Plugin or have a sort of guide how to use it?

My test flow works but the MQTT message does not arrive to my MQTT broker (Mosquitto).

I use the Plug-in action block to publish a topic with a so called payload-message. The plug-in settings are almost the same as is used at example on Google Paly store.

I also wonder if you could use  flow variables to set the topic and the message?

regards and thanks in advance.

janwille...@gmail.com

unread,
Apr 3, 2017, 8:28:47 AM4/3/17
to Automate, janwille...@gmail.com
The test flow is now working: I made a typing error in the topic part, with the result that the MQTT subscriber client did not receive the message.

Remains still the question: how to pass the topic and payload message part dynamically into the MQTT Publisher plug-in?

Any ideas how to resolve this?

Regards and thanks in advance.

janwille...@gmail.com

unread,
Apr 3, 2017, 8:36:37 AM4/3/17
to Automate, janwille...@gmail.com
I also wonder if you could use  flow variables to set the topic and the message?

OK, I found it, use the percent sign % as a prefix, so %topic and %msg


Message has been deleted

Simon H

unread,
Mar 31, 2018, 12:16:30 PM3/31/18
to Automate
Hi janwille,

writing this for the second time; not sure what happenned to the first one.

I'm having real trouble with getting the data from received MQTT messages. (i.e. where I've suscribed to a topic.  The plugin see the msg, but I just can't get it to create variables I can use).
Did you try this?

If so, could you outline your MQTT 'Message Received' configuration, and the configuration of the next block in the flow?

I only seem to be able to get 'variable not found' errors...

thanks,

Simon


Message has been deleted

Simon H

unread,
Apr 1, 2018, 3:36:41 AM4/1/18
to automa...@googlegroups.com
For posterity and easy of searching; I've duplicated this from my other thread:

Ok, just tried pre-creating the variable name using a 'Variable set' block - it works!

So; exact config to make MQTT Client message receive work:

1/ use two 'variable set' blocks to set variables 'topic', 'msg' (and from the source, maybe 'error'?) to some default values.  put these in the flow before the Plugin Event for 'MQTT Client:Message Arrived'.

2/ In a 'Plugin Event' block, select 'Message Arrived' from MQTT Client, and set 'vartopic' to topic, and 'varmessage' to msg (no % symbol!).

3/ Set 'Allow plug-in to assign any variable' - important!

4/ then in subsequent blocks you should be able to use '= topic' and '= msg' to access the MQTT message which was received.

janwille...@gmail.com

unread,
Apr 1, 2018, 4:48:25 AM4/1/18
to Automate
Hi Simon,

I did not receive your questions until this morning.

I use the flow to publish a mqtt message to a mqtt subscriber program to take actions according to the topic and payload message.

first I set two variables with the topic and msg like:
var topic = "code/grp/act/light/on"
var msg = "pw:Lampx;zw:node=2;zw:node=3"

Plugin block:
plugin = MQTT Publisher
configure settings:
IP-address  port 1883
tests7        no ssl/tls
username empty pasword empty        (at the moment)
%topic
%msg
option QoS1 (flagged)
checkbox Allow plugin to assing any variable (checked)

That's all, after a dealy of 15 minutes I send another topic and message . So the next block is setting line to the logfile and similar variable settings a new call to the plugin.

Hopefully this answers your questions, but you find a solution yourself.

Simon H

unread,
Apr 1, 2018, 6:21:27 AM4/1/18
to Automate
hi janwille,

thanks for replying :)

yes, I thought you were publishing only.
At least now we know we can publish and subscribe; I'm sure there must be a better way than mine, but it's working for me for the moment.

I'm using MQTT to interface with Node-Red; so it allows Node-Red to process SMS messages, and the subscription element allows me to send SMS from Node-Red (totally against my mobile terms and conditions!).

best,

Simon
Reply all
Reply to author
Forward
0 new messages