Hi,
I am developing an addon and have a problem with channels and their properties:
If I link a channel, that was defined in the XML file, to a new item, openHab populates “Type”, “Dimension” and “State Description Pattern” of the item with the proper values from the XML file.
If I do the same on a channel, that was created at runtime via editThing()
, openHab tries to create a “Switch” item instead of “Number:ElectricPotential” and the state pattern also stays empty.
What confuses me, is that both channels use the same ChannelType. And openHab reads the “label” from the ChannelType, but not the other information.
This is the relevant part of the thing description:
<thing-type id="sunspec-mppt">
<channels>
<channel id="mppt-dc-voltage" typeId="mppt-dc-voltage-type"/>
</channels>
with this channel type configuration:
<channel-type id="mppt-dc-voltage-type">
<item-type>Number:ElectricPotential</item-type>
<label>DC Voltage</label>
<state readOnly="true" pattern="%.1f %unit%"/>
</channel-type>
and here is the code, with which I am creating a new channel, which references the same ChannelType, but still behaves differently:
ChannelBuilder.create(new ChannelUID(getThing().getUID(), "module-" + moduleNumber, "mppt-dc-voltage"))
.withType(new ChannelTypeUID(BINDING_ID, "mppt-dc-voltage-type")).build());
The upper channel is from the XML file, the lower created by the code above:
Linking the first one the a new item:
Linking the second one to a new item:
What am I missing?