[SOLVED] Assistance Needed with OpenHab MQTT Setup

Hi all,

I am trying to set up a device to communicate with OpenHab through MQTT, and I am encountering some challenges. I am familiar with the MQTT protocol, as I have been using it with my self-designed controllers and actuators, so my difficulties do not stem from a lack of understanding of how MQTT works. However, I am new to OpenHab and am struggling to understand how to set up the various components.

In principle, the setup should be straightforward:

  1. Create an MQTT Broker Thing.
  2. Create Generic MQTT Things connected to the Broker Thing, with channels for all necessary commands and states.

Creating the MQTT Broker bridge was easy, but I encountered problems afterward. Below are the steps I took, along with the relevant data. I have a robust home firewall in place.

  1. Create a Thing (Things > New): Living Room Heater.

    • Choose Binding: MQTT Binding | Generic MQTT Thing
      • Thing ID: living_room
      • Label: Living Room Heater
      • Location: Living Room
      • Bridge: MQTT Broker
  2. In the Channels tab, click Add Channel. I noticed there is also an option for Add Points to Model. What is the difference between these two options, and which one should I choose?

    • Channel ID: living_room_temperature
    • Label: Room Temperature
    • Description:
    • Channel Type: select Number Value
    • MQTT State Topic: home/living_room/m9t/temp
    • MQTT Command Topic: (leave empty, as this is a read-only value)
  3. Now, go to Model | Living Room and Add to Model: Create Equipment from Thing.

    • Thing: select Living Room Heater
      • Name: Living_Room_Heater (auto-filled)
      • Label: Living Room Heater (auto-filled)
      • Category: temperature
      • Semantic Class: Equipment
      • Channels: select Room Temperature
        • Label: Room Temperature
        • Dimension: Temperature (°C)
        • Unit: °C
        • State Description Pattern: %.1f %unit%
        • Category: temperature
        • Semantic Class: Point
        • Semantic Property: Temperature

This setup works, but there is one issue: the temperature is displayed only in whole degrees (integers), while I require a precision of 0.1 °C. I set the State Description Pattern to %.1f %unit% (it was %.0f %unit% by default). Is this correct? Unfortunately, I could not find that setting again after saving the Thing. The Configure Channel option does not list the State Description Pattern anymore! Displaying the value rounded to integers will not suffice for my needs, as the MQTT channel provides four digits after the decimal point. I hope this can be resolved.

Now, onto a more significant issue. After creating the read-only channel, I attempted to create the command channel. I opened the Living Room Heater, accessed its Channels tab, and clicked Add Channel. I realized that Add Channel means Create Channel, which seems a bit less intuitive. However, I have not found a way to create the channel first, and perhaps that is unnecessary.

  • Add Channel:
    • Channel ID: living_room_target_temperature
    • Label: Target Temperature
    • Channel Type: Number Value
    • MQTT Command Topic: home/living_room/heat_state/target_temp
    • Delta Value: 0.1
    • Unit of Measurement: °C

However, I encountered a problem: the second added channel is not linked to the Thing! It appears in All Channels but not in Linked Channels, where only the first channel is shown. I understand that it should be linked in the end, but I could be mistaken.

Could someone please explain what the Linked channels mean on the Thing | Channels tab? When you create a channel using Add Channel on that tab, why is the first channel linked, but subsequent channels are not? More importantly, how can you link a channel to a Thing?

What does the + Add Link to Item... option below a channel do? I initially thought it would create a straightforward link, but it seems to serve a more general purpose.

In summary, I have been unable to create the additional MQTT channel linked to my Living Room Heater equipment Thing, although I believe this is possible. I am also confused about the terms channels and points. When I see Add Channel or Add Points to Model, I am uncertain which option to choose. Could you please clarify this for me?

Additionally, I have a few other questions:

  • When I run the system and click on the temperature or press “Analyze,” I receive an empty graph. What could be the reason for this?
  • What is the purpose of the Category for equipment (it allows free text but suggests autocompletions), and how is it utilized?

I appreciate any assistance you can provide. Thank you very much!

Best regards,
Zsolt

  • Platform information:
    • Hardware: x86_64/ 16 GB RAM
    • OS: Linux 5.19.0-42-generic (Ubuntu 22.04)
    • Java Runtime Environment: openjdk 17.0.12 2024-07-16 (does not OpenHab use its own Java runtime?)
    • openHAB version: 4.2.2

This might help with some of the trouble you’re having following the different pieces. It’s a lot at first, so this simple breakdown might make it esier:

All parts of the semantic model, including equipment and points are just items of different types. So when you “Create equipment from thing” what you are really doing is creating one group item (the equipment) which is automatically placed within the location group item that is currently selected in the model. Then each of the points that you also add are just regular items that are automatically place with that equipment group item. So this means that the setting you selected when adding points are the item settings.

When you press save after setting up the “Create equipment from thing” wizard, all the items are created so if you need to go back and change settings, you need to go to the item list. Some of the basic settings are still available right in the Model page when you click on one of the points, but to get the full suite of settings you must go to that item’s full details page. This is true for the State Description Pattern which is actually some metadata that is stored with the item, so you go to the item’s detail page, click the Add Metadata button and then select State Description from the list of common metadata namespaces.

Correct. Many of the more specific Things in OH come with preset channels appropriate for that Thing. But more general things, such as an MQTT thing cannot know in advance much about the channel that you need to you need to add the channel configuration. It helps to think about the channels, not as properties of a Thing, but as specific objects themselves which mediate access to a thing. One of the concepts that (I hope) is clear from the glossary above and can be found in a few places in the help docs is the basic arrangement of concept layers for OH:

[world] <-> [binding] <-> [thing] <-> [channel] <-> [link] <-> [item]

