-
-
Notifications
You must be signed in to change notification settings - Fork 266
Description
Issue
The issue is in Main UI when I try to create an Item linked to a structured dynamic channel, it does not find the respective Channel-Type data. Which means that the UI lacks the full information to properly create the Item.
The UI gives fore warning of such issue by marking the channel UID with a ?
mark indicating that the type information cannot be found..

Intro
I am working on a PR to implement a HomeKit client in OH and I am facing a difficulty which to be honest I am not sure is an issue in OH Core, Main UI, or the binding itself. But I am posting it here first in order to at least start somewhere :)
Background
The HomeKit architecture has three levels -- namely 'Accessory' entities which represent devices, where each Accessory implements multiple 'Service' entities, and each Service implements multiple 'Characteristic' entities which represent a single data point. The binding models Accessories as Things, Services as Channel-Groups, and Characteristics as Channels.
Code flow
In step 1 of initialization, the bridge handler fetches the full tree of Accessory, Service, Characteristic and builds a list of Channel-Types from the Characteristics, and a list of Channel-Group-Types from the Services. These types are persisted via an AbstractStorageBasedTypeProvider overridden class. The bridge handler also builds child accessory discovery results from the Accessories and places them in the Inbox.
Channel Group Types in AbstractStorageBasedTypeProvider overridden class
``` { "homekit:channel-group-type-lightbulb": { "class": "org.openhab.core.thing.binding.AbstractStorageBasedTypeProvider$ChannelGroupTypeEntity", "value": { "uid": { "segments": [ "homekit", "channel-group-type-lightbulb" ], "uid": "homekit:channel-group-type-lightbulb" }, "label": "Channel group type: Light Bulb", "channelDefinitions": [ { "id": "on", "uid": { "segments": [ "homekit", "channel-type-on" ], "uid": "homekit:channel-type-on" }, "label": "On", "properties": { "format": "bool", "iid": "9", "perms": "pr,pw,ev" } }, { "id": "brightness", "uid": { "segments": [ "homekit", "channel-type-brightness" ], "uid": "homekit:channel-type-brightness" }, "label": "Brightness", "properties": { "format": "int", "iid": "10", "maxValue": "100.0", "minStep": "1.0", "minValue": "0.0", "perms": "pr,pw,ev", "unit": "%" } } ] } } } ```Channel Types in AbstractStorageBasedTypeProvider overridden class
``` { "homekit:channel-type-brightness": { "class": "org.openhab.core.thing.binding.AbstractStorageBasedTypeProvider$ChannelTypeEntity", "value": { "uid": { "segments": [ "homekit", "channel-type-brightness" ], "uid": "homekit:channel-type-brightness" }, "label": "Channel type: Brightness", "advanced": false, "itemType": "Dimmer", "kind": "STATE", "tags": [ "Brightness", "Setpoint" ], "category": "light" } }, "homekit:channel-type-on": { "class": "org.openhab.core.thing.binding.AbstractStorageBasedTypeProvider$ChannelTypeEntity", "value": { "uid": { "segments": [ "homekit", "channel-type-on" ], "uid": "homekit:channel-type-on" }, "label": "Channel type: On", "advanced": false, "itemType": "Switch", "kind": "STATE", "tags": [ "Power", "Switch" ], "category": "switch" } } } ```Then in step 2 of initialization, the child accessory handlers build their Channels dynamically, with reference to the previously created Channel-Types and Channel-Group-Types that have been created and stored in the AbstractStorageBasedTypeProvider.
So in summary we end up with the following tree:
=> Thing instances created from Inbox
==> Dynamic Channel-Group instances referring to an AbstractStorageBasedTypeProvider entry
===> Dynamic Channel instances referring to an AbstractStorageBasedTypeProvider entry
Tests confirm that issue is in OH Core or OH UI and not the binding
The binding Junit tests confirm that the dynamic channel definitions do indeed link to the created Channel-Types and Channel-Group-Types. And furthermore I have now added code into the binding so that it successfully loads both the Channel-Types from the OH ChannelTypeRegistry and the Channel-Group-Types from the OH core ChannelGroupTypeRegistry.