I have a simple mosquitto MQTT broker running on my LAN (no SSL, anonymous auth) with various values available and would like to subscribe to a couple of topic values to use and display in Hubitat virtual devices like temperature sensors or contact switches. No need to publish, just subscribe to the value and use it in rules.
It seems like this should be easy but I can't find the right package or driver.
Several packages appear in the forums over the years but there is a lot of deprecated stuff.
Looks nice but seems to be for publishing from Hubitat, not subscribing
I tried for a couple of hours to get the 4 year old beta 3d working but every time I click 'Add User App' to install my Apps tab stops responding and I have to reboot to get it back. Then the app is not there even though the log said it was installed before the reboot.
Can someone please point me in the right direction to do this?
You do have to write a hubitat driver or otherwise acquire one. Especially for subscribing to a topic. As drivers go, MQTT is pretty simple. What device type do you want to deal with?
I have some temperatures and contact sensors published into MQTT, some from 1-wire devices and some from a modbus interface to my furnace.
All of the values are easily accessible in topics, I just need to connect to the mosquitto broker and subscribe the virtual device to to the topic to display the value or contact sensor state.
Here is the link to my repo of drivers. The mqtt-virtual-switch.groovy is the simplest - the others are pretty specific to the devices I wanted to connect so the use case may not be apparent - contact me off forum if you like.
@ccoupe your mqtt-listen-switch.groovy was the perfect starting point for me as my goal was a simple subscription to contact and temperature sensor topics.
I made a couple of modifications to accept temperatures, handle my contact topic values of 0|1 and needed to change the contact value attribute from "close" to "closed" on line 90.