Things with multiple Channels of the same Channel Type

Hi,

In the Z-Way Binding the channels are added dynamically. Some Z-Way devices have multiple functions of the same type, for example a rgb bulb has a function for cold white and one for soft white. The channel type is the same for both “switchColorTemperature”. When both channels added dynamically an error occurred: Duplicate channels ... . For that reason I added a unique identifier to the channel types during the dynamic addition, for example:

  • ...:switchColorTemperature-ZWayVDev_zway_21-0-51-0
  • ...:switchColorTemperature-ZWayVDev_zway_21-0-51-1

That works as expected, when simple mode of item linking is activated.

Problem:
When the simple mode is deactivated and the user try to link the channel manually via PaperUI an error occurred: ChannelType is undefined (see also topic: Z-Way Binding not working (Channels from Things cannot be used)).

I think the reason is that the REST API for channel types doesn’t provide the modified channel types, only the static defined.

Any ideas? Can I add the channels differently?

Code of dynamic addition:

  • id is channel id of static defined channel type (XML)

  • "-" + properties.get("deviceId") is the unique identifier

    ThingBuilder thingBuilder = editThing();
    ChannelTypeUID channelTypeUID = new ChannelTypeUID(BINDING_ID, id);
    Channel channel = ChannelBuilder
        .create(new ChannelUID(getThing().getUID(), id + "-" + properties.get("deviceId")), acceptedItemType)
        .withType(channelTypeUID).withLabel(label).withProperties(properties).build();
    thingBuilder.withChannel(channel);
    thingBuilder.withLabel(thing.getLabel());
    updateThing(thingBuilder.build());
    

Your channel ids are terribly long.

Instead of switchColorTemperature-ZWayVDev_zway_21-0-51-0, you should rather come up with something like color0, which would make it much better usable.

In general, you indeed have to make sure that you do not have two channels on a Thing with the same id. But on the REST API, all channels are shown, it doesn’t matter how they have been added. If this is indeed not the case, please enter an issue at https://github.com/eclipse/smarthome/issues.

Ok, I can probably shorten that. The channel type problem does not solve it, but it is on the todo list.

This is prevented by attaching the device id (ZWayVDev_zway_21-0-51-0) to channel type uid.

It does not. I’ll create an issue.

I’ve created an issue for that: https://github.com/eclipse/smarthome/issues/2903

The problem is solved with current snapshot release!