[RELEASE] Hubitat MQTT Link

I delete the info that I was using and redid the info on a different hub and I now have the same problem. I don't believe it's the hub or it shouldn't be. I can see the changes in the MQTT Explorer but it never send it to the hub?? Weird?

There is something odd going on. Looking at the debug log for the driver and checking the subscribe for the Switch and the Motion Sensor, shows this:

dev:1682021-01-16 17:33:06.274 debug[subscribe] full topic: hubitat/home-hub-000d/he-switch-02-200/switch
dev:1682021-01-16 17:33:06.272 debug[deviceSubscribe] topic: he-switch-02-200/switch attribute: he-switch-02-200

and

dev:1682021-01-16 17:33:06.226 debug[subscribe] full topic: hubitat/home-hub-000d/indigo-motion-02-169/motionSensor
dev:1682021-01-16 17:33:06.224 debug[deviceSubscribe] topic: indigo-motion-02-169/motionSensor attribute: indigo-motion-02-169

I think this could explain why the switch is working as the subscribed topic ends with switch which is what is published to MQTT. The Motion Sensor's subscribed topic ends with motionSensor which is not what is published to MQTT which is motion.

It is inconsistent and I suspect the wrong info is being used from the Capabilities table. However, I am not that au fait with Groovy so could be wrong. :slightly_smiling_face:

I create a flow in node red to turn on a light when the virtual motion sensor go active and off when when inactive? I try both ways and change the hub to active and then inactive and the light turn off and on? but when I try to change it from the node red side it work for a few seconds until the hub changes it back to what it has (hub has inactive). It sending it to the hub but the event is not holding/changing on the hub device for some reason and it's only so far on the Virtual Motion sensor only? Door sensor etc works. I work on it for a few hours and it beyond my knowledge level. Sorry. I'm going to get me a motion sensor and try it and I will let you know.

I when back and added an Inovelli Motion sensor and it work as it should with MQTT, Node Red and changes from MQTT Explorer. The virtual driver is another story and it failed. Wondering if the diver is missing something? it does seem funny that the other Virtual diver such as contact are working but not the motion? I don't think it has to do with the MQTT Link driver but the Virtual Motion Driver itself.

I have been doing a bit of digging around in the code for the App and Driver.

I think the issue is that any changes to a device that is defined in the App, is using the attribute as the last part of the topic e.g. motion. However, when the App subscribes to incoming MQTT messages it is using the type as the last part of the topic e.g. motionSensor. This is what is inconsistent. So if you publish a message to the App from MQTT Explorer with the last part of the topic set to motion it will be ignored as it hasn't been subscribed to.

I think the reason a virtual switch works is that the attribute and type are the same i.e. switch.

I have tried changing the code but I have never programmed in groovy before so it is definitely two steps forward and one step back at the moment. :wink:

It's a bit frustrating because if I could get virtual devices to publish updates and except incoming updates it would mean I could make use of Hubitat. I have managed to test setting up the Rules Engine to accept an update on a switch and set a motion sensor just to try it out but that seems like too much effort for little reward.

I shall probably take a break from looking at this for a while as I am definitely getting sidetracked. :grinning:

Just glancing at the code maybe Line 400?

I am afraid that is a bit too cryptic for me :slightly_smiling_face:
That line just says:

"motion" // ["inactive", "active"]

Looks like if you change that to “motionSensor” you may get the topic you were looking for. Might cause a problem on the HE side trying to match it back, but might be worth a shot to see.

I had all sorts of fun things like this when I was using mqtt link (before I made my own mqtt app/driver).

MQTT link works great for the most part, but "odd" devices throw it for a loop sometimes.

I when in and change the line 400 of the code to MotionSensor and it did nothing to help? Thanks

Sorry was worth a shot. If I get some time I’ll take a deeper look to see if I can figure out what it’s doing.

I appreciated the time and effort you took to help. Thanks

Hi guys, first of all thanks for this... i recently ditched my Smartthings for HE and I couldn't be happier. Regarding MQTT Link, I installed the driver and the App and both are working fine, I am trying to do some Temperature/Humidity Sensors with ESP8266 that publish the data to MQTT. I can see the data been published by my sensor to the MQTT Broker and MQTT Link App parsing the message:

[parse] Received MQTT message: [topic:hubitat/aurora-home-hub-000d/temperature-test-211/temperatureMeasurement, payload:72.9]

