Page 3 of 17
Re: MQTT Client
Posted: Tue Mar 03, 2015 7:11 pm
by gus
Hi!
First attempt to get this plug to work

My goal is to use this to connect to mysensors modules (
http://mysensors.org).
I managed to publish events to a local mossquitto broker, and I can see the events on other clients. My only problem is right now to see the events on EG.
I subscribe to Topic "/mysensors/#" but it will never appear any messages. I managed to get messages to EG if I'll type:
Code: Select all
mosquitto_pub -h 127.0.0.1 -t /mysensors -m "messages"
but not:
Code: Select all
mosquitto_pub -h 127.0.0.1 -t mysensors -m "messages"
Is there a way to subscribe to a Topic without the "/" before topic?
Regards Rickard
Re: MQTT Client
Posted: Wed Mar 04, 2015 7:51 am
by krambriw
Just put in # and you will subscribe to every topic
Re: MQTT Client
Posted: Wed Mar 04, 2015 1:20 pm
by gus
Sorry, already tested that, you then get an Exception:
Code: Select all
14:16:16 Exception in thread EventGhost:
14:16:16 Traceback (most recent call last):
14:16:16 File "threading.pyc", line 532, in __bootstrap_inner
14:16:16 File "C:\Program Files\EventGhost\plugins\MQTT Client\__init__.py", line 306, in run
14:16:16 lrsp = mqttc.loop(10.0, 1)
14:16:16 File "C:\Program Files\EventGhost\plugins\MQTT Client\mosquitto.py", line 722, in loop
14:16:16 rc = self.loop_read(max_packets)
14:16:16 File "C:\Program Files\EventGhost\plugins\MQTT Client\mosquitto.py", line 899, in loop_read
14:16:16 rc = self._packet_read()
14:16:16 File "C:\Program Files\EventGhost\plugins\MQTT Client\mosquitto.py", line 1278, in _packet_read
14:16:16 rc = self._packet_handle()
14:16:16 File "C:\Program Files\EventGhost\plugins\MQTT Client\mosquitto.py", line 1670, in _packet_handle
14:16:16 return self._handle_publish()
14:16:16 File "C:\Program Files\EventGhost\plugins\MQTT Client\mosquitto.py", line 1782, in _handle_publish
14:16:16 self.on_message(self, self._userdata, message)
14:16:16 File "C:\Program Files\EventGhost\plugins\MQTT Client\__init__.py", line 255, in on_message
14:16:16 if str(msg.topic).find(self.topic.split('/')[1]) > 0:
14:16:16 IndexError: list index out of range
And if I use "/#" then it dosent crash, but nothing receives
I use version r1694 and your latest plugin:
Re: MQTT Client
Posted: Wed Mar 04, 2015 1:58 pm
by krambriw
Strange, it works for me but I also see your exception...a / should be needed I think...cannot explain why it works here
To understand, you say that if you publish to /mysensors and subscribe in EG to /# it works?
What is the problem using / ?
EDIT I see why the exception happens, I am actually expecting that your subscription has a /
Re: MQTT Client
Posted: Wed Mar 04, 2015 2:23 pm
by krambriw
In EG, if you configure a subscription to a topic like /test you can use another of the actions to publish a message to the same topic /test and it should work. Now if you want to publish from Linux, you have to publish to the same topic
Re: MQTT Client
Posted: Wed Mar 04, 2015 6:32 pm
by gus
I must say that I'm quite a rookie with MQTT still... but in the parser that I use between mysensors and mosquitto I don't manage to add "/" before the topics name, it crashes then...
I'll find a way, this is fun, new building blocks form my automation jungle

Re: MQTT Client
Posted: Wed Mar 04, 2015 7:04 pm
by krambriw
I have noticed that a / (slash) not is mandatory in general, it is my implementation that is this way (I read in the beginning somewhere and understod that a slash was mandatory). It would be good if you can find a way around so I don't have to modify the plugin

Re: MQTT Client
Posted: Tue May 12, 2015 8:16 am
by krambriw
Added support for SwitchKing MQTT events
Since there is a new plugin for SwitchKing supporting MQTT, I have made an update of the EventGhost plugin to allow MQTT integrations between the two
http://www.switchking.se/forum/viewtopi ... =23&t=1714
New plugin uploaded
Re: MQTT Client
Posted: Sun Aug 09, 2015 10:23 am
by mlava
Hi
I am also having no events in log...
I'm using on same machine as broker, so 127.0.0.1:1883.
Have tried:
#
#/
/#
/#/
and various combinations using my topics, but nothing in log.
Can you help?
EG 0.4.1r1700
using current version d/l today from
http://krambriw.net/Release/MQTT%20Client/
Re: MQTT Client
Posted: Mon Aug 10, 2015 5:56 am
by krambriw
It is (in current version) mandatory to start with a slash for subscription to topics.
/# should be a good starting point
1) How and to what topic do you publish? (the topic has also to start with a slash)
2) New to EG? Check that the subscription really is running, open the plugin and check the list of running clients
3) Tick checkbox for all events?
Re: MQTT Client
Posted: Mon Aug 10, 2015 10:16 am
by mlava
Hi
I have mosquitto running on same pc, lots of mqtt messages running around.
I can see using MQTTlens that the topics are being sent.
I have unchecked the 'Log only assigned and activated events' in eventghost.
I tried creating a new topic with mosquitto_pub.exe but not showing in eg log with or without slash.
I have confirmed the subscription starts in the Plugin: MQTT Client entry in my autostart.
Any other ideas?
Re: MQTT Client
Posted: Wed Aug 12, 2015 2:01 am
by mlava
Scratch all that...
I now have it working, it was more about the format of the topic definitions on my side, not a problem with the plugin.
Sorry to have wasted your time! Silly me...

Re: MQTT Client
Posted: Wed Aug 12, 2015 4:46 am
by krambriw
No problem, good that you have it working now
Re: MQTT Client
Posted: Sat Oct 03, 2015 11:50 am
by wawa79
Hello,
Could anybody share the MQTT plugin?
Site
http://krambriw.net/ seems to be down.
Thanks!
Re: MQTT Client
Posted: Sat Oct 03, 2015 12:49 pm
by krambriw
My apache server is now up again