WHAT IS IT:
I wanted to make a SUPER SIMPLE MQTT client app/driver that would support publishing any Hubitat device with any command/attribute (even custom ones) to MQTT without any custom work needed by the end user.
This app only allows you to select Hubitat devices to publish to MQTT.
- You can not select specific commands/attributes - it is all or none on a device basis (on purpose).
- You can not control which commands on a device are controllable via MQTT - it is all or none on a device basis (on purpose).
Keep this in mind for perimeter security devices like locks and garage door openers!!!!
With a very specific goal in mind, and less optionality, the code is very small and light.
I run this on my dev and production hubs (80+ devices each) with no issue. That said, it is marked as a BETA for a reason, and I fully expect some device/attribute/command types I haven't tested may throw errors/break it.
All of that said, if you want to try it a link to the code is below. I'm open to error/bug reports, but as a side project issues may not get fixed immediately.
DRIVER
- Install driver code
- Create virtual device, specify YAMA driver for the type then click SAVE DEVICE.
- Edit this new device, entering MQTT broker info and then click SAVE PREFERENCES
APP
- Install user app code
- Create new user app (of type YAMA of course)
- Edit the app and select driver created above for the "MQTT Driver" entry
- Then select the devices you want to publish to MQTT in the next selection box
- Click Save and the app will start populating the MQTT data on the broker, and subscribe to the command topics
Initialization is throttled (no throttling once init is complete). So if you add a ton of devices, each with a lot of commands/attributes then it will take a while to initialize!!!! On my production hubs it takes ~90 seconds for the app to complete initialization.
Use -
-
All attribute values should show up, and automatically update, in the MQTT topic structure:
- hubitat/[hubname]/[device name]/[attribute name]/value
-
All commands on devices are controlled by publishing values to the MQTT topic structure:
- hubitat/[hubname]/[device name]/[command name]/set
Note 1: For commands that do not need parameters (like 'on' and 'off'), you can publish anything as the value for the /set topic (the value is ignored by the app).
Note 2: For commands that take multiple parameters, separate the parameters with a comma (like 80, 25)
- hubitat/[hubname]/[device name]/[command name]/set
No guarantees of the quality of the code. It is BETA, and I'm not a professional programmer. Use at your own risk.
That said, it hasn't destroyed my dev or production hubs, so there is that.
CODE:
Driver setup screen. Yup, that's all of it:
App setup screen. Yup, that's all of it:
Example of what it looks like on the MQTT side via the MQTT Explorer app: