[BETA] MQTT app

It's been a long wait but I have, at last, released my mqtt app as an open beta 1 this weekend. It's still evolving and although it won't win any coding awards it is pretty feature complete and stable I hope. It's been through 5 major alpha releases and numerous smaller updates with over a hundred alpha testers although feedback has been very limited saddeningly. For those in the smaller alpha testers groups - thank you so much for your feedback, it's been invaluable ..There maybe a few beta releases depending on feedback.

Please note this is currently under a pretty restricted 'personal' use only licence - please read before using and if it's not acceptable to you then don't download and install the app.

The purpose of the beta is to eek out the last bugs and refine the app itself in terms of presentation and usability. It's not presented as either final, feature complete or bug free, especially the UI and indeed there are known minor bugs and issues to work on. but I hope it will be useful already to a lot of people.

There will be three threads on this. This will be the main one related to the application itself and usage of and then there will be one related to OpenHAB (homie) and lastly one for Home Assistant (HA MQTT Discovery). Links are at the bottom of this post.

If you find definite bugs you can post them here but I would prefer them posted to the GitHub issues area as I'll notice and can manage them better there, discussing and closing when fixed.

The MQTT apps primary function is to link HE with MQTT in the most flexible and useful way possible. To do that it utilises the homie3 protocol (an MQTT topic structure) to provide status for and control of your inbuilt HE devices. This homie3 structure can also just be utilised in a 'simplified' form that is very easy to use, but then is not homie3 compliant. This is a very easy to understand presentation however for those just wanting MQTT linkage. You can also import arbitrary devices from MQTT into HE using any of the 24 Virtual HE drivers.

I support homie3 as both an advertising protocol and a discovery protocol meaning I can advertise HE devices for automatic discovery into other devices supporting homie3 like Athom's Homey controller or OpenHAB, and I can discover devices that advertise using homie3 and import those devices into HE. Please discuss homie discovery in the separate topic that I will set up and link to from here shortly, not in this topic which should remain HE centric.

I also support Home Assistant MQTT Discovery as an export advertising protocol from HE and also Home Assistant statestream as an import discovery into HE from Home Assistant. Devices are automatically discoverable and shareable between the two. This has proven the most popular usage of my application in the alpha test groups and so again there will be a separate topic that I will create and link to for discussion of Home Assistant integration. OpenHAB, Domoticz and a few others also support this protocol. Please don't discuss HA specific issues here, instead leaving this topic HE centric.

Please note that HA and OH integration come as a consequence of MQTT capabilities within HE. That is not the primary role of this app ,which is to provide the best possible feature set support for MQTT within HE both for basic and advanced users.

MQTT will be a new subject for many people. I am hoping that I can spend most of my time on improving the app and fixing any issues. As such I'm hoping that many people who are familiar with MQTT will step in and provide help for people just starting or having issues there. It would be much appreciated.

I also strongly recommend this application as your MQTT client - it's just a great app.

Links below

15 Likes

Here is the link to the beta 1 release.

Please respect the licence..

I promised to publish this over the weekend and so I am doing so despite being aware of one significant bug just reported which I am unable to replicate it. It maybe unique to the user, I'm hoping so.

It results in a long long string of device data being published to MQTT as a temperature value or a dim value. If you experience this please report it , ideally with steps to reproduce it.

app beta1a hotfix update posted - required if you are using HA statestream discovery into HE.
MQTT Client 1a hotfix for initial MQTT connection issues after new install.

beta 2 estimated mid Feb.

Sorry - being greedy and reserving a third space....

Looking to use this with zigbee2mqtt. Not using HA or openhab.

Mike

Hey @kevin I hope I have time to test this out soon. I have a new job with Inovelli now so I'll try as soon as I have time.

If this is bidirectional then I'm really interested. I've got OpenMQTTGateway feeding 9 Mi Flora into MQTT and it was time for me to start trying to force them into homebridge-mqttthing and then feed virtual objects into Hubitat hubs for me to see daily. This would save me a step and also mean I wouldn't have to get creative because HomeKit doesn't support soil fertility.

Then if that goes well I plan to add PM2.5, CO2, and VOC sensors to my ESP32 that would get loaded into MQTT also.

Jeneva

edit: To clarify I don't care if it's bidirectional I just want it to be able TO feed Hubitat and it looks like it may be a FROM. I don't need a FROM, just the TO.

It supports devices going either direction.

Oh I do.. and it is .. it’ll do all that you need I think

Interesting as HE is a very good as a ZigBee controller. Anyway I don’t support or use zigbee2mqtt specifically but that shouldn’t be a problem. I don’t know what device type identification there might be in their topics that might allow me to map devices into HE capabilities better. (Discovery). Perhaps one to look into for the future

Essentially just looking for a mqtt client to support a few devices that aren't supported directly by hubitat but are by zigbee2mqtt.

