MQTT Gateway Plugin

Posted on
Tue Feb 09, 2016 4:31 pm
jeremyjjr offline
Posts: 104
Joined: Sep 10, 2013
Location: St Albans, UK

Re: MQTT Gateway Plugin

Can you expand on what the issues are? Happy to try and help fix and build in to 1.0.9!


Sent from my iPhone using Tapatalk

Posted on
Tue Feb 09, 2016 11:30 pm
bluenoise offline
Posts: 143
Joined: Aug 23, 2008

Re: MQTT Gateway Plugin

jeremyjjr wrote:
Okay, so I think we can safely say this is an iterative process :D

I did some digging around the On/Off state property of the MQTT device. If the 'Show On/Off State' checkbox is not ticked in the Device config dialog, then any attempt to access the onOffState property of the device will fail. I've updated the code to 1.0.8 (yes, again!) to check that the device supports the property before trying to update it - this should remove the errors you are seeing when the plugin loads for the first time.

As for the error you posted in the log - looks like this is being generated by an action or trigger script rather than the plugin itself? If I'm correct, then paste the code and we can take a look.

J.



I didn't get the On/Off state errors with this new one and it's working perfectly. Thank you very much!

Regarding that error, I believe you're correct. I think it's the script I posted earlier that tracks the maximum temperature of the pool. It's assuming what it gets from the plugin is a float represented as a string, but it must be getting "Test message" when the plugin first reloads.

Posted on
Wed Feb 10, 2016 1:25 am
jeremyjjr offline
Posts: 104
Joined: Sep 10, 2013
Location: St Albans, UK

Re: MQTT Gateway Plugin

Okay!

The plugin doesn't load any messages when it starts, so 'test message' must have been sent in the past and is still stored in the device state.

If you send a message of '0.0' then this should solve things.


Sent from my iPhone using Tapatalk

Posted on
Wed Feb 10, 2016 10:02 am
bluenoise offline
Posts: 143
Joined: Aug 23, 2008

Re: MQTT Gateway Plugin

I added a simple test to my script:

Code: Select all
if len(message) > 5:
   message = "0.0"


If the length of the message is greater than five characters, it's very unlikely to be the temperature of my pool. I picked five because the temp could be "xx.xx" if I decide I want that much precision some day. :P

Posted on
Tue Mar 08, 2016 12:50 pm
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: MQTT Gateway Plugin

jeremyjjr wrote:
... hope you have success with everything and please share how you use the plugin!


Hi Jeremy,
This is how I am currently using it which is maybe not as originally envisaged? :)

I am using Airfoil to send audio to a couple of SmartSpeaker (A2) AirPlay speakers. I have written a python program to subscribe and receive messages from the MQTT broker. I have converted the python program to an OSX app (named AutologAudio) by using py2app. The messages contain the sound and/or speech text to play. The AutologAudio app converts the speech to audio. I can use Airfoil to select the AutologAudio app as source and direct the output to the airplay speakers.

I use the MQTTGateway plugin to publish the messages from Indigo to the MQTT broker. This seems to work quite well. :D

However, I note that you have to enable Status Request and enter a Status Topic for the Send Message action to be routed to the correct topic otherwise it goes to device/status (even though this isn't defined in the device).

It would be useful if the output message did device and variable substitution on Send Message action. I have taken the liberty of adding the following code into the SendMessage function just before the except clause i.e at the point the function has determined it has a valid message to publish:
Code: Select all
            # AUTOLOG MODIFICATION START
            # perform variable / device substitution
            textToSpeakvalidation = self.substitute(brokerStatusMessage, validateOnly=True)
            if textToSpeakvalidation[0] == True:
                brokerStatusMessage = self.substitute(brokerStatusMessage, validateOnly=False)
            else:
                self.debugLog("Broker Status Message ['%s'] has an error with dev/var substitution: [%s]" % (brokerStatusMessage, textToSpeakvalidation[1]))
                return False

            # AUTOLOG MODIFICATION END
I now have device/variable substitution in my output messages :)

Thanks again for taking the time and trouble to write this plugin to enable the use of MQTT - It is much appreciated. :D

