Beginner, guidance needed for mqtt.home assistant binding

  • Platform information:
    • Hardware: Synology Docker
    • openHAB version: 3.3.0

Hi , i’new for Openhab, but using Home Assistant for several years, i have an MQTT server configured, there are some entities in HA being auto discovered
Now i have setup Openhab on docker , configured with host mode, and make sure the correct lan adapter is setup in Openhab

So installed an MQTT broker in HA, its in online state
if i do a “scan” here, shouldnt it not find the entities ? the audo discovery is turned on in the broker setting:

If not possible to find the entities by autodiscover, i created an mqtt thing manually:

above screenshot with channel is being created automaticly
Now what? what do i have todo now to get it on the UI? i think i need to click on “add equipment to model” , but then i get error below? why cant i select the channel being created in above screenshot?

i’m stuck here , not sure what the next steps are, or why autodiscovery is not working

thnx for the advice

How many brokers have you got running now?

I have 2 brokers running

the mqtt server is running on HA , and then 2 brokers, one in HA and one in Openhab

in openhab i creater a broker and selected the IP of the running mqtt server in HA, inputted the correct authorization, and i see it online

when adding manually the mqtt.homeassistant , i can then select the online broker

ok, i had a look in log files

for the discover part, seems openhab is finding sensors and stuff, but they give invalid config

2022-07-04 13:19:46.566 [WARN ] [nal.discovery.HomeAssistantDiscovery] - HomeAssistant discover error: invalid configuration of thing 1 component binary_sensor: Cannot parse channel configuration JSON
2022-07-04 13:19:46.566 [WARN ] [nal.discovery.HomeAssistantDiscovery] - HomeAssistant discover error: invalid configuration of thing 1-bypass component switch: Cannot parse channel configuration JSON

for the light i entered manually in openhab, when i turn it on, seems i see it in the log
now how do i add that manually added mqtt light to the UI?

2022-07-04 17:02:27.657 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command '{"state": "ON", "color_mode": "onoff"}' from channel 'mqtt:homeassistant:2693a81a59:mqtt_5Flight_2Ebadkamer#light' not supported by type 'ColorValue': {"state": "ON", "color_mode": "onoff"} is not a valid string syntax

It sounds like you have one broker, which is just as it should be.
The ‘broker Bridge Thing’ in openHAB is just a pointer to some external MQTT service, where openHAB can subscribe to MQTT topics.

Okay, so the link to broker is good.

Are these devices actually sending messages in HomeAssistant self-identifying format?

Yes, these entities are being discovered in HA without an issue…

If discovery doesn’t work I can live with that, how to proceed manually? I’m also stuck here… See my first post, not sure what I need to do with the channel/model part

I think you should study the concepts of Thing, channels and items first (this is a different concept than Home assistant uses as far as I know)

In brief. Example: You have a Philips Hue lamp.
To use these you need the Philips Hue binding to make Openhab and Hue speak the same language.

then you create a Thing (or it is automatically detected) this is a virtual representation of the physical lamp within Openhab
This lamp has an on and off function and a dimmer function, which we call Channels. So the Thing has a dimmer and an on-off (switch) channel.

To display a Channel on a UI you need to create an Item associated with Channel.

An item has a type, name, label, etc.
For example, a type can be a switch, color or player.

This might be confusing at first, but it’s all well documented

Configuration | openHAB

Ok need a look at the docs again indeed, channels is confusing indeed…
I try again next time

Hey @micware , i’m back from vacation, want to start working on it again, but still stuckj on channels
Openhab found a lot of mqtt lights and i see them all in inbox (44 items)
I added one as a test from inbox, looks like:

Next, added a model (groundfloor) , but now i’m stuck
when i “create equipment from thing” or "create points from thing’, i always get error…
What am i missing?

extra, if i click on the cofigure channel that was added by auto discovery, i see this
so all looks fine to me?

is there any error message in the openhab.log file ?

this error, was from wrong place, irrelevant
but i tested again, went to inbox and added the thing, see screens from the thing created:


UID: mqtt:homeassistant_mqtt_5Flight_2Ewasplaats:e94f1500bd:mqtt_5Flight_2Ewasplaats
label: Wasplaats (Light)
thingTypeUID: mqtt:homeassistant_mqtt_5Flight_2Ewasplaats
    - light/wasplaats
  basetopic: homeassistant
bridgeUID: mqtt:broker:e94f1500bd

Next, i go to add model =>

but i’m unable to select the channel it seems?

What i do see in log, when i goto model => create points from thing, i see this in log:

