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:
- Create an MQTT Broker Thing.
- 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.
-
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
- Choose Binding: MQTT Binding | Generic MQTT Thing
-
In the Channels tab, click
Add Channel
. I noticed there is also an option forAdd 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)
-
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
- Thing: select
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
- Channel ID:
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