MQTT Gateway Plugin

Posted on
Mon Feb 01, 2016 10:53 am
bluenoise offline
Posts: 143
Joined: Aug 23, 2008

Re: MQTT Gateway Plugin

All right, it seems I was greatly overthinking the solution to my problem. I looked at the source code of the MQTT Gateway plugin and found a reference that I hadn't seen. So, my updated script is here:

Code: Select all
poolMax = indigo.variables[1141597781] # "pool_temp_max" variable that is reset each morning

poolTemp = indigo.devices[102542860] # "Pool Temperature" sensor via MQTT

message = poolTemp.states["topicMessage"] # MQTT message payload from temperature sensor


# If the daily maximum temperature is less than our new temperature, update the daily max to the new value
if float(poolMax.value) < float(message):
   indigo.variable.updateValue(poolMax, message)


This is much nicer. I hadn't found this reference in any documentation for scripting using custom plugin devices.

Posted on
Mon Feb 01, 2016 11:05 am
jeremyjjr offline
Posts: 104
Joined: Sep 10, 2013
Location: St Albans, UK

Re: MQTT Gateway Plugin

Nicely done!

Posted on
Mon Feb 01, 2016 11:37 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: MQTT Gateway Plugin

Not knowing anything about how that plugin works, I didn't chime in. However, for future reference in the scripting tutorial: Access a custom device state.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Feb 01, 2016 1:36 pm
bluenoise offline
Posts: 143
Joined: Aug 23, 2008

Re: MQTT Gateway Plugin

jeremyjjr wrote:
Nicely done!


Thanks! I'm slowly learning more about both MQTT and python scripting in Indigo. I've already queued up another project idea that I'm going to tackle in the coming weeks.

jay (support) wrote:
Not knowing anything about how that plugin works, I didn't chime in. However, for future reference in the scripting tutorial: Access a custom device state.


Thanks for that link, Jay. I had seen that page in the past, but didn't remember that's where I should look for information to solve this problem. I've saved that link because I'll be using it a lot going forward! :)

Posted on
Mon Feb 01, 2016 1:39 pm
bluenoise offline
Posts: 143
Joined: Aug 23, 2008

Re: MQTT Gateway Plugin

I have a feature request for this plugin:

I'd like the ability to optionally disable logging of MQTT events on specific devices. For example, my temperature sensors are flooding my Indigo log whenever there is a new reading.

In the short term, I could modify the plugin source to suppress this logging, but I thought others might like that feature, too.

Posted on
Tue Feb 02, 2016 3:35 am
jeremyjjr offline
Posts: 104
Joined: Sep 10, 2013
Location: St Albans, UK

Re: MQTT Gateway Plugin

Done. I've updated the plugin to v1.0.6 and added a new device property called 'Disable Topic Update'. When checked in the device config page, any updates from the queue will not be displayed in the log file.

Hope that helps.

J.

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

Re: MQTT Gateway Plugin

jeremyjjr wrote:
Done. I've updated the plugin to v1.0.6 and added a new device property called 'Disable Topic Update'. When checked in the device config page, any updates from the queue will not be displayed in the log file.

Hope that helps.

J.


Thank you so much for the awesome support, Jeremy!

I'm getting this in my log after the update and it stopped working. Everything looks correct in my device settings, so I'm stumped.

Code: Select all
  Started plugin "mqttGateway 1.0.6"
  Error                           device "Family Room Temperature" state key onOffState not defined (ignoring update request)
  Error                           device "Family Room Temperature" state key onOffState not defined (ignoring update request)
  Error                           device "Garage Door" state key onOffState not defined (ignoring update request)
  Error                           device "Garage Door" state key onOffState not defined (ignoring update request)
  Error                           device "Pool Temperature" state key onOffState not defined (ignoring update request)
  Error                           device "Pool Temperature" state key onOffState not defined (ignoring update request)

Posted on
Mon Feb 08, 2016 1:43 pm
rlust offline
Posts: 93
Joined: Jan 12, 2009
Location: Ohio

Re: MQTT Gateway Plugin

Since my update to 1.6 theMQTT gateway is not working. I also am getting error on startup.
Any ideas on this issue, and where can I get the previous version?

Thanks for your work and help!

Randy

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

Re: MQTT Gateway Plugin

Okay, so the 1.0.6 release had a couple of bugs in the code - apologies. I've moved things around a little and hopefully all should be working once you update to 1.0.7. Link at the top of the thread as usual.

Please let me know how you get on.

Jeremy.

Posted on
Tue Feb 09, 2016 8:52 am
rlust offline
Posts: 93
Joined: Jan 12, 2009
Location: Ohio

Re: MQTT Gateway Plugin

Thanks so much for all of your work Jeremy!
That fixed it!!!

Posted on
Tue Feb 09, 2016 9:48 am
bluenoise offline
Posts: 143
Joined: Aug 23, 2008

Re: MQTT Gateway Plugin

I just installed the update and it's working with my MQTT devices. I still get this when the plugin is restarted:

Code: Select all
  Started plugin "mqttGateway 1.0.7"
  Error                           device "Family Room Temperature" state key onOffState not defined (ignoring update request)
  Error                           device "Family Room Temperature" state key onOffState not defined (ignoring update request)
  Error                           device "Garage Door" state key onOffState not defined (ignoring update request)
  Error                           device "Garage Door" state key onOffState not defined (ignoring update request)
  Error                           device "Pool Temperature" state key onOffState not defined (ignoring update request)
  Error                           device "Pool Temperature" state key onOffState not defined (ignoring update request)


It does not seem to affect operation, so I'm not too concerned about it. It appears to be an error from Indigo and not the plugin itself as I didn't find that text in the plugin's code.

Posted on
Tue Feb 09, 2016 9:49 am
jeremyjjr offline
Posts: 104
Joined: Sep 10, 2013
Location: St Albans, UK

MQTT Gateway Plugin

If you edit the config of each device and click Save on the dialog without changing anything, does that remove the error?


Sent from my iPhone using Tapatalk

Posted on
Tue Feb 09, 2016 10:40 am
bluenoise offline
Posts: 143
Joined: Aug 23, 2008

Re: MQTT Gateway Plugin

I toggled the "On/Off State" checkbox on then off in each before hitting save, so I didn't make any change. I got this in the log for the temperature sensing devices:

Code: Select all
  Script Error                    embedded script: invalid literal for float(): test message
  Script Error                    Exception Traceback (most recent call shown last):

     embedded script, line 8, at top level
ValueError: invalid literal for float(): test message


When I tried it a second time, that error didn't happen. When I reloaded the plugin, I got the same errors mentioned previously regarding On/Off state key.

Posted on
Tue Feb 09, 2016 11:30 am
jeremyjjr offline
Posts: 104
Joined: Sep 10, 2013
Location: St Albans, UK

Re: MQTT Gateway Plugin

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.

Posted on
Tue Feb 09, 2016 4:25 pm
rlust offline
Posts: 93
Joined: Jan 12, 2009
Location: Ohio

Re: MQTT Gateway Plugin

Sorry to ask, but can I get a copy of 17,, 1.8 might have introduced some issues for me?

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

Who is online

Users browsing this forum: No registered users and 9 guests

cron