MQTT Gateway Plugin

Posted on
Sun Jun 11, 2017 10:41 am
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: MQTT Gateway Plugin

It works for me OK AFAICS.
I have the triggers set to topic message becomes equal to 'CAMERAS ON' for example.
The MQTT device shows the topicMessage that has been sent.

Is your trigger on the receiving system?

Posted on
Wed Jun 14, 2017 4:19 pm
jeremyjjr offline
Posts: 104
Joined: Sep 10, 2013
Location: St Albans, UK

Re: MQTT Gateway Plugin

Reviewing recent feedback from others in the forum, I've taken the opportunity to add further functionality to the mqttGateway plugin and up-versioned to 1.1.1. Link can be found at the top of this thread.

Enhancements
1. Added support for device level basic authentication to the Mosquitto broker using a user name and password (sent in the clear, so not public access ready!)
2. Variable substitution is now enabled when sending a message to a topic. Messages should take form 'Today is %%v:VariableID%%', where 'VariableID'' is the Indigo variable unique ID

Fixes
1. Umlauts now supported - although, this is likely to Indigo using Python 2.7, over me fixing anything.

For instructions on how to configure Mosquitto Broker to require user name and password credentials, see https://medium.com/@eranda/setting-up-authentication-on-mosquitto-mqtt-broker-de5df2e29afc

Please make a backup of your old version of the plugin before installing - just in case!

Thanks,

Jeremy.
Last edited by jeremyjjr on Wed Jun 14, 2017 5:22 pm, edited 2 times in total.

Posted on
Wed Jun 14, 2017 4:39 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: MQTT Gateway Plugin

Check out the substitute method in the plugin base class - it will automatically do variable and device state substitutions in strings using the same syntax as all other plugins that support substitution... ;)

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Jun 14, 2017 5:23 pm
jeremyjjr offline
Posts: 104
Joined: Sep 10, 2013
Location: St Albans, UK

Re: MQTT Gateway Plugin

Thanks Jay! Updated accordingly.

Posted on
Wed Jun 21, 2017 12:42 pm
mikeL offline
Posts: 46
Joined: Apr 30, 2010
Location: Gatineau, QC

Re: MQTT Gateway Plugin

Hi Jeremy:
Thanks for building this plugin. I’m using the plugin to get data from an Arduino Uno Wifi that’s measuring luminosity into Indigo via MQTT. And, it seems to be working well. The image is a dashboard from one of my Indigo control pages.
Cheers,
Mike
Attachments
screenshot_211.jpg
screenshot_211.jpg (86.95 KiB) Viewed 7777 times

Posted on
Wed Jun 21, 2017 1:11 pm
jeremyjjr offline
Posts: 104
Joined: Sep 10, 2013
Location: St Albans, UK

Re: MQTT Gateway Plugin

Nicely done Mike! Thanks for sharing the use case! If you have any ideas on additional functionality then let me know!

Posted on
Mon Jun 26, 2017 10:44 am
mikeL offline
Posts: 46
Joined: Apr 30, 2010
Location: Gatineau, QC

Re: MQTT Gateway Plugin

Hey Jeremy:
I’d like to be able to use the state of the mqttGateway Topic Subscription (On or Off) to indicate the reliability of the data published.

Here’s my use case. My sensor publishes data at regular intervals, say, every 30 seconds. If the sensor goes down (goes offline or crashes), it will not publish. This results in regular changes to the topic notification state of the corresponding topic subscription, about every 30 seconds, unless the sensor is down. So, I use a timer from the Timers and Pesters plugin that will time out if the expected state change does not occur on time, say within 120 seconds. My sensor does not support status update, so this gives me a way to assess the timeliness of the last data published, aka, its reliability.

When the time out occurs, I’d like to set the state of the topic subscription to Off to give a logical indication that the sensor has gone offline, but I can’t seem to set it at will. The time out event tries to run this script where “GDM main door” is the topic subscription.
Code: Select all
gdm = indigo.devices[1989790393] # "GDM main door"
if hasattr(gdm, 'onState'):
   isOn = gdm.onState
   if not isOn:
      indigo.device.turnOn(gdm)

results in

mqttGateway Error plugin does not define method actionControlSensor

So, no go. Without knowing the impact on the functionality of your plugin, I would like to ask you for a method in the plugin that directly sets the state of the subscription to On or Off. And, for the record, what is the real intended meaning of the state of the subscription? (In case I’m abusing it.)

BTW, I realize that I can control the subscription’s state by doing the following, but this is a bit ugly, n’est-ce pas?
Code: Select all
gdm = indigo.devices[1989790393] # "GDM main door"
if hasattr(gdm, 'onState'):
   isOn = gdm.onState
   if not isOn:
      # turn on subscription
      import subprocess
      cmd = "/usr/local/bin/mosquitto_pub -t gdm/mainDoor -m 'On'"
      process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
      # launch the shell command:
      out, err = process.communicate()
      if err != '':
         indigo.server.log(err[0:], type=u'MQTT turn-on script')

