MQTT - How can I control devices on openHAB via Home Assistant?

Have used openHAB for a number of years to control lights around my house and have them integrated with Alexa via HUE Emulation. (Great for those with mobility issues.)

Recently I had an HVAC issue which resulted in the purchase of new thermostats (Honeywell T6 Pro z-wave) had difficulty integrating with openHAB so I took a look at Home Assistant (HA).

It seems that to get the best of both worlds I will need to run both openHAB and HA.

I would like to control the devices associated with openHAB through the HA interface. It seems that MQTT is the likely solution.

Rather then reinventing the wheel I am looking for a simple step by step instructions or to be guided by a learned sage.

I have read a number posts and have set up mosquitto on both openHAB and HA.

On openHAB have set up mqtt thing, channels and have linked devices to them.

At this point I am unclear how to communicate between openHAB and HA or if I should have mosquitto on openHAB and both openHAB and HA publish and subscribe to it.

Thanks for the fast reply @hafniumzinc .

Went to Settings → Add-ons → Automation → BLUE + and only two automation were available.

I am running openHAB 3.0.2

I don’t have that in mine. Within the Automation area, there’s a subsection called Rule Templates - some of the MQTT Event Bus stuff is there.

Or just use the search icon bottom right from any Add-ons section

The Marketplace wasn’t introduced until June of 2021 which puts it past OH 3.0. You’ll need to upgrade to at least 3.2 (I think) though you may as well upgrade to 3.4.

Yep… after a re-read I discovered I need 3.2 or newer. I will need to make a updated clone of my openHAB before I update to a newer version of openHAB.

Going to read over the information you provided a few times before I “experiment” anymore.

I do have one other questions.

From a command line on HA I am attempting to turn on light on openHAB with the following command:

mosquitto_pub -h -t homeassistant/switch/nook_entrance/cmd -m “1” -p 1883

and on openHAB I have the following set for the Nook Entrace Light

From the openHAB mosquitto log file the message is being received but I must not be sending to the correct TOPIC and/or the correct MESSAGE.

Any guidance?

Post the full Thing config. Open the “code” tab and copy the YAML you find there and paste it into a reply. Use code fences.

code goes here

Screen shots are hard to read and leave a lot of context out.

UID: mqtt:topic:250138eec7:be3054190d
label: Generic MQTT Thing
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:250138eec7
  - id: nook_entrance
    channelTypeUID: mqtt:switch
    label: light
    description: ""
      commandTopic: homeassistant/switch/nook_entrance/cmd
      postCommand: true
      retained: true
      qos: 1
      stateTopic: homeassistant/switch/nook_entrance/state
  - id: garage_entrance
    channelTypeUID: mqtt:switch
    label: Garage Entrance Light
    description: ""
      commandTopic: homeassistant/switch/garage_entrance/cmd
      stateTopic: homeassistant/switch/garage_entrance/state

I’m no expert, but if you are sending state from HA to:

I don’t think your linked item (you don’t show that but I assume it is there) will change. Try sending to:


That is the subscribed topic.

  • Also, take a look at HA MQTT Statestream. Automatically sends all HA activity to MQTT in prescribed format (you can filter what you want or don’t want).

  • Download MQTT Explorer

To elaborate a bit on @kjknauss answer, The topic you put for the “State Topic” on the MQTT Thing is the topic that OH subscribes to. “Command Topic” is the topic that OH publishes to. You are sending a message to the cmd topic so of course OH won’t receive anything.

KJ and @rlkoshak I downloaded the MQTT Explorer and I am able to issues MQTT statements that turn the light on and off but I still cannot from the command line of Home Assistant.

Anything I should be look at within the Explorer app with regards to additional setting or info that it might be sending to the MQTT host?

FYI I tried the same TOPIC on the command line but no such luck.

Pedantry: the mosquitto_pub command you show is one bundled with your Mosquitto MQTT broker. When you say ‘the command line of Home Assistant’ do you just mean ‘from the device running Home Assistant’?

This is a good question. We may be leaking into a HA configuration discussion on an OH forum. Are you looking to control an OH integrated light with an HA UI? I run both OH and HA to integrate some equipment (HVAC and Fans) where there wasn’t an existing OH binding. But I never originate actions from HA. Perhaps you are just testing, but from your original post you had been using OH for years, so keep it that way and control from OH, but use HA to handle the few items that aren’t available in OH.

This is the opposite of what I am suggesting, I know. But if you an experienced OH user, do the opposite (unless of course you really like the HA UI).

To control devices the way you want, you will have to look into the concept of what HA calls helper items (i.e., similar to a proxy item in OH).

Also, are you able to control the Honeywell thermostat with HA?

I don’t know anything about Home Assistant but I do know openHAB. And what I know, based on what you’ve shown so far, is that your publish command is to the topic you’ve configure openHAB to only publish to. OH will never see any messages sent to that topic. If you want OH to see it, you have to publish to the State Topic. That’s the only topic OH subscribes to.

If you want that message to be sent to the linked Item as a command, there’s a checkbox on the Channel config to treat state updates as commands.

But unless you’ve changed your config since posting above, the only messages OH will see are those published to homeassistant/switch/garage_entrance/state

I would suggest that you need to decide to use either OpenHAB or HomeAssistant for your automation system. I’ve used both system, they each have their pros and cons. If you’re planning to run the two systems simultaneously I think you’re going to make maintaining the systems challenging. You’ll have twice of everything to maintain and learn, from versions, upgrades, different programming styles, etc., and you’ll be asking questions on multiple forums; OpenHAB on this one and HA on another.

With the openHAB custom integration for Home Assistant you are able to use almost all openHAB items without MQTT.

Unfortunately it is a “WORK IN PROGRESS”.

I tried the integration but unfortunately it does not support dimmer switches and the switch toggles do not update or stay synced the physical switches without the constant reloading of the integration.

Have made progress controlling devices on openHAB via HA UI input booleans and automations.

Now need to figure out how to keep the input booleans in sync with the physical switches and when they are controlled via openHAB.

It would be nice if one size fits all but it seldom does.

I mean I can use a trash bag as a raincoat but it sure doesn’t look good.

It is likely both communities would grow more if there was greater interoperability between the two platforms.

In my experience this will be another automation. My solution looks like this (for a thermostat):

When changed in OH UI/sitemap

OH channel cmd topic→MQTT broker→HA automation (change temp from payload)→thermostat

or Changed at thermostat

thermostat→HA publish changes via Statestream→MQTT broker→OH channel state topic/linked item

Also Changed in HA UI works (I don’t control from HA though)

HA changes thermostat and publishes changes via Statestream→MQTT broker→OH channel state topic/linked item→(now goes back) OH channel cmd topic→MQTT broker→HA automation (change temp from payload, which does nothing based on conditions in the automation since the thermostat temp already equals the payload).

Everything stays in sync, including state and cmd topics (you can watch in MQTT Explorer).