Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Homematic] Fix "Channel not found for Datapoint" errors #11493

Merged
merged 1 commit into from
Dec 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,52 @@ private void doInitializeInBackground() throws GatewayNotAvailableException, Hom
}
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());
Flole998 marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down