[RELEASE] Hubitat MQTT Link

Creating a device was the missing step for me, everything else fell into place perfectly, I can see the devices in MQTT Explorer and Hubitat! Thank you @tpc77!!

I looks through the thread/documentation and didn't find anything, apologies if I missed it, but how do I provide variables to the actions in the message? I'd like to set up a single virtual button with a bunch of buttons. I've assigned it the pushableButton action. I've tried variations of making the message things like push(1), push 1, etc... but haven't gotten them to work. I have a different MQTT virtual switch working and am able to toggle it via MQTT.

Thanks for any help!

edit:

After posting this I dug into the code a bit and figured out that the pushableButton doesn't have an action, so I guess this is turned into a feature request. :slight_smile:

I think I hacked something together, but I don't quite get the separation between capability name, the capability attribute and the list of attributes in the capability. It looks like some of them like samsungTV have different methods that take values but I don't quite get how it does that, so I ended up with adding pushableButton as an attribute and parsing push(#) off of the message. Probably a better way to do it though.

@tpc77,

After a lot of sweat (and cursing) I have a eclipse-mosquitto broker working as a docker container and I can't wait to use your MQTT Link. However, when I tried to install it using HPM, but nothing shows.

Sorry to ask, but did you asked to include your "repository.json" file to the main HPM repository?

In case anyone is getting stuck setting this up, as I was. It does still work but there have been changes to the code that don't seem to be reflected in the documentation on github like the topic for control needs to include "cmd" in the path.

I managed to get it configured to use the HA message broker and the devices to show up in HA with manual configuration. Ideally I'd like auto discover to work but this is a good start. It looks like its working both ways and I've also got some sensors working.

Here is an example of the configuration.yaml for mapping a hubitat switch in HA to help others.

switch:
  - platform: mqtt
    unique_id: "testswitch-232"
    name: "Hubitat Test Switch"
    state_topic: "hubitat/myhubname-000d/testswitch-232/switch"
    command_topic: "hubitat/myhubname-000d/testswitch-232/cmd/switch"
    payload_on: "on"
    payload_off: "off"
    state_on: "on"
    state_off: "off"
    optimistic: false
    qos: 0
    retain: true
2 Likes

Has anyone used this with Sonoff ZbBridge with Tasmota? is there a way to do it? if so, please help me.

If you use Discord, go to DigiBlurDIY channel. Lots of smart people there. Heavy into MQTT, tasmota, NodeRed and HomeAssistant. Very friendly and ready to help.

It's been awhile since I've posted anything here. The reason is that I have jumped the Hubitat ship and am now 100% on Home Assistant.

I no longer have the need for MQTTLink as I no longer run the HE hub. I did however, come across someone on Reddit who uses MQTTLink and has an interest in maintaining it going forward. I will be handing things off to him for all future updates and support.

1 Like

hi,
How to use Mqtt with Shelly devices and Hubitat?
I have a Shelly flood and H&T .
thanks in advanced.

I'm trying to integrate an HE with an HA using this app. I have everything configured, and here's what I've got:

  • HE publishes events to MQTT (e.g., I trigger a switch in HE): These events are visible in both HA and MQTT Explorer.
  • HA publishes events to MQTT: These events are visible in both HA and MQTT Explorer, but not to HE.
  • MQTT Explorer publishes events to MQTT: These events are visible in both HA and MQTT Explorer, but not to HE.

It feels like I'm missing a step in the config somewhere, but I've been through the config several times without determining what.

I missed the part about needing to use the /cmd when posting an event from HA or MQTT Explorer. Everything is working as expected now, except that I've got to echo that autodiscovery would be nice.

hey floks,
if i want to use Shelly / Hubitat MQTT, do i need additional hardware to act as a MQTT broker (like Node Red) to work in between?

I know that Shelly devices have a buid in MQTT in thier web server.

Yes, you will need an MQTT broker. That sometimes requires extra hardware if you plan to run it yourself. There are some cloud based brokers you could look into like ada fruit or hivemq.

1 Like

thanks :slightly_smiling_face: :+1:

Is therte a tutorial? im using MQTT link driver and app in hubitat... i dont know hwat else to do, already set them up, why isnt there a tutorial to get it working with something... comunicating with something, doing anything, why is this so complicated... i got my mosquitto broker... so then what??? omg

Aight, it seems that publishing from mqtt Explorer directly to hubitat doesn't work, I dont know if it has to do with the way Explorer sends data or whatnot, because I was not able to communicate from Explorer to any device in hubitat mqtt link. But then I downloaded an app for my phone called iotMQTTpanel and managed to configure some switches and now they are working... still have to test some more

I've just started using MQTT Link and I'm able to turn on/off a virtual switch in HE, but I can't set a virtual Presence Sensor to present or not present. Here's what I have for my virtual switch (which works):

mosquitto_pub -h 192.168.50.128 -t "hubitat/home-hub-000d/test-switch-71/cmd/switch" -m "on"

and here's what I have for my virtual presence sensor (doesn't work):

