[miele] Fix mDNS issue where hub repeatedly disappears from, resp. reappears in, the Inbox. (#11834)
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
This commit is contained in:
parent
8d15e0ae7b
commit
e9060c462b
@ -29,6 +29,17 @@ The types of appliances that are supported by this binding are:
|
|||||||
The binding is able to auto-discover the Miele XGW3000 gateway.
|
The binding is able to auto-discover the Miele XGW3000 gateway.
|
||||||
When an XGW3000 gateway is discovered, all appliances can be subsequently discovered.
|
When an XGW3000 gateway is discovered, all appliances can be subsequently discovered.
|
||||||
|
|
||||||
|
### Note on Discovery
|
||||||
|
|
||||||
|
The XGW3000 gateway is sometimes a few seconds late in re-announcing itself on the network.
|
||||||
|
This means that it might repeatedly disappear from, and re-appear in, the Inbox.
|
||||||
|
To avoid this, there is a discovery configuration parameter `removalGracePeriod` which delays such Inbox disappearances.
|
||||||
|
The default value is 15 seconds.
|
||||||
|
If you want to change this value just add the following line to your `$OPENHAB_CONF/services/runtime.cfg` file.
|
||||||
|
|
||||||
|
```
|
||||||
|
discovery.miele:removalGracePeriod=30
|
||||||
|
```
|
||||||
|
|
||||||
## Thing Configuration
|
## Thing Configuration
|
||||||
|
|
||||||
|
|||||||
@ -114,4 +114,5 @@ public class MieleBindingConstants {
|
|||||||
public static final String USER_NAME = "userName";
|
public static final String USER_NAME = "userName";
|
||||||
public static final String PASSWORD = "password";
|
public static final String PASSWORD = "password";
|
||||||
public static final String LANGUAGE = "language";
|
public static final String LANGUAGE = "language";
|
||||||
|
public static final String REMOVAL_GRACE_PERIOD = "removalGracePeriod";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,13 +22,17 @@ import java.util.Set;
|
|||||||
|
|
||||||
import javax.jmdns.ServiceInfo;
|
import javax.jmdns.ServiceInfo;
|
||||||
|
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.binding.miele.internal.MieleBindingConstants;
|
import org.openhab.binding.miele.internal.MieleBindingConstants;
|
||||||
import org.openhab.core.config.discovery.DiscoveryResult;
|
import org.openhab.core.config.discovery.DiscoveryResult;
|
||||||
import org.openhab.core.config.discovery.DiscoveryResultBuilder;
|
import org.openhab.core.config.discovery.DiscoveryResultBuilder;
|
||||||
import org.openhab.core.config.discovery.mdns.MDNSDiscoveryParticipant;
|
import org.openhab.core.config.discovery.mdns.MDNSDiscoveryParticipant;
|
||||||
|
import org.openhab.core.config.discovery.mdns.internal.MDNSDiscoveryService;
|
||||||
import org.openhab.core.thing.ThingTypeUID;
|
import org.openhab.core.thing.ThingTypeUID;
|
||||||
import org.openhab.core.thing.ThingUID;
|
import org.openhab.core.thing.ThingUID;
|
||||||
|
import org.osgi.service.component.annotations.Activate;
|
||||||
import org.osgi.service.component.annotations.Component;
|
import org.osgi.service.component.annotations.Component;
|
||||||
|
import org.osgi.service.component.annotations.Modified;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -40,7 +44,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
* @author Martin Lepsy - Added check for Miele gateway for cleaner discovery
|
* @author Martin Lepsy - Added check for Miele gateway for cleaner discovery
|
||||||
* @author Jacob Laursen - Fixed multicast and protocol support (ZigBee/LAN)
|
* @author Jacob Laursen - Fixed multicast and protocol support (ZigBee/LAN)
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component(configurationPid = "discovery.miele")
|
||||||
public class MieleMDNSDiscoveryParticipant implements MDNSDiscoveryParticipant {
|
public class MieleMDNSDiscoveryParticipant implements MDNSDiscoveryParticipant {
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(MieleMDNSDiscoveryParticipant.class);
|
private final Logger logger = LoggerFactory.getLogger(MieleMDNSDiscoveryParticipant.class);
|
||||||
@ -48,6 +52,37 @@ public class MieleMDNSDiscoveryParticipant implements MDNSDiscoveryParticipant {
|
|||||||
private static final String SERVICE_NAME = "mieleathome";
|
private static final String SERVICE_NAME = "mieleathome";
|
||||||
private static final String PATH_PROPERTY_NAME = "path";
|
private static final String PATH_PROPERTY_NAME = "path";
|
||||||
|
|
||||||
|
private long removalGracePeriodSeconds = 15;
|
||||||
|
|
||||||
|
@Activate
|
||||||
|
public void activate(@Nullable Map<String, Object> configProperties) {
|
||||||
|
updateRemovalGracePeriod(configProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Modified
|
||||||
|
public void modified(@Nullable Map<String, Object> configProperties) {
|
||||||
|
updateRemovalGracePeriod(configProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the removalGracePeriodSeconds when the component is activates or modified.
|
||||||
|
*
|
||||||
|
* @param configProperties the passed configuration parameters.
|
||||||
|
*/
|
||||||
|
private void updateRemovalGracePeriod(Map<String, Object> configProperties) {
|
||||||
|
if (configProperties != null) {
|
||||||
|
Object value = configProperties.get(MieleBindingConstants.REMOVAL_GRACE_PERIOD);
|
||||||
|
if (value != null) {
|
||||||
|
try {
|
||||||
|
removalGracePeriodSeconds = Integer.parseInt(value.toString());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
logger.warn("Configuration property '{}' has invalid value: {}",
|
||||||
|
MieleBindingConstants.REMOVAL_GRACE_PERIOD, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
|
public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
|
||||||
return Collections.singleton(MieleBindingConstants.THING_TYPE_XGW3000);
|
return Collections.singleton(MieleBindingConstants.THING_TYPE_XGW3000);
|
||||||
@ -113,4 +148,14 @@ public class MieleMDNSDiscoveryParticipant implements MDNSDiscoveryParticipant {
|
|||||||
return service.getApplication().contains(SERVICE_NAME) && service.getPropertyString(PATH_PROPERTY_NAME) != null
|
return service.getApplication().contains(SERVICE_NAME) && service.getPropertyString(PATH_PROPERTY_NAME) != null
|
||||||
&& service.getPropertyString(PATH_PROPERTY_NAME).equalsIgnoreCase(PATH_TO_CHECK_FOR_XGW3000);
|
&& service.getPropertyString(PATH_PROPERTY_NAME).equalsIgnoreCase(PATH_TO_CHECK_FOR_XGW3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Miele devices are sometimes a few seconds late in updating their mDNS announcements, which means that they are
|
||||||
|
* repeatedly removed from, and (re)added to, the Inbox. To prevent this, we override this method to specify an
|
||||||
|
* additional delay period (grace period) to wait before the device is removed from the Inbox.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public long getRemovalGracePeriodSeconds(ServiceInfo serviceInfo) {
|
||||||
|
return removalGracePeriodSeconds;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user