How to set the "semantic" class for a MQTT channel

  • Platform information:
    • Hardware: amd64 / 4 cores / 8G RAM
    • OS: Manjaro
    • Java Runtime Environment: Oracle 11.0.18
    • openHAB version: 3.4.2
  • Issue of the topic:

Hello,

As I’m continuing to experiment with zigbee2mqtt, I have created a thing with four channels for a door sensor that I have here and that publishes contact, tamper, battery low, battery percent and battery voltage.
Here is the definition made in PaperUI:

UID: mqtt:topic:6b3d5af049:91070e9004
label: Contact porte entrée (zigbee2mqtt)
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:6b3d5af049
channels:
  - id: ContactJSON
    channelTypeUID: mqtt:contact
    label: Contact
    description: null
    configuration:
      stateTopic: zigbee2mqtt/Contact porte entrée
      transformationPattern: JSONPATH:$.contact
      off: "true"
      on: "false"
  - id: Tamper
    channelTypeUID: mqtt:contact
    label: Tamper
    description: null
    configuration:
      stateTopic: zigbee2mqtt/Contact porte entrée
      transformationPattern: JSONPATH:$.tamper
      off: "true"
      on: "false"
  - id: BatteryLow
    channelTypeUID: mqtt:contact
    label: Battery Low
    description: null
    configuration:
      stateTopic: zigbee2mqtt/Contact porte entrée
      transformationPattern: JSONPATH:$.battery_low
      off: "true"
      on: "false"
  - id: battery_level
    channelTypeUID: mqtt:number
    label: Battery level
    description: null
    configuration:
      min: 0
      stateTopic: zigbee2mqtt/Contact porte entrée
      transformationPattern: JSONPATH:$.battery
      max: 100
  - id: battery_voltage
    channelTypeUID: mqtt:number
    label: Battery voltage
    description: null
    configuration:
      stateTopic: zigbee2mqtt/Contact porte entrée
      transformationPattern: JSONPATH:$.voltage

While this works, the various channels do not have automatic icons as there is with other non mqtt things. For instance, I have this:

While my mqtt thing channels show up like this:

Is there a way to add some “semantic” meaning to those channels so that they are recognized for what they are?
I have tried changing the channelTypeUID by adding :ElectricPotential after Number but could only get the channel to be destroyed by doing so.

Is this at all possible?

First: This is not Paper UI :slight_smile: but Main UI.

The semantic model is Items-only, your definition is Thing-only, so you have to go further and create Items to be linked with the channels (well, you did already for some channels)

Ah sorry, I keep mixing them up.

Fair enough, but then how do I get the channels to show up with nice icons as shown in the first screen capture?
Mind you, it’s not just about icons, but I feel there is an information used by openHAB itself when the channel as a more detailed definition.

Go to the semantic model and add the Items. The icons are set through category

It’s not.

“Semantic” has no meaning when it comes to Things and Channels. And in truth, it’s linking the Channels to Items and the properties of that Item that gives the Channels meaning in your home automation.

That’s defined and controlled by the binding author and you can do nothing to change it beyond asking the author to add units to the Numbers Channels.

But in this case, the MQTT gives you the option to define the unit in the Channel config. So put V in for that property and link it to an Item defined as a Number:ElectricPotential and you can add units to your Number Channels.

You don’t.

Well, thing is, when using “Create Equipment from Thing” in MainUI, the fact that the channel has Number:ElectricPotential makes it creates Items and Links with the appropriate parameters, saving me the hassle to do it. And when there are dozens of sensors, the less I have to click through configuration, the better I feel.

From your message, I feel it’s pointless for me to create an issue at Github requesting for adding units to the Numbers channels. Is that correct?

It’s pointless in the case for MQTT because it’s already there and supported.