mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 23:22:02 +01:00
fix startup (#16971)
Signed-off-by: Mark Herwege <mark.herwege@telenet.be> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
3d9023ca51
commit
3597f55bbd
@ -28,8 +28,10 @@ public class SystemInfoBindingConstants {
|
|||||||
|
|
||||||
public static final String BINDING_ID = "systeminfo";
|
public static final String BINDING_ID = "systeminfo";
|
||||||
|
|
||||||
public static final ThingTypeUID THING_TYPE_COMPUTER = new ThingTypeUID(BINDING_ID, "computer");
|
public static final String THING_TYPE_COMPUTER_ID = "computer";
|
||||||
public static final ThingTypeUID THING_TYPE_COMPUTER_IMPL = new ThingTypeUID(BINDING_ID, "computer-impl");
|
public static final ThingTypeUID THING_TYPE_COMPUTER = new ThingTypeUID(BINDING_ID, THING_TYPE_COMPUTER_ID);
|
||||||
|
public static final ThingTypeUID THING_TYPE_COMPUTER_IMPL = new ThingTypeUID(BINDING_ID,
|
||||||
|
THING_TYPE_COMPUTER_ID + "-impl");
|
||||||
|
|
||||||
// Thing properties
|
// Thing properties
|
||||||
/**
|
/**
|
||||||
|
@ -14,8 +14,6 @@ package org.openhab.binding.systeminfo.internal;
|
|||||||
|
|
||||||
import static org.openhab.binding.systeminfo.internal.SystemInfoBindingConstants.*;
|
import static org.openhab.binding.systeminfo.internal.SystemInfoBindingConstants.*;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.binding.systeminfo.internal.handler.SystemInfoHandler;
|
import org.openhab.binding.systeminfo.internal.handler.SystemInfoHandler;
|
||||||
@ -43,25 +41,22 @@ public class SystemInfoHandlerFactory extends BaseThingHandlerFactory {
|
|||||||
private @NonNullByDefault({}) SystemInfoInterface systeminfo;
|
private @NonNullByDefault({}) SystemInfoInterface systeminfo;
|
||||||
private @NonNullByDefault({}) SystemInfoThingTypeProvider thingTypeProvider;
|
private @NonNullByDefault({}) SystemInfoThingTypeProvider thingTypeProvider;
|
||||||
|
|
||||||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_COMPUTER,
|
|
||||||
THING_TYPE_COMPUTER_IMPL);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
|
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
|
||||||
return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
|
return BINDING_ID.equals(thingTypeUID.getBindingId())
|
||||||
|
&& thingTypeUID.getId().startsWith(THING_TYPE_COMPUTER_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected @Nullable ThingHandler createHandler(Thing thing) {
|
protected @Nullable ThingHandler createHandler(Thing thing) {
|
||||||
if (THING_TYPE_COMPUTER.equals(thing.getThingTypeUID())) {
|
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
|
||||||
|
if (supportsThingType(thingTypeUID)) {
|
||||||
if (thingTypeProvider.getThingType(THING_TYPE_COMPUTER_IMPL, null) == null) {
|
if (thingTypeProvider.getThingType(THING_TYPE_COMPUTER_IMPL, null) == null) {
|
||||||
thingTypeProvider.createThingType(THING_TYPE_COMPUTER_IMPL);
|
thingTypeProvider.createThingType(THING_TYPE_COMPUTER_IMPL);
|
||||||
// Save the current channels configs, will be restored after thing type change.
|
// Save the current channels configs, will be restored after thing type change.
|
||||||
thingTypeProvider.storeChannelsConfig(thing);
|
thingTypeProvider.storeChannelsConfig(thing);
|
||||||
}
|
}
|
||||||
return new SystemInfoHandler(thing, thingTypeProvider, systeminfo);
|
return new SystemInfoHandler(thing, thingTypeProvider, systeminfo);
|
||||||
} else if (THING_TYPE_COMPUTER_IMPL.equals(thing.getThingTypeUID())) {
|
|
||||||
return new SystemInfoHandler(thing, thingTypeProvider, systeminfo);
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user