Package org.openhab.core.thing.binding
Interface ThingHandlerFactory
- All Known Implementing Classes:
BaseThingHandlerFactory
@NonNullByDefault
public interface ThingHandlerFactory
The
ThingHandlerFactory
is responsible for creating Thing
s and ThingHandler
s. Therefore the
factory must be registered as OSGi service.- Author:
- Dennis Nobel - Initial contribution, Stefan Bußweiler - API changes due to bridge/thing life cycle refactoring
-
Method Summary
Modifier and TypeMethodDescription@Nullable Thing
createThing
(ThingTypeUID thingTypeUID, Configuration configuration, @Nullable ThingUID thingUID, @Nullable ThingUID bridgeUID) Creates a thing for given arguments.registerHandler
(Thing thing) Creates a newThingHandler
instance.void
removeThing
(ThingUID thingUID) A thing with the givenThing
UID was removed.boolean
supportsThingType
(ThingTypeUID thingTypeUID) Returns whether the handler is able to create a thing or register a thing handler for the given type.void
unregisterHandler
(Thing thing) Unregisters aThingHandler
instance.
-
Method Details
-
supportsThingType
Returns whether the handler is able to create a thing or register a thing handler for the given type.- Parameters:
thingTypeUID
- the thing type UID- Returns:
- true, if the handler supports the thing type, false otherwise
-
registerHandler
Creates a newThingHandler
instance. In addition, the handler can be registered as a service if it is required, e.g. asFirmwareUpdateHandler
,ConfigStatusProvider
.This method is only called if the
ThingHandlerFactory
supports the type of the given thing.The framework expects this method to be non-blocking and return quickly.
- Parameters:
thing
- the thing for which a new handler must be registered- Returns:
- the created thing handler instance, not null
- Throws:
IllegalStateException
- if the handler instance could not be created
-
unregisterHandler
Unregisters aThingHandler
instance.The framework expects this method to be non-blocking and return quickly.
- Parameters:
thing
- the thing for which the handler must be unregistered
-
createThing
@Nullable Thing createThing(ThingTypeUID thingTypeUID, Configuration configuration, @Nullable ThingUID thingUID, @Nullable ThingUID bridgeUID) Creates a thing for given arguments.- Parameters:
thingTypeUID
- thing type uid (not null)configuration
- configurationthingUID
- thing uid, which can be nullbridgeUID
- bridge uid, which can be null- Returns:
- created thing
-
removeThing
A thing with the givenThing
UID was removed.- Parameters:
thingUID
- thing UID of the removed object
-