[nuki] Disabled warning for things created from textual config (#13331)
* Removed warning shown when thing is created with hexadecimal warning for read-only things * Added missing configuration parameters into documentation Signed-off-by: Jan Vybíral <jan.vybiral1@gmail.com>
This commit is contained in:
@@ -26,6 +26,7 @@ import org.openhab.core.io.net.http.HttpClientFactory;
|
||||
import org.openhab.core.net.HttpServiceUtil;
|
||||
import org.openhab.core.net.NetworkAddressService;
|
||||
import org.openhab.core.thing.Bridge;
|
||||
import org.openhab.core.thing.ManagedThingProvider;
|
||||
import org.openhab.core.thing.Thing;
|
||||
import org.openhab.core.thing.ThingTypeUID;
|
||||
import org.openhab.core.thing.ThingUID;
|
||||
@@ -54,14 +55,17 @@ public class NukiHandlerFactory extends BaseThingHandlerFactory {
|
||||
|
||||
private final HttpClient httpClient;
|
||||
private final NetworkAddressService networkAddressService;
|
||||
private final ManagedThingProvider managedThingProvider;
|
||||
private NukiApiServlet nukiApiServlet;
|
||||
|
||||
@Activate
|
||||
public NukiHandlerFactory(@Reference HttpService httpService, @Reference final HttpClientFactory httpClientFactory,
|
||||
@Reference NetworkAddressService networkAddressService) {
|
||||
@Reference NetworkAddressService networkAddressService,
|
||||
@Reference ManagedThingProvider managedThingProvider) {
|
||||
this.httpClient = httpClientFactory.getCommonHttpClient();
|
||||
this.networkAddressService = networkAddressService;
|
||||
this.nukiApiServlet = new NukiApiServlet(httpService);
|
||||
this.managedThingProvider = managedThingProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,6 +76,7 @@ public class NukiHandlerFactory extends BaseThingHandlerFactory {
|
||||
@Override
|
||||
protected @Nullable ThingHandler createHandler(Thing thing) {
|
||||
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
|
||||
boolean readOnly = managedThingProvider.get(thing.getUID()) == null;
|
||||
|
||||
if (NukiBindingConstants.THING_TYPE_BRIDGE_UIDS.contains(thingTypeUID)) {
|
||||
String callbackUrl = createCallbackUrl(InstanceUUID.get());
|
||||
@@ -79,9 +84,9 @@ public class NukiHandlerFactory extends BaseThingHandlerFactory {
|
||||
nukiApiServlet.add(nukiBridgeHandler);
|
||||
return nukiBridgeHandler;
|
||||
} else if (NukiBindingConstants.THING_TYPE_SMARTLOCK_UIDS.contains(thingTypeUID)) {
|
||||
return new NukiSmartLockHandler(thing);
|
||||
return new NukiSmartLockHandler(thing, readOnly);
|
||||
} else if (NukiBindingConstants.THING_TYPE_OPENER_UIDS.contains(thingTypeUID)) {
|
||||
return new NukiOpenerHandler(thing);
|
||||
return new NukiOpenerHandler(thing, readOnly);
|
||||
}
|
||||
logger.warn("No valid Handler found for Thing[{}]!", thingTypeUID);
|
||||
return null;
|
||||
|
||||
@@ -71,9 +71,11 @@ public abstract class AbstractNukiDeviceHandler<T extends NukiDeviceConfiguratio
|
||||
protected T configuration;
|
||||
@Nullable
|
||||
private NukiHttpClient nukiHttpClient;
|
||||
protected final boolean readOnly;
|
||||
|
||||
public AbstractNukiDeviceHandler(Thing thing) {
|
||||
public AbstractNukiDeviceHandler(Thing thing, boolean readOnly) {
|
||||
super(thing);
|
||||
this.readOnly = readOnly;
|
||||
this.configuration = getConfigAs(getConfigurationClass());
|
||||
}
|
||||
|
||||
@@ -109,9 +111,11 @@ public abstract class AbstractNukiDeviceHandler<T extends NukiDeviceConfiguratio
|
||||
// legacy support - check if nukiId is hexadecimal (which might have been set by previous binding version)
|
||||
// and convert it to decimal
|
||||
if (NUKI_ID_HEX_PATTERN.matcher(nukiId).matches()) {
|
||||
logger.warn(
|
||||
"SmartLock '{}' was created by old version of binding. It is recommended to delete it and discover again",
|
||||
thing.getUID());
|
||||
if (!readOnly) {
|
||||
logger.warn(
|
||||
"SmartLock '{}' was created by old version of binding. It is recommended to delete it and discover again",
|
||||
thing.getUID());
|
||||
}
|
||||
Configuration newConfig = editConfiguration();
|
||||
newConfig.put(NukiBindingConstants.PROPERTY_NUKI_ID, hexToDecimal(nukiId));
|
||||
updateConfiguration(newConfig);
|
||||
|
||||
@@ -36,8 +36,8 @@ import org.openhab.core.types.Command;
|
||||
@NonNullByDefault
|
||||
public class NukiOpenerHandler extends AbstractNukiDeviceHandler<NukiDeviceConfiguration> {
|
||||
|
||||
public NukiOpenerHandler(Thing thing) {
|
||||
super(thing);
|
||||
public NukiOpenerHandler(Thing thing, boolean readOnly) {
|
||||
super(thing, readOnly);
|
||||
}
|
||||
|
||||
private volatile Instant lastRingAction = Instant.EPOCH;
|
||||
|
||||
@@ -35,8 +35,8 @@ import org.openhab.core.types.Command;
|
||||
@NonNullByDefault
|
||||
public class NukiSmartLockHandler extends AbstractNukiDeviceHandler<NukiSmartLockConfiguration> {
|
||||
|
||||
public NukiSmartLockHandler(Thing thing) {
|
||||
super(thing);
|
||||
public NukiSmartLockHandler(Thing thing, boolean readOnly) {
|
||||
super(thing, readOnly);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user