Cheers,
Mike

Posted on
Thu Jul 20, 2017 10:18 am
rlust offline
Posts: 93
Joined: Jan 12, 2009
Location: Ohio

Re: MQTT Gateway Plugin

I also would really like the ability to publish ON / Off events.

Thanks for your work!

Posted on
Thu Nov 02, 2017 8:31 am
BonfireVA offline
Posts: 62
Joined: Sep 17, 2017

Re: MQTT Gateway Plugin

Is there anyway in Indigo to create "virtual devices" for things other than switches? I have used Sonoff devices with MQTT to update variables in Indigo and tied virtual switches in the interface to these variables, works great. I want to do the same with PIR, temp, and door switches I have deployed using Arduino and MQTT. I was able to update variable in Indigo for these sensors, and create control pages to display the values / states, but I would like to be able to add them as actual devices, mostly for proper integration with homebridge.
Thanks!

-Eric

Posted on
Thu Nov 02, 2017 9:17 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: MQTT Gateway Plugin

BonfireVA wrote:
Is there anyway in Indigo to create "virtual devices" for things other than switches? I have used Sonoff devices with MQTT to update variables in Indigo and tied virtual switches in the interface to these variables, works great. I want to do the same with PIR, temp, and door switches I have deployed using Arduino and MQTT. I was able to update variable in Indigo for these sensors, and create control pages to display the values / states, but I would like to be able to add them as actual devices, mostly for proper integration with homebridge.
Thanks!

-Eric


Try using my Masquerade plugin to make a homebridge compatible virtual device.

viewtopic.php?f=216&t=17402

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Thu Nov 02, 2017 9:34 am
BonfireVA offline
Posts: 62
Joined: Sep 17, 2017

Re: MQTT Gateway Plugin

FlyingDiver wrote:
Try using my Masquerade plugin to make a homebridge compatible virtual device.

viewtopic.php?f=216&t=17402



I will take a look, thanks for the quick reply!

-Eric

Posted on
Thu Nov 02, 2017 11:08 am
BonfireVA offline
Posts: 62
Joined: Sep 17, 2017

Re: MQTT Gateway Plugin

BonfireVA wrote:
FlyingDiver wrote:
Try using my Masquerade plugin to make a homebridge compatible virtual device.

viewtopic.php?f=216&t=17402



I will take a look, thanks for the quick reply!

-Eric


Does the plug in support temperature sensor types? I have an Arduino that is sending results from several temp sensors using MQTT. I am using the MQTT plugin to write the temp values to variables in Indigo. If I create a new masquerade device and choose the sensor option, I can choose the MQTT plug in, and the temp sensor I want to use, but the masquerade device only gives me an on/off value, not the contents of the MQTT message (which in this case would be the temp). Is the masquerade sensor type meant for things like door/window or PIR sensors?

-Eric

Posted on
Thu Nov 02, 2017 11:11 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: MQTT Gateway Plugin

BonfireVA wrote:
Does the plug in support temperature sensor types? I have an Arduino that is sending results from several temp sensors using MQTT. I am using the MQTT plugin to write the temp values to variables in Indigo. If I create a new masquerade device and choose the sensor option, I can choose the MQTT plug in, and the temp sensor I want to use, but the masquerade device only gives me an on/off value, not the contents of the MQTT message (which in this case would be the temp). Is the masquerade sensor type meant for things like door/window or PIR sensors?

-Eric


There's currently no temp sensor type. But I could add one fairly easily I think.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Thu Nov 02, 2017 11:24 am
BonfireVA offline
Posts: 62
Joined: Sep 17, 2017

Re: MQTT Gateway Plugin

FlyingDiver wrote:
BonfireVA wrote:
Does the plug in support temperature sensor types? I have an Arduino that is sending results from several temp sensors using MQTT. I am using the MQTT plugin to write the temp values to variables in Indigo. If I create a new masquerade device and choose the sensor option, I can choose the MQTT plug in, and the temp sensor I want to use, but the masquerade device only gives me an on/off value, not the contents of the MQTT message (which in this case would be the temp). Is the masquerade sensor type meant for things like door/window or PIR sensors?

-Eric


There's currently no temp sensor type. But I could add one fairly easily I think.



That would be great!
Basically a device type that can support a float or even a string value from the MQTT topic would be extremely useful and a way to tell Indigo what it is (ie temp, humidity, ambient light etc). If you are able to make some progress on adding support I could certainly help test.

-Eric

Posted on
Thu Nov 02, 2017 7:33 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: MQTT Gateway Plugin

BonfireVA wrote:
That would be great!
Basically a device type that can support a float or even a string value from the MQTT topic would be extremely useful and a way to tell Indigo what it is (ie temp, humidity, ambient light etc). If you are able to make some progress on adding support I could certainly help test.

-Eric


Try https://github.com/FlyingDiver/Indigo-M ... /0.1.1.zip

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

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

Who is online

Users browsing this forum: Google [Bot] and 6 guests

cron