Posted on
Tue Sep 06, 2016 6:34 am
yassi offline
Posts: 468
Joined: Sep 06, 2015
Location: Germany

Re: MQTT Gateway Plugin

Hi Jeremy,

first of all, thanks for the plugin, great idea!

I'm not really using ist right now with Indigo (the plugin is installed), but installed a broker on my Synology NAS, some clients on the iPhone & iPad, they are talking to each other (publich/ subscribe)
Waiting to get some NodeMCU's first (someone here is using them) and sensors for temperature - or try with Arduino, then I will come back with questions :lol:

Best,
Yassi

Update: As I see, the plugin brings an error (Python.framework missing in System/Library/Frameworks, it looks for version 2.6, I don't have the folder at all.)
But with homebrew Python 2.7 is also installed in /opt
Any idea what's going on?
Attachments
Bildschirmfoto 2016-09-06 um 21.17.33.png
No 2.6 Python.framework
Bildschirmfoto 2016-09-06 um 21.17.33.png (48.08 KiB) Viewed 6973 times
Bildschirmfoto 2016-09-06 um 21.17.03.png
Python from homebrew
Bildschirmfoto 2016-09-06 um 21.17.03.png (39.71 KiB) Viewed 6973 times
Bildschirmfoto 2016-09-06 um 21.16.09.png
Python 2.6.1
Bildschirmfoto 2016-09-06 um 21.16.09.png (31.71 KiB) Viewed 6973 times
Bildschirmfoto 2016-09-06 um 21.13.22.png
Plugin
Bildschirmfoto 2016-09-06 um 21.13.22.png (27.21 KiB) Viewed 6973 times

Posted on
Tue Sep 06, 2016 1:44 pm
jeremyjjr offline
Posts: 104
Joined: Sep 10, 2013
Location: St Albans, UK

MQTT Gateway Plugin

Hi - thanks for your kind comments.

Indigo uses the Python 2.6 stack. You have to ensure you install the python libraries under v2.6 and not the OS default 2.7.

You should be able to execute v2.6 by typing 'python2.6' on the cmd line.

Let me know how you get on.

Jeremy.

Posted on
Wed Sep 07, 2016 1:00 am
yassi offline
Posts: 468
Joined: Sep 06, 2015
Location: Germany

Re: MQTT Gateway Plugin

jeremyjjr wrote:
Hi - thanks for your kind comments.

Indigo uses the Python 2.6 stack. You have to ensure you install the python libraries under v2.6 and not the OS default 2.7.

You should be able to execute v2.6 by typing 'python2.6' on the cmd line.

Let me know how you get on.

Jeremy.


Hi Jeremy,

ok. But's strange, because when I call Python in terminal I get the version 2.6.1
Also, it sems a 2.7 was installed by homebrew.

How can I reinstall the 2.6.1 again with the libraries? Should I get the package from python.org?
And do I have to deinstall the 2.7 from homebrew?

Yassi

Posted on
Wed Sep 07, 2016 1:07 am
jeremyjjr offline
Posts: 104
Joined: Sep 10, 2013
Location: St Albans, UK

Re: MQTT Gateway Plugin

Hi Yassi, sounds like a pickle! 2.7 ships by default with Mac OSX 10.7+ so it shouldn't have been installed by homebrew.

That said, I'd carefully search for info on removing the brew version of 2.7 to ensure it doesn't impact the base OS version.

I'm not sure you can reinstall 2.6, but worth checking for information on how to reset to default. This may impact other apps that have installed other libraries ...

For installation of Python libraries I tend to use PIP as a way to manage the trickier bits!

Good luck!

Posted on
Wed Sep 07, 2016 2:38 am
yassi offline
Posts: 468
Joined: Sep 06, 2015
Location: Germany

Re: MQTT Gateway Plugin

jeremyjjr wrote:
Hi Yassi, sounds like a pickle! 2.7 ships by default with Mac OSX 10.7+ so it shouldn't have been installed by homebrew.

That said, I'd carefully search for info on removing the brew version of 2.7 to ensure it doesn't impact the base OS version.

I'm not sure you can reinstall 2.6, but worth checking for information on how to reset to default. This may impact other apps that have installed other libraries ...

For installation of Python libraries I tend to use PIP as a way to manage the trickier bits!

Good luck!


Oh, that sounds complex! :shock:
No idea, what happened. Seems so that the frameworks are missing under /System/Library/Frameworks/...
In any case, both are installed, 2.6.1 and 2.7. with brew(?).
Hmmm, maybe I will try to install somewhere a clean 10.6.8 (actually on the MacMini running Indigo) and just copy the frameworks over to the Indigo server?

Thx.
Yassi

UPDATE: Jeremy, I have it. Sorry, my fault: I looked in the wrong directory. I have the frameworks and libs, but the plugin still gives me the same error in line 595 and 1106 in the subprocess.py file.
What could be wrong?
Attachments
Bildschirmfoto 2016-09-07 um 20.39.33.png
Frameworks and libs are here
Bildschirmfoto 2016-09-07 um 20.39.33.png (279.92 KiB) Viewed 6874 times

Posted on
Thu Sep 08, 2016 5:10 pm
jeremyjjr offline
Posts: 104
Joined: Sep 10, 2013
Location: St Albans, UK

Re: MQTT Gateway Plugin

Hmm. The error traces back to the sub process.py lib. Looks like something is corrupt somewhere.

If you have the spare hardware, definitely worth giving a clean install a shot. If not spin up a VM using parallels or equivalent?

Sorry I can't help more but it's not an error in the code I've written and I wouldn't want to give any 'advice' that may cause more harm than good!!

Best of luck!

Posted on
Fri Sep 09, 2016 12:25 pm
yassi offline
Posts: 468
Joined: Sep 06, 2015
Location: Germany

Re: MQTT Gateway Plugin

jeremyjjr wrote:
Hmm. The error traces back to the sub process.py lib. Looks like something is corrupt somewhere.

If you have the spare hardware, definitely worth giving a clean install a shot. If not spin up a VM using parallels or equivalent?

Sorry I can't help more but it's not an error in the code I've written and I wouldn't want to give any 'advice' that may cause more harm than good!!

Best of luck!


Hi Jeremy,

I've sent you a PM.

Yassi

Posted on
Mon Sep 19, 2016 7:01 am
yassi offline
Posts: 468
Joined: Sep 06, 2015
Location: Germany

Re: MQTT Gateway Plugin

UPDATE:

So, still trying to install the mosquitto package with homebrew.
@Jeremy: I was able to fix some errors with curl, and managed to install all packages needed by mosquitto but the last one "c-ares" doesn't want to install.

Seems so, something is wrong with the compiler.
Per default gcc 4.2.1 ist installed, as well 5.3.0 by homebrew.

Does one have an idea how to fix it? Or how to get "c-ares" installed?

Yassi
Attachments
mosquitto with brew.jpg
mosquitto with brew.jpg (133.96 KiB) Viewed 6769 times

Posted on
Mon Sep 19, 2016 7:23 am
jeremyjjr offline
Posts: 104
Joined: Sep 10, 2013
Location: St Albans, UK

Re: MQTT Gateway Plugin

Yassi,

I may be stating the obvious here, but any reason you're still running 10.6? I'd encourage you to upgrade to latest version of OS as supported by Indigo 6.1 and see how that goes ...

J.

Posted on
Mon Sep 19, 2016 7:31 am
yassi offline
Posts: 468
Joined: Sep 06, 2015
Location: Germany

Re: MQTT Gateway Plugin

jeremyjjr wrote:
Yassi,

I may be stating the obvious here, but any reason you're still running 10.6? I'd encourage you to upgrade to latest version of OS as supported by Indigo 6.1 and see how that goes ...

J.


Jeremy, you're right. The old stuff makes troubles. But the newest too :lol:

But: I'm still waiting for Indigo7 (to see the requirements) and for a newer OS I don't have an "actual/ supported" Mac.
Could install on one old MacBook (white) 10.7, but that's all, no step further without hacks.

Yassi

Page 4 of 9 1, 2, 3, 4, 5, 6, 7 ... 9

Who is online

Users browsing this forum: No registered users and 22 guests