"temperature-test-211" is a Virtual Temperature Sensor Device, but even if MQTT Link is receiving the published message is not updating the sensor value.

My questions are: What am I doing wrong? Is this even possible? Do I need to create my own Temperature Sensor driver for this in HE? If that is the case somebody can point me to an example?

Thank you in advance for your help....

First off, great app and documentation. No issues getting hubitat reporting a few devices to my mqtt broker. That said does anyone know if there is way to publish the last update (think hubitat calls it last activity) time for a device? Example, for a temp sensor I want to public both the temp and last time hubitat got an update from that temp sensor.

Somewhat new to HE. Trying to use mqtt to update the value of a virtual temperature sensor. I must be missing something, I can't seem to get the value of the device attribute to update in HE. Is this even possible? I see the event being created, but I am missing on how to get the device attribute within HE to actually update. Do I need to create a rule or something?

Hi all. Sorry for the delay in addressing some of the issues reported here.

I just released a new version of the scripts that address a few items.

  1. The LWT message now goes out only once per full state refresh rather than after every attribute refresh. This will cut down significantly on the number of generated MQTT msgs.
  2. I found the bug that was preventing devices from subscribing to command topics. So, for example, if you have 10 bulbs configured, all 10 can be turned on/off now.
  3. The device state and device command mqtt topic are now distinct. The state topics will continue to report as they always have at hubutat/<hub>/<device>/<attribute> however, to control these devices you must add /cmd before the attribute like this hubitat/home-hub-000d/bulb-2-1154/cmd/switch with a payload of either on or off.

While going thru the code, I did discover and issue with some device types and their actions that will prevent those actions from being executed. For example, the colorControl action on RGB bulbs will not work in the current state nor will any other actions that have a list of attributes not matching the action name. I will work to address this next to ensure that all devices supported by HE can be controlled via MQTT msg.

Let me know how this new version works for you. Thanks for your patience!

I've installed the latest version, and I still have a general question on how it should work. Should I be able to publish to hubitat/stogitat-hub-xxxx/temp-mqtt-932/temperature from outside HE and expect the state value of the temperature attribute to update. I see MQTT Link publishing out updates to that device state. Right now if I publish to the same topic through MQTT explorer, nothing gets updated and I don't even see it in the logs.

Screen Shot 2021-02-16 at 7.02.52 PM

The only thing I can see being subscribed to in my broker(mosquitto) logs is the following topic:
Received SUBSCRIBE from hubitat_stogitat-hub-000d
hubitat_stogitat-hub-000d 1 hubitat/stogitat-hub-000d/temp-mqtt-932/cmd/temperatureMeasurement

And I can see it in the logs the broker publish to that topic when I update in mqtt explorer, and I can see mqtt link received that message, but nothing happens to the value of my device

I am a Home Assistant convert and have a decent handle on mqtt, but I am new to HE and not really sure what is supported and how to do it. I have tried several different apps, any help would be appreciated. I know in HA all I needed to do was create a sensor tied to the state topic and publish to it. Not sure what I am missing.

Hi Scott. You aren't missing anything. When I worked on this latest update, I discovered that the way the capabilities in the original code were set up makes it impossible to control some devices.

At the time that I first added the mqtt changes to the original code, I only had light bulbs and window sensors to test with. The sensors are output only so no issue there. And, the bulbs were simple on/off which happened to be one of the capabilities that works.

Since then, I've added some RGB zigbee bulbs which led me to discover that I could not set the color with the code as-is.

While looking thru the code to address that issue, I discovered the bug in the code that caused multiple devices from being controlled. So, I released this version right away to address that for those who are having a problem.

I am now working on making the adjustments to ensure that all device capabilities including setting thermostat Temps will work. I should have the update out in the near future.

2 Likes

Hello!

Novice here starting to play with MQTT. I have some switches (one specifically for this test) I've configured via Home Assistant and MQTT and it works perfectly there.

Given most of my devices are in Hubitat (Zigbee Sensors, lights thermostats etc.), I'd like to see if I can get these MQTT devices working in Hubitat to use automations with them!

I'm not entirely clear how a device is integrated with these drivers however.

I can see my device in MQTT Explorer, but how do I apply that to HE? Auto discovery allowed me direct control without any additional set up (i.e. see and control tele/Plug15/SENSOR)

My apologies for these basic questions :slight_smile:
Thanks!