[OLD] MQTT app beta1 and pre beta2 - please use beta3 thread

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.

This is OK - the homie topic structure is somewhat fixed and requires a number of payloads to be present for discovery to work.

You will have to use the second page 'Virtual MQTT Data' of the app and add virtual device(s) to take the payloads in from your devices. This is usable for any payload (except json formatted) but it's the more advanced of all the options. It is f) in the read me.

That should be fine.. it's two of my drivers that mustn't be installed at the same time as they would then use duplicate clientID's. If there is an issue then please create one on github. Concurrency in even a single driver is possible , and only a reboot will remedy that. The logs with duplicate messages would indicate to you that two concurrent threads might be running

I can see where some awkwardness might be coming from though, by it's nature an MQTT connection is essentially constantly running a 'parse' loop. Once running happily it's fine and so it's not so apparent to me with the app resident to pickup these new installation issues. At install I launch straight into this loop and so the 'save' does not complete as such. I could and probably should install to a disconnected state.

I'll remove completely and install on one of my other hubs on Sunday evening when I get back in.

Ok I've tried multiple times with complete deletes of driver and client and reboots in between. I'm getting the same install failure as ccoupe had above.

The add virtual device screen stalls at adding the virtual device, I waited longer than 10 minutes. But it does create the device.

If I try to complete the rest of the installation as per the instructions it never connects per the logs

dev:9362020-01-25 10:53:18.717 pm infoMQTT> MQTT connect failed attempt:[null], try again in 10 secs

dev:9362020-01-25 10:53:17.717 pm infoMQTT> Connecting as Hubitat_temporary to MQTT broker null

dev:9362020-01-25 10:53:17.714 pm infoMQTT> MQTT> client beta 1 initialising

dev:9382020-01-25 10:53:15.825 pm infoMQTT> MQTT connect failed attempt:[null], try again in 10 secs

dev:9382020-01-25 10:53:14.822 pm infoMQTT> Connecting as Hubitat_temporary to MQTT broker null

dev:9382020-01-25 10:53:14.820 pm infoMQTT> MQTT> client beta 1 initialising

app:8142020-01-25 10:53:14.284 pm infoMQTT: ================== Startup complete ==================

app:8142020-01-25 10:53:14.283 pm infoMQTT: [1] Total Hubitat endpoints enabled on MQTT

app:8142020-01-25 10:53:14.281 pm infoMQTT: [0] Total Hubitat devices are enabled on MQTT

app:8142020-01-25 10:53:14.215 pm infoMQTT: ==================================================

app:8142020-01-25 10:53:14.211 pm infoMQTT: Initialize exit

app:8142020-01-25 10:53:14.194 pm infoMQTT: Skipping homie MQTT discovery

app:8142020-01-25 10:53:14.190 pm infoMQTT: HE device publishing to MQTT has completed in 0 secs

app:8142020-01-25 10:53:14.135 pm infoMQTT: Resynch MQTT device states and HA discovery topics

app:8142020-01-25 10:53:13.933 pm infoMQTT: Starting HE device publishing to MQTT for 0 HE devices with 0 attributes

app:8142020-01-25 10:53:13.752 pm warnMQTT: All discovered devices forgotten

app:8142020-01-25 10:53:13.684 pm warnMQTT: All atomicState devices cleared

app:8142020-01-25 10:53:13.570 pm warnMQTT: Deleted all discovered child devices

dev:9362020-01-25 10:53:13.562 pm infoMQTT> Log Level set to 2

dev:9362020-01-25 10:53:13.560 pm warnMQTT> ## Restarted ##

Mike

Sucess story with Kevin's MQTT app, a free review from me

tagging @bravenel for sharing the good mood.

If you read my first post on HE, 5 months ago, I was looking for solutions.

I'm in Home-Automation since forever. And I have plenty of modbus (industrial) plc's in my home to control... everything but lights and motion. That's the reason I came for HE. And I'm happy of it

But I realize very quickly that HE supported devices were not including modbus devices :frowning:

5 months, adding sensors, lutron caseta (very nice choice for an old house), you know the usual story. Same for everybody.
2 concurrent home-automation systems running in parallel. Nice people here, friendly and ready to help. @cybrmage (thanks again) reprogrammed an existing (but non functional) app for my Venstar thermostat !

I learned a lot here, discovered node-red (but I'm not - for the moment - a Raspberry Pi guy) but was always stuck with my lonely devices.

And then Kevin came with his alpha MQTT App :slight_smile:

Of course, asked to be part of the alpha.
Since then, I was able to learn more about MQTT (mosquitto with 2 T's) and the way it works.
Now, with his help (he always replied quickly to my newbie requests) and Installed a running MQTT app that send data to HE, extracted from my [no more alone] devices !!!

I have now important data coming from my plc's (energy of my house and my geothermal unit, temperatures of coils, air blowers and water loops), no need to launch Internet Explorer (...) to see values from my plc's. And I can now deploy rules with values harvested from my hvac system.

Thank you again Kevin and enjoy your coffees !

5 Likes

I’m not at my PC now but it looks like you don’t have an IP address for your broker entered in the MQTT driver.

I just went through another complete remove and replace of the device/app/driver and now it connected.

Mike

If you read above you can see it could be an issue that I will take a look at tomorrow evening. The stall happens I think because I’m launching directly into a maintained loop connection. Everything saves OK though.

The app doesn’t pass the IP that is configured directly in the driver, but yours shows as null. It does pass the hub name however. Do you or have you had two drivers installed ? Make sure there is only one. I would also try a reboot and configure the driver again as maybe there are two instances running. The log says the broker address field Is null

image https://community.hubitat.com/uploads/default/original/3X/c/5/c5fb81ed2f1ddd6221c6f23536aa1c04a6fa9a86.png