mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[Homematic] Fix "Channel not found for Datapoint"-Errors (#11493)
Signed-off-by: Flole <flole@flole.de>
This commit is contained in:
parent
374a89a9fb
commit
145bd0ec97
@ -147,10 +147,52 @@ public class HomematicThingHandler extends BaseThingHandler {
|
||||
}
|
||||
updateConfiguration(config);
|
||||
|
||||
boolean channelsChanged = false;
|
||||
|
||||
// update thing channel list for reconfigurable channels (relies on the new value of the
|
||||
// CHANNEL_FUNCTION datapoint fetched during configuration update)
|
||||
List<Channel> thingChannels = new ArrayList<>(getThing().getChannels());
|
||||
|
||||
if (thingChannels.isEmpty()) {
|
||||
for (HmChannel channel : device.getChannels()) {
|
||||
for (HmDatapoint dp : channel.getDatapoints()) {
|
||||
if (HomematicTypeGeneratorImpl.isIgnoredDatapoint(dp)
|
||||
|| dp.getParamsetType() != HmParamsetType.VALUES) {
|
||||
continue;
|
||||
}
|
||||
ChannelUID channelUID = UidUtils.generateChannelUID(dp, getThing().getUID());
|
||||
if (containsChannel(thingChannels, channelUID)) {
|
||||
// Channel is already present
|
||||
continue;
|
||||
}
|
||||
|
||||
ChannelTypeUID channelTypeUID = UidUtils.generateChannelTypeUID(dp);
|
||||
ChannelType channelType = channelTypeProvider.getInternalChannelType(channelTypeUID);
|
||||
if (channelType == null) {
|
||||
channelType = HomematicTypeGeneratorImpl.createChannelType(dp, channelTypeUID);
|
||||
channelTypeProvider.addChannelType(channelType);
|
||||
}
|
||||
|
||||
Channel thingChannel = ChannelBuilder.create(channelUID, MetadataUtils.getItemType(dp))
|
||||
.withLabel(MetadataUtils.getLabel(dp))
|
||||
.withDescription(MetadataUtils.getDatapointDescription(dp)).withType(channelType.getUID())
|
||||
.build();
|
||||
thingChannels.add(thingChannel);
|
||||
|
||||
logger.debug(
|
||||
"Updated value datapoints for channel {} of device '{}' (function {}), now has {} datapoints",
|
||||
channel, channel.getDevice().getAddress(), channel.getCurrentFunction(),
|
||||
channel.getDatapoints().size());
|
||||
}
|
||||
}
|
||||
channelsChanged = true;
|
||||
}
|
||||
|
||||
if (updateDynamicChannelList(device, thingChannels)) {
|
||||
channelsChanged = true;
|
||||
}
|
||||
|
||||
if (channelsChanged) {
|
||||
updateThing(editThing().withChannels(thingChannels).build());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user