Package org.openhab.core.thing.binding
Interface ThingHandlerCallback
@NonNullByDefault
public interface ThingHandlerCallback
ThingHandlerCallback is callback interface for ThingHandlers. The implementation of a
ThingHandler must use the callback to inform the framework about changes like state updates, status updated
or an update of the whole thing.- Author:
- Dennis Nobel - Initial contribution, Stefan Bußweiler - Added new thing status info, added new configuration update info, Christoph Weitkamp - Moved OSGI ServiceTracker from BaseThingHandler to ThingHandlerCallback, Christoph Weitkamp - Added preconfigured ChannelGroupBuilder
-
Method Summary
Modifier and TypeMethodDescriptionvoidchannelTriggered(Thing thing, ChannelUID channelUID, String event) Informs the framework that a channel has been triggered.voidconfigurationUpdated(Thing thing) Informs about an updated configuration of a thing.createChannelBuilder(ChannelUID channelUID, ChannelTypeUID channelTypeUID) Creates aChannelBuilderwhich is preconfigured with values from the givenChannelType.createChannelBuilders(ChannelGroupUID channelGroupUID, ChannelGroupTypeUID channelGroupTypeUID) Creates a list ofChannelBuilders which are preconfigured with values from the givenChannelGroupType.editChannel(Thing thing, ChannelUID channelUID) Creates aChannelBuilderwhich is preconfigured with values from the givenChanneland allows to modify it.@Nullable BridgeReturns the bridge of the thing.@Nullable ConfigDescriptiongetConfigDescription(ThingTypeUID thingTypeUID) Get theConfigDescriptionfor aThingTypeUID@Nullable ConfigDescriptiongetConfigDescription(ChannelTypeUID channelTypeUID) Get theConfigDescriptionfor aChannelTypeUIDbooleanisChannelLinked(ChannelUID channelUID) Returns whether at least one item is linked for the given UID of the channel.voidmigrateThingType(Thing thing, ThingTypeUID thingTypeUID, Configuration configuration) Informs the framework that the ThingType of the givenThingshould be changed.voidpostCommand(ChannelUID channelUID, Command command) Informs about a command, which is sent from the channel.voidsendTimeSeries(ChannelUID channelUID, TimeSeries timeSeries) Informs about a time series, whcihs is send from the channel.voidstateUpdated(ChannelUID channelUID, State state) Informs about an updated state for a channel.voidstatusUpdated(Thing thing, ThingStatusInfo thingStatus) Informs about an updated status of a thing.voidthingUpdated(Thing thing) Informs about an update of the whole thing.voidvalidateConfigurationParameters(Channel channel, Map<String, Object> configurationParameters) Validates the given configuration parameters against the configuration description.voidvalidateConfigurationParameters(Thing thing, Map<String, Object> configurationParameters) Validates the given configuration parameters against the configuration description.
-
Method Details
-
stateUpdated
Informs about an updated state for a channel.- Parameters:
channelUID- channel UID (must not be null)state- state (must not be null)
-
postCommand
Informs about a command, which is sent from the channel.- Parameters:
channelUID- channel UIDcommand- command
-
sendTimeSeries
Informs about a time series, whcihs is send from the channel.- Parameters:
channelUID- channel UIDtimeSeries- time series
-
statusUpdated
Informs about an updated status of a thing.- Parameters:
thing- thing (must not be null)thingStatus- thing status (must not be null)
-
thingUpdated
Informs about an update of the whole thing.- Parameters:
thing- thing that was updated (must not be null)- Throws:
IllegalStateException- if theThingis can't be found
-
validateConfigurationParameters
Validates the given configuration parameters against the configuration description.- Parameters:
thing- thing with the updated configuration (must not be null)configurationParameters- the configuration parameters to be validated- Throws:
ConfigValidationException- if one or more of the given configuration parameters do not match their declarations in the configuration description
-
validateConfigurationParameters
Validates the given configuration parameters against the configuration description.- Parameters:
channel- channel with the updated configuration (must not be null)configurationParameters- the configuration parameters to be validated- Throws:
ConfigValidationException- if one or more of the given configuration parameters do not match their declarations in the configuration description
-
getConfigDescription
Get theConfigDescriptionfor aChannelTypeUID- Parameters:
channelTypeUID- the channel type UID- Returns:
- the corresponding configuration description (or null if not found)
-
getConfigDescription
Get theConfigDescriptionfor aThingTypeUID- Parameters:
thingTypeUID- the thing type UID- Returns:
- the corresponding configuration description (or null if not found)
-
configurationUpdated
Informs about an updated configuration of a thing.- Parameters:
thing- thing with the updated configuration (must no be null)
-
migrateThingType
Informs the framework that the ThingType of the givenThingshould be changed.- Parameters:
thing- thing that should be migrated to another ThingType (must not be null)thingTypeUID- the new type of the thing (must not be null)configuration- a configuration that should be applied to the givenThing
-
channelTriggered
Informs the framework that a channel has been triggered.- Parameters:
thing- thing (must not be null)channelUID- UID of the channel over which has been triggered.event- Event.
-
createChannelBuilder
Creates aChannelBuilderwhich is preconfigured with values from the givenChannelType.- Parameters:
channelUID- the UID of theChannelto be createdchannelTypeUID- theChannelTypeUIDfor which theChannelshould be created- Returns:
- a preconfigured
ChannelBuilder - Throws:
IllegalArgumentException- if the referencedChannelTypeis not known
-
editChannel
Creates aChannelBuilderwhich is preconfigured with values from the givenChanneland allows to modify it. The methodsBaseThingHandler.editThing()andBaseThingHandler.updateThing(Thing)must be called to persist the changes.- Parameters:
thing-Thing(must not be null)channelUID- the UID of theChannelto be edited- Returns:
- a preconfigured
ChannelBuilder - Throws:
IllegalArgumentException- if noChannelwith the given UID exists for the givenThing
-
createChannelBuilders
List<ChannelBuilder> createChannelBuilders(ChannelGroupUID channelGroupUID, ChannelGroupTypeUID channelGroupTypeUID) Creates a list ofChannelBuilders which are preconfigured with values from the givenChannelGroupType.- Parameters:
channelGroupUID- the UID of the channel group to be createdchannelGroupTypeUID- theChannelGroupUIDfor which theChannels should be created- Returns:
- a list of preconfigured
ChannelBuilders - Throws:
IllegalArgumentException- if the referencedChannelGroupTypeis not known
-
isChannelLinked
Returns whether at least one item is linked for the given UID of the channel.- Parameters:
channelUID- UID of the channel (must not be null)- Returns:
- true if at least one item is linked, false otherwise
-
getBridge
Returns the bridge of the thing.- Parameters:
bridgeUID-ThingUIDUID of the bridge (must not be null)- Returns:
- returns the bridge of the thing or null if the thing has no bridge
-