How to deal with multi-channel items in OH2 in the new semantic model

I just installed OH3 yesterday and tried to fit my existing items configuration into the new model. The problem with me seems to do with how I defined my items in OH2 .items file. Most of my items were linked to multi-channels. e.g.

Dimmer ZW_Kitchen_Dimmer “Kitchen Light [%d%%]” (gKitchen) [ “OpenLevel”, “Light” ] {channel=“zwave:device:d573ec23a9:node2:switch_dimmer”, channel=“mqtt:topic:MyMQTTBroker:oh_kitchen_lt:proxyDimmer”}

The reason for that was to post state changes to Smartthings through MQTT proxy topic, and also get command from it. This worked fine for me all along in basic UI@OH2.

The problem with it in the new semantic model is that the extra channel (mqtt) seemed to confuse the UI. So in the location tab, I don’t see any slider or switch being rendered, instead, I only see NULL or 0%.

Any suggestion? One way I can think of is to create items fresh with only one channel, and create rules to deal with extra channel communication. But I’d rather check with the community if there is a better way first. After all, I was migrating to OH3 due to a mishap to my old OH2 server, I’m not really prepared to spend a lot of time on this yet.

This has nothing to do with the fact that it’s linked to two different Channels. You could have a 100 channels and the Semantic Model wouldn’t care. The model only sees and only operates at the Item level.

The widget is only showing NULL or 0% because that’s the state of the Item. You don’t see a slider because you’ve tagged it with the Point “OpenLevel” which is meant to be used for sensors that measure how open/closed a door, window, rollershutter, etc is. A Dimmer would more appropriately be tagged with Setpoint, since the purpose of the Item is to show and control the dimmer’s target point.

No need to create rules. You almost certainly could use the MQTT Event Bus rule templates. Just add those Items you want to have mirrored via MQTT and the rules instantiated from the templates will handle the rest.

But, like I said, your problem has nothing to do with the multiple links.

Thanks @rlkoshak , I’m glad to hear that multiple channels linking is not the culprit here. But I’m still unable to have a control widget for the dimmer or switch.

Here is my updated item:

Dimmer    ZW_Kitchen_Dimmer                 "Kitchen Light [%d%%]"                   <light>                 (gKitchen)    [ "Setpoint", "Light" ]      {channel="zwave:device:d573ec23a9:node2:switch_dimmer", channel="mqtt:topic:MyMQTTBroker:oh_kitchen_lt:proxyDimmer"}

It showed up as a point under location Kitchen which is fine.


But I still not seeing any slider or switch control in the widget:

I was suspecting this has to do with multi-channel, because I removed the second MQTT channel from item’s linking, and everything worked fine. Anywhere else I need to pay attention to?

BTW, MQTT event bus template seems a good initiative, but I haven’t read how template works yet, I’ll look into it later.

Well, MainUI does it’s best to pick an appropriate widget based on the Item type and the semantic tags. But when it doesn’t give you what you need, you can set the “default stand alone widget” and “default list item widget” where you can set the widget used to what ever you want it to be.

It’s covered here and here but at a high level:

  1. Install the rule template under Settings → Automation → Rule Templates.
  2. Navigate to Rules and click + to create a new rule.
  3. Choose the rule template from the list of installed templates
  4. Fill out the properties (see the rule template’s docs for details)
  5. Hit save

You now have a rule customized using the filled in properties. You are free to further customize the code if required. Some templates can be very powerful. For example, I use the Open Reminder template to:

  • remind me when a door is left open for too long
  • tell me when a service goes offline/online
  • tell me when a sensor stops/starts reporting
  • tell me when the motion sensor at my dad’s house hasn’t triggered for too long

I’m about to merge Open Door and Threshold Alert meaning I’ll be able to have these also implemented by the same rule template:

  • remind me to fill the humidifiers when the humidity gets too low
  • control a dumb humidifier connected to a smart plug based on the humidity levels
  • alert me when the temperature gets too high or low in one of the rooms in the house

And while I had to write the code to do all this, you don’t have to. You just need to install it, instantiate it, and configure it. That’s the power of rule templates.

Great job in OH3 about the template. It sounds interesting already. I came from SmartThings, so template reusing is always the most wanted thing I missed in OH since day 1. I reused a lot of good SmartApps developed by others in ST, hence the reason I’m still syncing between OH and ST, so that I can keep benefiting from ST world. Now that OH has something similar, if it’s comparable to ST, I may forget about ST totally. :slight_smile:

Back to the channel linking issue, I think this may be a candidate for the feature requests. Say when multiple channels are linked to an item, allow one to be set as the primary one for UI hint.

Well, you kind of already have that with the fact that you can set the units yourself by setting the State Description Pattern with our desired units. Or if you don’t want units you can just use a Number.

In OH 4, it’s looking like if you want to use units you will have to set the units you want on the Item yourself. The binding will no longer be allowed to push the units to you. Though it will still be able to set the State Description Pattern.