MQTT Client

Questions and comments specific to a particular plugin should go here.
gus
Posts: 11
Joined: Sun Feb 10, 2013 5:09 pm

Re: MQTT Client

Post by gus » Tue Mar 03, 2015 7:11 pm

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

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: MQTT Client

Post by krambriw » Wed Mar 04, 2015 7:51 am

Just put in # and you will subscribe to every topic

gus
Posts: 11
Joined: Sun Feb 10, 2013 5:09 pm

Re: MQTT Client

Post by gus » Wed Mar 04, 2015 1:20 pm

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:

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: MQTT Client

Post by krambriw » Wed Mar 04, 2015 1:58 pm

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 /

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: MQTT Client

Post by krambriw » Wed Mar 04, 2015 2:23 pm

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

gus
Posts: 11
Joined: Sun Feb 10, 2013 5:09 pm

Re: MQTT Client

Post by gus » Wed Mar 04, 2015 6:32 pm

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 :-)

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: MQTT Client

Post by krambriw » Wed Mar 04, 2015 7:04 pm

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 :D

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: MQTT Client

Post by krambriw » Tue May 12, 2015 8:16 am

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

mlava
Posts: 3
Joined: Sun Aug 09, 2015 10:17 am

Re: MQTT Client

Post by mlava » Sun Aug 09, 2015 10:23 am

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/

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: MQTT Client

Post by krambriw » Mon Aug 10, 2015 5:56 am

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?

mlava
Posts: 3
Joined: Sun Aug 09, 2015 10:17 am

Re: MQTT Client

Post by mlava » Mon Aug 10, 2015 10:16 am

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?

mlava
Posts: 3
Joined: Sun Aug 09, 2015 10:17 am

Re: MQTT Client

Post by mlava » Wed Aug 12, 2015 2:01 am

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... :roll:

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: MQTT Client

Post by krambriw » Wed Aug 12, 2015 4:46 am

No problem, good that you have it working now

wawa79
Posts: 25
Joined: Fri Nov 02, 2012 11:01 pm

Re: MQTT Client

Post by wawa79 » Sat Oct 03, 2015 11:50 am

Hello,

Could anybody share the MQTT plugin?
Site http://krambriw.net/ seems to be down.

Thanks!

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: MQTT Client

Post by krambriw » Sat Oct 03, 2015 12:49 pm

My apache server is now up again

Post Reply