[EARLY BETA] Yet Another MQTT App (YAMA?)

I had this code sitting around for a while... It is somewhat preliminary, and likely not of any use to anyone for any reason versus the other 3 or 4 MQTT apps/clients already out there.

So why did I make this, then? My thought was that I wanted a SUPER SIMPLE MQTT app/client that would support any command/attribute (even custom ones) without any custom work needed by the end user (me!).

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).

With few features, the code is very light (~200 lines w/comments currently).

I only tested it against devices on my dev hub - so I fully expect many device 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

  1. Install driver code
  2. Create virtual device, use driver for type
  3. Enter MQTT broker info, save preferences

APP

  1. Install app code
  2. Install user app
  3. Select devices to publish to MQTT
  4. Select driver created above for the "MQTT Driver"

Initialization is throttled to 4 commands/attributes/sec (no throttling once init is complete). So if you add a ton of devices, each with a lot of commands/attributes it will take a while to initialize!!!!

Use -

  • All attributes should show up in MQTT topic structure: hubitat/hubname/device/attribute/value
  • Devices are controlled by publishing values to MQTT topic structure hubitat/hubname]/device/command/set
    Note 1: for commands that do not need parameters, you can publish anything as the value for the /set topic.
    Note 2: For commands that take multiple parameters, separate with comma

No guarantees of the quality of the code. It is ALPHA, and I'm not a professional programmer. Use at your own risk.

That said, it hasn't destroyed my dev hub, so there is that. :slight_smile:

Example of what it looks like on the MQTT side:
image

2 Likes

Known Issues:

  1. Driver does not always automatically reconnect / start the heartbeat after a hub reboot. Fixed in 0.0.2
  2. Debug logging doesn't turn off automatically. oops. Fixed in 0.0.2
  3. Probably some weirdness with subscriptions if the driver stops/restarts. Needs testing. Fixed in 0.0.3
  4. Unpredictable behavior when you add in the MQTT Driver itself device as a device to publish to MQTT. Don't do that for now.

Also, no guarantees that I won't change the MQTT topic structure in the future.

I have toyed with a few formats.

Right now it is:

  • hubitat/hub/device/attribute/value
  • hubitat/hub/device/command/set

Have also toyed with this to separate out attributes and commands:

  • hubitat/hub/device/attributes/attribute (no "/value" - just put value on the attribute itself)
  • hubitat/hub/device/commands/command (no "/set" - just put the command parameter on the command itself)

v0.0.2 posted. Fixed init on startup issues. Reduced init delays from 250ms to 150ms to get through init a little faster.

Both driver and app updated.

1 Like

Last work on this for now.

  • Survives hub reboots properly.
  • I've tested the app/driver with a few hundred virtual devices loaded in, and about 30 command changes/s (on virtual devices! don't expect that speed on a z radio!) with no issues on my dev hub. As stated before, it is beta and YMMV.
  • On init only /set topics are published. If you want to re-publish all attribute values (like on a node-red reboot or similar) you can hit the sendAll command on the driver, or set the MQTT topic /hubitat/hubname/sendAll to a non-blank value. Remember, it can take up to a few minutes to re-send all values if you have a lot of devices!
  • Raised init speed to 10 commands or attributes per second. Note that it can still take a long time to initialize if you are publishing a lot of devices, or have many devices with a ton of commands or attributes. Check the log - it logs begin and end of init and sendAll.

v0.0.3 posted. Changes to both driver and app.

Really the last update for today.

Updated app only to 0.0.4. Added logic to remove the MQTT Driver from the device publishing list if it was added by the user to avoid looping message issues.

Closed. App rebranded and moved to new topic.