2022-07-26 17:44:47.491 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command '{"state": "OFF"}' from channel 'mqtt:homeassistant_mqtt_5Flight_2Ewasplaats:e94f1500bd:mqtt_5Flight_2Ewasplaats:mqtt_5Flight_2Ewasplaats#light' not supported by type 'ColorValue': {"state": "OFF"} is not a valid string syntax
2022-07-26 17:47:02.634 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command '{"state": "OFF"}' from channel 'mqtt:homeassistant_mqtt_5Flight_2Ewasplaats:e94f1500bd:mqtt_5Flight_2Ewasplaats:mqtt_5Flight_2Ewasplaats#light' not supported by type 'ColorValue': {"state": "OFF"} is not a valid string syntax
2022-07-26 17:50:24.625 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command '{"state": "OFF"}' from channel 'mqtt:homeassistant_mqtt_5Flight_2Ewasplaats:e94f1500bd:mqtt_5Flight_2Ewasplaats:mqtt_5Flight_2Ewasplaats#light' not supported by type 'ColorValue': {"state": "OFF"} is not a valid string syntax

seems its indeed related to colorvalue, i now added a thing from inbox, like a switch instead of light, without colorvalue, that seems to work without an issue

so its related indeed to colorvalue, but how to fix?

I think you need to look at the channel configuration (YAML part) of the thing that is not working.

From the error message I conclude that he wants to send an on-off command but color is expected

below you see an example of one of my MQTT things (a lamp)

There is a switch channel (for on/off)
There is a Dimmer channel
There is a color temperature channel

for a switch channel you create a switch item that you can display and control via a UI and for the dimmer channel and dimmer item

in my example you see channelTypeUID: mqtt:switch because it points to a commandTopic (MQTT) that accepts an on or off command. If I make this a channelTypeUID of “Color” you probably get an error.

UID: mqtt:topic:xxxxxxx:huiskamer_kabinet_lamp_links
label: Huiskamer kabinet lamp links
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:xxxxxxx
location: "Huiskamer "
  - id: state
    channelTypeUID: mqtt:switch
    label: bedlamp aan/uit
    description: null
      commandTopic: zigbee/huiskamer_kabinet_links/set/state
      stateTopic: zigbee/huiskamer_kabinet_links/state
      off: OFF
      on: ON
  - id: dimmer
    channelTypeUID: mqtt:dimmer
    label: Dimmer
    description: null
      commandTopic: zigbee/huiskamer_kabinet_links/set/brightness
      min: 0
      stateTopic: zigbee/huiskamer_kabinet_links/brightness
      max: 255
  - id: Color_temperature
    channelTypeUID: mqtt:dimmer
    label: Dimmer
    description: null
      commandTopic: zigbee/huiskamer_kabinet_links/set/color_temp
      min: 150
      stateTopic: zigbee/huiskamer_kabinet_links/color_temp
      max: 500
  - id: effect
    channelTypeUID: mqtt:string
    label: Dimmer
    description: null
      commandTopic: zigbee/huiskamer_kabinet_links/set/effect
      stateTopic: zigbee/huiskamer_kabinet_links/effect

I made all my mqtt things by hand.

I’m not an expert in this area, hopefully someone will correct me if I’m explaining it all wrong :wink:

I am now experimenting with Home assistant and running into the opposite. I don’t use MQTT topics according to the naming convention that home assistant automatically understands. So now I have to learn/find out how home assistant deals with this.

Oh yeah, it is always useful to use a program like MQTT-Explorer to see the MQTT command and state topics that are published on your MQTT broker.

That’s the issue, when I look at the yaml code, there is no channel section at all, looks it doesn’t get generated… I try again tomorrow

When i add the thing directly from inbox, the channel does look like:

With code below:

UID: mqtt:homeassistant_mqtt_5Flight_2Ezolder:e94f1500bd:mqtt_5Flight_2Ezolder
label: Zolder (Light)
thingTypeUID: mqtt:homeassistant_mqtt_5Flight_2Ezolder
    - light/zolder
  basetopic: homeassistant
bridgeUID: mqtt:broker:e94f1500bd

Then the issue begins, i cant add points

If i compare it with another mqtt , but a switch instead of lights, it looks like:

with yaml below

UID: mqtt:homeassistant_mqtt_5Fswitch_2Eeetkamer_5Fsc:e94f1500bd:mqtt_5Fswitch_2Eeetkamer_5Fsc
label: Eetkamer Sc (Switch)
thingTypeUID: mqtt:homeassistant_mqtt_5Fswitch_2Eeetkamer_5Fsc
    - switch/eetkamer_sc
  basetopic: homeassistant
bridgeUID: mqtt:broker:e94f1500bd

it seems the mqtt home assistant binding , doesnt need any yaml at all, its probably somekind of builtin, but it just doesnt work for lights…
i really hoped openHab was a stable system :frowning:

Whether it has the features that you want or not, has little to do with stability.

I think it would be fair to say that the Home Assistant discovery part of the MQTT binding has received less development from volunteer developers than say the Homie version. That would reflect the interest of the developers.
I wouldn’t be surprised if it does not include support for every combination, which is what you seem to be looking at.

You can contribute yourself, or persuade someone who can (there is a bounty scheme for enhancement requests)

Or, the MQTT binding is flexible and allows you to manually define all the Things and channels that you’d like. That’s more work than auto-discovery, of course.