MQTT Client

Questions and comments specific to a particular plugin should go here.
wawa79
Posts: 25
Joined: Fri Nov 02, 2012 11:01 pm

Re: MQTT Client

Post by wawa79 » Sat Oct 03, 2015 12:56 pm

Thanx a lot :D

RiseUp
Posts: 16
Joined: Mon Nov 24, 2014 3:28 am

Re: MQTT Client

Post by RiseUp » Sun Nov 15, 2015 3:22 pm

mlava wrote: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:
Can you share what you did to fix it? I am experiencing the same issue that you had (i.e. no MQTT messages being seen by EG's MQTT client, with or without the leading "/").

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

Re: MQTT Client

Post by krambriw » Mon Nov 16, 2015 6:15 am

How does your topic definition in EG MQTT Client look like?

How does the mqtt event look like that you are publishing?

Are you able to see any mqtt message with another mqtt client? Like the MQTT.fx client?

RiseUp
Posts: 16
Joined: Mon Nov 24, 2014 3:28 am

Re: MQTT Client

Post by RiseUp » Tue Nov 17, 2015 3:27 am

krambriw wrote:How does your topic definition in EG MQTT Client look like?
I am testing with the topic as:

Code: Select all

eventghost/#
krambriw wrote:How does the mqtt event look like that you are publishing?
I am using Node-RED (from a Raspberry Pi on my LAN) to test the MQTT on Eventghost. Currently, I am just sending a timestamp as the payload.
krambriw wrote:Are you able to see any mqtt message with another mqtt client? Like the MQTT.fx client?
Yes, with the MQTT.fx client, I am receiving the messages. And my mosquitto broker's log says that it is sending the messages to my Eventghost (best that I can tell, at least). However, even with EG's log set to show unassigned events, I see nothing that shows it's receiving the MQTT messages. Any idea what's going on?

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

Re: MQTT Client

Post by krambriw » Tue Nov 17, 2015 5:12 am

Yes, with the MQTT.fx client, I am receiving the messages
Copy & paste some messages here so I can see the structure of them

RiseUp
Posts: 16
Joined: Mon Nov 24, 2014 3:28 am

Re: MQTT Client

Post by RiseUp » Tue Nov 17, 2015 11:49 pm

krambriw wrote:Copy & paste some messages here so I can see the structure of them
I'm not sure if I'm misunderstanding you, or if I've confused you. I am sending MQTT messages from Node-RED on my R-Pi to Eventghost on my PC. For testing purposes, I am simply sending a timestamp. If the copy/paste of the message helps, here is one:

Code: Select all

1447804039460
If in fact I am misunderstanding what you're asking for, I apologize. :oops:

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

Re: MQTT Client

Post by krambriw » Wed Nov 18, 2015 5:41 am

OK, fine, I see

The thing is that in general topics need to be with a leading slash (/)

So in your case, you have to set the topic to /eventghost/#

When you publish the timestamp in the RPi, you have to publish it to the topic /eventghost

If this still does not work, we could start debugging. Open the __init__.py file for the MQTT Client plugin with a text editor, insert the following code at line 173, save and restart EG

Code: Select all

            print msg.topic
            print msg.payload

PS another possible solution could eventually work if you use the topic NRED (without leading slash) on both sides. In EG, configure the topic as NRED/# and in RPi, publish to topic NRED

RiseUp
Posts: 16
Joined: Mon Nov 24, 2014 3:28 am

Re: MQTT Client

Post by RiseUp » Thu Nov 19, 2015 1:23 am

krambriw wrote:OK, fine, I see

The thing is that in general topics need to be with a leading slash (/)

So in your case, you have to set the topic to /eventghost/#

When you publish the timestamp in the RPi, you have to publish it to the topic /eventghost
On mosquitto's man page, all their examples have no leading slash, so I was doing the same. If you mean that your plugin is expecting that leading slash, then so be it. :D
krambriw wrote:If this still does not work, we could start debugging. Open the __init__.py file for the MQTT Client plugin with a text editor, insert the following code at line 173, save and restart EG

Code: Select all

            print msg.topic
            print msg.payload

PS another possible solution could eventually work if you use the topic NRED (without leading slash) on both sides. In EG, configure the topic as NRED/# and in RPi, publish to topic NRED
After adding those lines to the code, I can see the printouts in EG's log! Yay!

And...it works both with and without the leading slash!

So where do we go from here?

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

Re: MQTT Client

Post by krambriw » Thu Nov 19, 2015 4:45 am

If you mean that your plugin is expecting that leading slash
Yeah, that is needed in the normal case (with some special exceptions for the topics NRED, switchking, nethomeserver, zwave and rfxtrx, then it is not needed. You see them if you scroll down the code )
So where do we go from here?
OK, so the correct time stamp is now printed. Do you also see it as event in the EG log on the left side? If so, you can comment out or delete those lines we just added. Next is to start using the event to trigger macros...or just...I don't know what you wanna do. I guess the time stamp was just a test signal. If you have other information to transfer from the RPi, the principal is the same.

(If uncertain, always make a partial screen shot or copy & paste partly from your log, makes it easier to capture what you have working...and what is not)

RiseUp
Posts: 16
Joined: Mon Nov 24, 2014 3:28 am

Re: MQTT Client

Post by RiseUp » Fri Nov 20, 2015 12:52 am

Good idea on the screenshot. This is EG's log of me testing it with the debugging print statements you asked me to insert into the code. Also, I have included the plugin settings window to see how I have it configured.

It appears I am not getting an event in EG. Does everything look okay so far?
Attachments
Capture2.PNG
Capture.PNG
Capture.PNG (3.46 KiB) Viewed 5393 times

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

Re: MQTT Client

Post by krambriw » Fri Nov 20, 2015 7:30 am

It looks ok I think, you should receive events.

I have configured it similar and here it works when I publish a timestamp like that to a broker
Skärmklipp.JPG

PS just an idea! If you could change your setting to publish on the same broker & topic, I would expect that I would receive your time stamps and then I could see further what kind of problem there could be!

RiseUp
Posts: 16
Joined: Mon Nov 24, 2014 3:28 am

Re: MQTT Client

Post by RiseUp » Sat Nov 21, 2015 1:46 am

OK, so I really have no idea what the heck changed, but somehow...it's now working. :shock:

According to my best recollection, the only thing I changed was that I deleted the disabled "Keyboard" plugin from my EG configuration. I can't imagine that that would have anything to do with the MQTT plugin. In fact, I even re-added the keyboard plugin, re-disabled it, and re-tested MQTT, and it still worked. So, I cannot recreate the non-working situation.

Thank you so much, krambriw, for sticking with me to help me get your plugin working, even when it seems like it was some kind of issue on my side. :oops:

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

Re: MQTT Client

Post by krambriw » Sat Nov 21, 2015 6:53 am

Well, good to hear, finally a happy end

Best regards, Walter

MikeD82
Posts: 2
Joined: Tue Jul 08, 2014 4:13 pm

Re: MQTT Client

Post by MikeD82 » Thu Dec 10, 2015 4:40 pm

Your website seems to be down. Is you plugin available via github?

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

Re: MQTT Client

Post by krambriw » Thu Dec 10, 2015 9:34 pm

Sorry for that, my apache server stops sharing from time to time ... unknown reason, trying to fix it now...

Should be accessible now again

Post Reply