Skip to content

Commit

Permalink
Fixed bug between binding and OH core - DeviceHandler.updateStatus sh…
Browse files Browse the repository at this point in the history
…ould work again

Signed-off-by: JankKeks <[email protected]>
  • Loading branch information
JankKeks committed Dec 22, 2024
1 parent a4be1eb commit 8cd512b
Showing 1 changed file with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,19 @@ public void handleCommand(ChannelUID channelUID, Command command) {
logger.debug("Handle command for device (but invalid datapointgroup) {} - at channel {} - full command {}",
device.getDeviceId(), channelUID.getAsString(), command.toFullString());

logger.debug("Try to find channelUID in dpg: {}", channelUID.getAsString());
logger.debug("dpg: ");
mapChannelUID.forEach((k, v) -> {
if (v.getOutputDatapoint() != null) {
logger.debug("key: {} - input value: {}", k, v.getOutputDatapoint().getChannelIdforDatapoint() + " "
+ v.getOutputDatapoint().getDatapointId());
}
if (v.getInputDatapoint() != null) {
logger.debug("key: {} - output value: {}", k, v.getInputDatapoint().getChannelIdforDatapoint() + " "
+ v.getInputDatapoint().getDatapointId());
}
});

updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"@text/conf-error.invalid-deviceconfig");
} else {
Expand Down Expand Up @@ -480,8 +493,7 @@ public void updateChannels() throws FreeAtHomeGeneralException {
channelTypeUID = createChannelTypeForDatapointgroup(dpg, channelTypeUID);
}

ChannelUID channelUID = new ChannelUID(thingUID, channel.getChannelId(),
dpg.getLabel().substring(4));
ChannelUID channelUID = createChannelUID(thingUID, channel.getChannelId(), dpg.getLabel());

String channelLabel = String.format("%s",
i18nProvider.getText(bundle, dpg.getLabel(), "-", locale));
Expand Down Expand Up @@ -568,7 +580,7 @@ private void reloadChannelTypes() throws FreeAtHomeGeneralException {
channelTypeUID = createChannelTypeForDatapointgroup(dpg, channelTypeUID);
}

ChannelUID channelUID = new ChannelUID(thingUID, channel.getChannelId());
ChannelUID channelUID = createChannelUID(thingUID, channel.getChannelId(), dpg.getLabel());

FreeAtHomeDatapoint outputDatapoint = dpg.getOutputDatapoint();

Expand All @@ -589,6 +601,12 @@ private void reloadChannelTypes() throws FreeAtHomeGeneralException {
}
}

// Create a channel UID. Makes sure that the channel UID is unique and generated the same way every time
private ChannelUID createChannelUID(ThingUID thingUID,String channelID, String dpgLabel) {
ChannelUID channelUID = new ChannelUID(thingUID, channelID, dpgLabel.substring(4));
return channelUID;
}

public void removeChannels() {
Bridge bridge = this.getBridge();

Expand Down

0 comments on commit 8cd512b

Please sign in to comment.