mosquitto_pub -h 192.168.50.128 -t "hubitat/home-hub-000d/car-in-garage-899/cmd/presenceSensor" -m "present"

Any tips on how to get my virtual presence sensor to work via MQTT?

Thanks.

@ktd, did you ever manage to get this working, I'm trying to do exactly this with a Shelly Plus 1PM

For Shelly Gen2 (including Shelly Plus 1PM) there is another driver with instant event propagation/reporting as an option (uses websocket stream connection instead of mqtt). Shelly Device Handlers for Hubitat - #442 by dmitry.rozovik

1 Like

Thanks for the info!

I'm trying to make my Honeywell T6 Pro z-wave thermostat to communicate with MQTT broker. HE publish all checked thermostat capabilities, but I couldn't control them from the broker. Unfortunately I have no experience with groovy or any computer programing language, only with plc (programmable logic controllers, basic and ladder logic). I started looking into groovy learning on line, just to find out which sections of mqtt driver and app are responsible for each action. After couple of weeks I have found most of the mistakes (mostly in Capability_Map description of devices and action sections) , but now I got stuck and looking for some advice from one of you that has groovy experience.
Below I pasted the part of MQTT Link section that is receiving mqtt event from the broker and sends the action request to action section of the script. This is specifically to change thermostat mode to "heat"

// Receive an inbound event from the MQTT Link Driver
def mqttLinkHandler(evt) {
def json = new JsonSlurper().parseText(evt.value)
debug("[a:mqttLinkHandler] Received inbound device event from MQTT Link Driver: ${json}")

if (json.type == "notify") {
	sendNotificationEvent("${json.value}")
	return
} else if (json.type == "modes") {
	actionModes(json.value)
	return
} else if (json.type == "routines") {
	actionRoutines(json.value)
	return
}

def attribute = json.type
def capability = CAPABILITY_MAP[attribute]
def normalizedId = json.device.toString()
def deviceName = state.selectedLookup[normalizedId]

def selectedDevice = settings.selectedDevices.find { 
    device -> (device.displayName == deviceName)
}

if (selectedDevice && settings[normalizedId] && capability["attributes"].contains(attribute)) {
    if (capability.containsKey("action")) {
        def action = capability["action"]
        json['action'] = action
        debug("[a:mqttLinkHandler] MQTT incoming target action: ${json}")
        // Yes, this is calling the method dynamically
        "$action"(selectedDevice, attribute, json.value)
    }
}

}

def actionThermostatMode(device, attribute, value) {
debug("[a:Action Thermostat Mode] ${value}")
switch (value) {
case "auto":
device.auto()
break
case "cool":
device.cool()
break
case "emergencyHeat":
device.emergencyHeat()
break
case "heat":
device.heat()
break
case "off":
device.off()
break
case "setThermostatMode":
device.setThermostatMode(value)
break
}
}

I added debug line to make sure app executes all the way to action section. It does. You can see in logs below.

[a:Action Thermostat Mode] heat
[a:mqttLinkHandler] MQTT incoming target action: [device:tstat-1st-137, type:thermostatMode, value:heat , action:actionThermostatMode]
[a:mqttLinkHandler] Received inbound device event from MQTT Link Driver: [device:tstat-1st-137, type:thermostatMode, value:heat ]

Everything, all the way to last log, works but the app doesn't recognize "value" (which is heat, last log) as "heat" in switch/case routing. When I replace word value with "heat" it executes fine, so value == "heat" is not true. I tried to convert value to String, Integer, Character and nothing worked.
Maybe one of you would know how to make value == "heat"