Not looking for you to support zigbee2mqtt.

I could put together a very rudimentry app but I don't want to waste time reinventing the wheel if your app does what I need.

Mike

I’m interested in how this might be useable currently. I don’t support json payloads (currently) and it looks like the /set command might use those. One for future expansion maybe.

Does it support advertising devices using the HomeAssistant discovery protocol - is that how it links with HA (I know you don’t use HA) ?

Always happy for pull requests...

I’ve got one potentially significant bug just been reported overnight in the alpha testers group. It’s one I need to fix but on it at the moment.

Now trying to contact the reportee as I can't reproduce it...but in different time zones probably.

The user isn't readily available this weekend and so I have published beta 1 anyway - have a play and let me know how you get on.

beta 1 is released. Details here..

I'm around this weekend although absent tomorrow (Sunday) between 1pm and 8pm GMT . I'll check in as soon as I get back though for any problems..

There's three topics for feedback / issues - this one for the HE app and two others .. one for HomeAssistant issues and one for homie (OpenHAB / Homey)

Enjoy..

2 Likes

AWESOME!!!! Great work to all involved!

How do I delete the MQTT APP?
No matter how I setup the MQTT Client it seems to never finish after Save Device is pressed. But enough is setup to connect the APP (this was a mistake on my part). Now my log is filled with
indent preformatted text by 4 spaces
dev:4492020-01-25 16:24:03.512 infoMQTT> MQTT connect failed attempt:[null], try again in 10 secs
dev:4492020-01-25 16:24:02.491 infoMQTT> Connecting as Hubitat_temporary to MQTT broker null
dev:4492020-01-25 16:24:02.482 infoMQTT> MQTT> client beta 1 initialising
dev:4522020-01-25 16:24:00.111 errorjava.lang.NullPointerException: Cannot invoke method next() on null object on line 319 (heartbeat)
dev:4522020-01-25 16:24:00.096 debugMQTT> Tx: heartbeat [null] none
`
I can't find a way to Delete the app.

I did find a way to delete the App and the Driver but it was still logging the failures. I had to reboot in order to get that running 'object' out of the system. I do have a running MQTT system but it's not homie or HA compatible. I don't require username/password could that be part of the problem connecting?

This was actually raised before by someone else and I sort of ignored the issue as they then got it working fine.

What I now think is happening is that the driver is intelligent and continually manages its own connection to the MQTT broker, reconnecting as needed. I can see in the logs that your broker connection was failing , perhaps the credentials or address details weren’t quite correct ? Hence it didn’t complete installation / connection.

Please make sure there is only one MQTT driver installed and that it is configured and has connected succesfully to the MQTT broker. It will continue to manage that connection in the background and yes you will see persistent log messages. Restarting might be the best way to remove it should you want to - by selecting the device you created and clicking delete and restarting.

I’ll revisit this in the device drivers code so that it doesn’t initially try that connection until the app tells it to and handles removal better.

Yours is not failing because of you not using HA or homie, once the broker credentials are correct in the configuration it will connect just fine. It looks like the MQTT broker IP address or port might be wrong or not filled in. You configured those... yes ?

Let me look at that null error in the heartbeat too.

Parts of your scheme did connect successfully - way to many error messages to
include that detail. So, that part was configured correctly.

I've got 5 motion sensors and 2 UPS talking to 4 hubitat mgtt drivers that I wrote and they all work fine but they don't have a topic and command structure like you are using. I'll try to migrate one of them again to your app/driver and study your code more deeply.

Please do ensure that only one MQTT driver is installed. Two will cause problems currently as they will alternately kick each other off the broker and interact with the app.

Does your one driver now show that it has a normHubName that matches you HE and also connected true ?

image

It should also have presence : present in it's attributes (it acts as a presence sensor when connected)

image

If so you're good to go.

I'm being overly aggressive with the driver which is very persistent at maintaining the broker connection. This was to combat problems people had with poor MQTT connections people had in their own setups. I'll look at backing that off a bit and having a 'disconnect' command available too. I won't be able to look at that for a day or so though as it's after 3am here now and I have unfortunately to be out for lunch tomorrow.

You should also see a heartbeat payload in your broker incrementng away every 20 seconds

image

My existing MQTT drivers use
``mqttbroker = "tcp://" + settings?.MQTTBroker + ":1883"
mqttInt.connect(mqttbroker, "hubitat_${device}", settings?.username,settings?.password)
and yours uses
mqttInt.connect(settings?.MQTTBroker, "Hubitat_${state.normHubName}", settings?.username,settings?.password, lastWillTopic: "Hubitat/${state.normHubName}/LWT", lastWillQos: 0, lastWillMessage: "I died")

They should not be conflicting because they use different client names. I'll file a github issue when I try again, assuming I still have an issue.