[RELEASE] Hubitat MQTT Link

If you're looking for a simple to use and simple to configure solution for sending and receiving device updates via MQTT then check out Hubitat MQTT Link.

3 Likes

Very promising, this might help me intergrate with the openhab server that's used in the factory system on my RV....

That would be great. Let me know if you have questions with setting things up.

1 Like

Thankyou tpc77, the hubitat-mqtt-link software is excellent.

Im new to Home Assistant, Hubitat and MQTT, so it took me a while to work out how to connect them but here is a writeup which other newbies may find helpful...

My setup:
Hubitat v2.2.4.158
HomeAssistant v0.118.5
MQTT-Explorer v0.4.0-beta1
This is a guide to allow HomeAssistant (HA) to control Hubitat and assumes the above are already installed.

Hubitat setup:
Discover some devices or setup a virtual switch/sensor.
Create a new driver under 'Drivers Code', then paste in the device code from hubitat-mqtt-link/drivers at master · mydevbox/hubitat-mqtt-link · GitHub
Create a new app under 'Apps Code', then paste in the app code from hubitat-mqtt-link/apps at master · mydevbox/hubitat-mqtt-link · GitHub
Add a new virtual device under 'Devices' and specify type 'MQTT Link Driver', name it along the lines of MQTTDriver
Click on your new virtual device (MQTTDriver) under 'Devices' and configure the Preferences;
Specify MQTT Broker IP Address as the IP address of your HA
Specify MQTT Broker Port as 1883
Specify MQTT Broker Username as your admin login for HA
Specify MQTT Broker Password as your admin pswd for HA
Save details
Add a user app under 'Apps' and choose MQTT Link
Click 'Select devices' and choose devices you wish to access/control from HA. There is no need to select the virtual MQTTDriver you just created.
Click 'Notify this driver' and choose the virutal MQTTDriver you just created.
Click 'Next' and select the capabilities for each device, I suggest all of them. Note the MQTT topics are listed here for convenience.
Click 'Done'
You may need to restart Hubitat at this point.

MQTT
Before configuring HA, we need to know what topics are being sent from Hubitat, so start MQTT-Explorer that will show us this.
Add a connection;
Leave the defaults - 'validate certificate' checked, 'Encryption' unchecked and protocol 'mqtt://'
Specify host as the IP address of you HA
Specify port as 1883
Specify username as your admin login for HA
Specify password as your admin pswd for HA
Click connect
After a while, 'hubitat' should appear as a topic. Drill down into this tree eg 'hubitat/hubitat-hub-000d' and you should see your hubitat devices listed with values that update when something changes. We use this information in the HA configuration file later on.

Home Assistant setup:
Under 'Supervisor', goto Add-on Store and download 'File Editor', which will allow you to easily update the configuration.yaml file.
Check to show in sidebar and start it.
Under 'Supervisor', goto Add-on Store and download Mosquitto broker
Use the default configuration (there is no need to specify logins etc) and start it.
Under 'Configurations'>'Integrations', click 'Add Integration' and choose 'MQTT'
Click 'Re-configure MQTT';
Specify MQTT broker as the IP address of your HA
Specify MQTT port as 1883
Specify Username as your admin login for HA
Specify Password as your admin pswd for HA
Submit changes
Under followup Options screen;
Check 'Enable discovery'
Specify Birth message topic as your hubitat root topic eg 'hubitat/hubitat-hub-000d'
Specify Will message topic as your hubitat root topic eg 'hubitat/hubitat-hub-000d'
Submit changes.
You can use the MQTT Integration to confirm HA is recieving messages from Hubitat if you specify '#' as the wildcard topic to subscribe to and click 'Start Listening'.
Click the 'File editor' in the sidebar so we can modify the /config/configuration.yaml (pay attention to indents)
Specify a switch using your details from MQTTExplorer and this script as an example;
switch:

    • platform: mqtt*
  • name: MQTT_MyVirtualSwitch*

  • state_topic: hubitat/hubitat-hub-000d/myvirtualswitch-38/switch*

  • command_topic: hubitat/hubitat-hub-000d/myvirtualswitch-38/switch*

  • payload_on: "on"*

  • payload_off: "off"*

  • state_on: "on"*

  • state_off: "off"*

  • optimistic: false*

  • qos: 1*

  • retain: false*

    Specify a sensor using your details from MQTTExplorer and this script as an example;
    sensor:

    • platform: mqtt*
  • name: MQTT_MyVirtualTemperature*

  • state_topic: hubitat/hubitat-hub-000d/myvirtualtemperature-39/temperature*

  • device_class: temperature*

  • unit_of_measurement: °F*

  • qos: 0*

Save the changes and restart Home Assistant. The switches and sensors you define in the configuration.yaml will now be available as Entities which can be added to the dashboard.
4 Likes

UPDATE: Since writing this, v2.0 of MQTT Link is now available and I found there was a small change which stopped my switches working. After looking into it I discovered that the command topic from HA to Hubitat now needs to contain /cmd/ before the switch. ie command_topic: hubitat/hubitat-hub-000d/myvirtualswitch-38/cmd/switch*

Here is what it would look like in the configuration.yaml file;
switch:

  • platform: mqtt
    unique_id: mqtt_switch3a
    name: MQTT_VirtualSwitch
    state_topic: hubitat/hubitat-hub-000d/myvirtualswitch-38/switch
    command_topic: hubitat/hubitat-hub-000d/myvirtualswitch-38/cmd/switch
    payload_on: "on"
    payload_off: "off"
    state_on: "on"
    state_off: "off"
    optimistic: false
    qos: 1
    retain: false

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.