MQTT without writing more code?

From best I can tell, all of the apps/drivers require me to write additional code to handle my use case. I don't see option to send MQTT messages or listen for them in Rule Manager or similar. Is that true or am I missing something?

I am currently doing this with Node Red but would love to remove that step if it's a possibility:

I have 7 RF water sensors and 3 RF motion sensors. A Tasmotized Sonoff RF Bridge listens for alerts and publishes the device's hexadecimal ID to a MQTT topic. Node Red listens for that topic then converts that ID to a common device name and sends an HTTP Request to correct virtual device on HE. It also sends me a phone notification. It works great so I can't complain. Just curious if there is a better way.

Yes, you would need a driver to connect to the MQTT broker, subscribe to topics, parse incoming messages (from those topics), publish to a topic, etc. Rule Machine can't do this alone due to the fact that it needs to be a device/driver, not an app, though an app of some sort would usually work in companion with such a device. It would likely be possible for them to add this if they ever add a "standard" MQTT device type, but as of now, they're just providing methods for you to be able to do this on your own.

One user is working on an app (and driver) here whose goal is to be a full MQTT client for Hubitat: [Alpha] MQTT application (currently in a private alpha, but a public beta is likely coming soon). The idea behind this would be to publish events from Hubitat devices to MQTT or to manipulate virtual/MQTT devices in Hubitat in response to incoming MQTT messages--not just read the stream and react in an arbitrary fashion. However, someone could certainly write an app that does something similar without the need for the devices (the devices created from the MQTT subscriptions; you'll always need some "MQTT broker client" device per the above). Creating devices would let you work in a more Hubitat-like fashion and would let you use things from MQTT in other apps, so it's probably a better way to go unless you have a specific reason. If you share more about your use, perhaps others will have some ideas of how to make it work.

1 Like

What I am imagining is the following:

Create a Rule
Trigger: MQTT Message is published to a specific folder
Action: Series of If-then-else statements based on hexadecimal number in msg.payload
For example
If msg.payload = F6884E
Then change state of virtual device "Master Bathroom Moisture Sensor" to WET.
Else-if msg.payload = 9FAA13
Then change state of virtual device "Backyard Motion" to ACTIVE
and on and on for each device.

Definitely can't do that in Hubitat today. Hubitat works off of events generated on devices. No device=no event=no RM trigger.

Best bets would be to make an app/driver and parse the mqtt message there, triggering virtual switches. And then use the virtual switches in RM.

Or use node-red and do the mqtt parsing there, and trigger virtual switches in Hubitat via maker API. And then use the virtual switches in RM.

Yes, Node Red is working great fo rme. I just wasn't sure if I could simplify things and have HE do it instead of NR. I figured there wasn't yet unless i learned how to write groovy code. Thanks all for the info.