Each of these is its own type of relevant object and most are one-to-many connections (one binding can have many things). The exception is that a Link connects one Item to one Channel.

So you are adding a channel object to your MQTT thing in oder to be able to create a link which allows an item to communiate up the chain with the outside world.

I hope this makes more sense now. On the Thing’s channel tab the All option shows every Channel already configured for the Thing. The Linked option shows only those Channels that already have a Link to an Item.

If the Channel shows up in the All tab then you have successfully created it. Now you just have to link an Item to it.

This is a persistence feature. rrd4j persistence should be installed and configured automatically unless you disabled this during the initial setup. If you are not seeing a graph of the historical data for that Item when you press analyze. Then there is something wrong with your presitence configuration.

Category is the way you can assign on of the default OH icons to an item. That’s pretty much all it does. You can put arbitrary text in there because it is possible for you to create your own OH icons if you wish, but it auto-suggests the ones that already exist. You can see a list of the built-in icons here:

2 Likes

Thank you so much, @JustinG! This is a wealth of information and incredibly helpful. I will read it carefully and do my best to immerse myself in the world of OpenHab. :blush:

The only thing I can add is it could be the case that your persistence is configured and working but this Item has never received an update. In that case too there’s be no data to chart.

I don’t think that’s the case here given the information prvided but I wanted to mention that as a possibility.

Dear @JustinG,

Thank you once again for your assistance. I find the glossary to be quite useful, and I strongly believe that it should be included in the documentation. I see no drawbacks to this suggestion.

However, I would like to emphasize that newcomers may struggle to grasp all the intricacies of the OpenHab system. It is relatively complex, and not everything is intuitive. There is a significant difference between theory and practice. I would greatly appreciate seeing real examples and use cases that demonstrate how to configure specific features from start to finish, as this would be tremendously helpful.

Regarding the following instruction:

To get the full suite of settings, you must go to that item’s full details page. This is true for the State Description Pattern, which is actually some metadata stored with the item. To access it, go to the item’s detail page, click the Add Metadata button, and then select State Description from the list of common metadata namespaces.

While this resolved my issue, I must express that I found it to be less than intuitive. I was searching for the item settings on the item’s detail page and would never have guessed that I needed to add metadata to access certain settings.

[world] <-> [binding] <-> [thing] <-> [channel] <-> [link] <-> [item]

Each of these is its own type of relevant object, and most are one-to-many connections (one binding can have many things). The exception is that a Link connects one Item to one Channel.

This line and comment from the glossary were particularly useful!

If the Channel shows up in the All tab, then you have successfully created it. Now you just have to link an Item to it.

Thank you for clarifying that; it resolved my confusion.

Regarding the following query:

When I run the system and click on the temperature or press “Analyze,” I receive an empty graph. What could be the reason for this?

This is a persistence feature. The rrd4j persistence should be installed and configured automatically unless you disabled this during the initial setup. If you are not seeing a graph of the historical data for that Item when you press analyze, then there is something wrong with your persistence configuration.

I can confirm that rrd4j is installed, and I do not recall disabling it. Nevertheless, I have now set up InfluxDB, made it the default persistence service, and configured the persistence settings to restoreOnStartup and everyChange, expecting to see data points appear on the graphs. However, the graphs remain blank. I have reviewed the persistence documentation, but I found it lacking in clarity. Additionally, I would expect the persistence strategies to be applied on a per-item basis rather than universally across all items (even with inclusion/exclusion options), but I seem to be misunderstanding how this operates. What am I doing wrong?

Thank you for your assistance!

Best regards,

Making OH more beginner friendly was a driving force behind the MainUI that you now use (you should have seen it before…:wink:) and it has been an even bigger push here in version 4. There’s no denying, however, that there’s still lots of room to grow in this area.

This is really the main issue here. While there is not necessarily a direct causal negative relationship between complexity and intuitiveness, there is a strong negative correlation. In order for software such as OH to perform the myriad number of functions that it does, it must have an extremely intricate control system. The UI dev’s do all they can to make this intuitive, but there’s a real limit to just how far that can go. If every single action/activity/setting available to users in OH were made into forms, each form would have an intimidating (and likely incomprehensible) array of inputs and gadgets and info boxes. So, a successful UX means narrowing that down, but that, by definition, means making some assumptions about user needs and desires taking away some user agency. As soon as dev’s have to start making these decisions, there’s a layer of interpretation between software and user and that interpretation will be intuitive for some and not for others.

No one here disagrees with that. The only thing standing in the way is enough volunteers and hours in a day. Everything from the source code of the core software to each and every doc page is created and maintained by volunteer work. Suggests for where to focus some of that work are always helpful. When you feel you’re ready, jumping in and helping with the work is even better! With doc pages its pretty easy. At the bottom of every page is this link:
image
Clicking on that link and adding what you’d like to see is a great way to get started contributing to OH.

I can’t disagree with that, maybe given how prominent metadata has become that label would make more sense as Edit Metadata instead. Another good way get in to helping with OH is to file a request or an issue in one of the code repository’s on github. In this case, you’d want to file a request in the UI repository. If you’ve never worked with github before, here’s a great quick intro to OH’s repositories.

I’m not particularly familiar with InfluxDB. This sounds like it would be worth starting a new thread likely to attract users with more experience in that area.

@gkzsolt , when/if you open a new thread, be sure to paste in your persistence config.

You can configure it that way.

Without more information about what you did and how you did it, most of which will be answered by posting your persistence config :person_shrugging:

How can I mark this thread as Solved? I marked a previous response as “Solution”, but I am not sure this is enough.

Thanks,

That is enough. But if you would like it’s status to be more visible, you can just edit the thread title and add some indicator such as [Solved].