[samsungtv] WebSocket TVs stay UNKNOWN until first power-on #9764 (#9923)

Fixed #9764

Signed-off-by: morph166955 <rosenblumb@gmail.com>
This commit is contained in:
morph166955 2021-01-25 16:19:13 -06:00 committed by GitHub
parent 5dd30ea35f
commit c77d3b93f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -239,14 +239,26 @@ public class SamsungTvHandler extends BaseThingHandler implements RegistryListen
private void checkAndCreateServices() {
logger.debug("Check and create missing UPnP services");
boolean isOnline = false;
for (Device<?, ?, ?> device : upnpService.getRegistry().getDevices()) {
createService((RemoteDevice) device);
if (createService((RemoteDevice) device) == true) {
isOnline = true;
}
}
if (isOnline == true) {
logger.debug("Device was online");
putOnline();
} else {
logger.debug("Device was NOT online");
putOffline();
}
checkCreateManualConnection();
}
private synchronized void createService(RemoteDevice device) {
private synchronized boolean createService(RemoteDevice device) {
if (configuration.hostName != null
&& configuration.hostName.equals(device.getIdentity().getDescriptorURL().getHost())) {
String modelName = device.getDetails().getModelDetails().getModelName();
@ -275,8 +287,9 @@ public class SamsungTvHandler extends BaseThingHandler implements RegistryListen
logger.debug("Service rediscovered, clearing caches: {}, {} ({})", modelName, type, udn);
existingService.clearCache();
}
putOnline();
return true;
}
return false;
}
private @Nullable SamsungTvService findServiceInstance(String serviceName) {