mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[mqtt.homeassistant] remove channels for no-longer-configured components (#17447)
Signed-off-by: Cody Cutrer <cody@cutrer.us>
This commit is contained in:
parent
19c18be297
commit
b77458dca7
@ -214,6 +214,13 @@ public class HaID {
|
||||
return UIDUtils.encode(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the topic for this component, without /config
|
||||
*/
|
||||
public String getTopic() {
|
||||
return topic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a topic, which can be used for a mqtt subscription.
|
||||
* Defined values for suffix are:
|
||||
|
@ -150,8 +150,18 @@ public class HomeAssistantThingHandler extends AbstractMQTTThingHandler
|
||||
// Already restored component?
|
||||
@Nullable
|
||||
AbstractComponent<?> component = haComponents.get(groupID);
|
||||
|
||||
if (component != null) {
|
||||
continue;
|
||||
}
|
||||
HaID haID = HaID.fromConfig(config.basetopic, channel.getConfiguration());
|
||||
|
||||
if (!config.topics.contains(haID.getTopic())) {
|
||||
// don't add a component for this channel that isn't configured on the thing
|
||||
// anymore
|
||||
// It will disappear from the thing when the thing type is updated below
|
||||
continue;
|
||||
}
|
||||
|
||||
discoveryHomeAssistantIDs.add(haID);
|
||||
ThingUID thingUID = channel.getUID().getThingUID();
|
||||
String channelConfigurationJSON = (String) channel.getConfiguration().get("config");
|
||||
|
Loading…
Reference in New Issue
Block a user