Package org.openhab.core.thing.binding
Interface ThingHandlerCallback
@NonNullByDefault
public interface ThingHandlerCallback
ThingHandlerCallback
is callback interface for ThingHandler
s. 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 TypeMethodDescriptionvoid
channelTriggered
(Thing thing, ChannelUID channelUID, String event) Informs the framework that a channel has been triggered.void
configurationUpdated
(Thing thing) Informs about an updated configuration of a thing.createChannelBuilder
(ChannelUID channelUID, ChannelTypeUID channelTypeUID) Creates aChannelBuilder
which is preconfigured with values from the givenChannelType
.createChannelBuilders
(ChannelGroupUID channelGroupUID, ChannelGroupTypeUID channelGroupTypeUID) Creates a list ofChannelBuilder
s which are preconfigured with values from the givenChannelGroupType
.editChannel
(Thing thing, ChannelUID channelUID) Creates aChannelBuilder
which is preconfigured with values from the givenChannel
and allows to modify it.@Nullable Bridge
Returns the bridge of the thing.@Nullable ConfigDescription
getConfigDescription
(ThingTypeUID thingTypeUID) Get theConfigDescription
for aThingTypeUID
@Nullable ConfigDescription
getConfigDescription
(ChannelTypeUID channelTypeUID) Get theConfigDescription
for aChannelTypeUID
boolean
isChannelLinked
(ChannelUID channelUID) Returns whether at least one item is linked for the given UID of the channel.void
migrateThingType
(Thing thing, ThingTypeUID thingTypeUID, Configuration configuration) Informs the framework that the ThingType of the givenThing
should be changed.void
postCommand
(ChannelUID channelUID, Command command) Informs about a command, which is sent from the channel.void
sendTimeSeries
(ChannelUID channelUID, TimeSeries timeSeries) Informs about a time series, whcihs is send from the channel.void
stateUpdated
(ChannelUID channelUID, State state) Informs about an updated state for a channel.void
statusUpdated
(Thing thing, ThingStatusInfo thingStatus) Informs about an updated status of a thing.void
thingUpdated
(Thing thing) Informs about an update of the whole thing.void
validateConfigurationParameters
(Channel channel, Map<String, Object> configurationParameters) Validates the given configuration parameters against the configuration description.void
validateConfigurationParameters
(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 theThing
is 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 theConfigDescription
for aChannelTypeUID
- Parameters:
channelTypeUID
- the channel type UID- Returns:
- the corresponding configuration description (or null if not found)
-
getConfigDescription
Get theConfigDescription
for 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 givenThing
should 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 aChannelBuilder
which is preconfigured with values from the givenChannelType
.- Parameters:
channelUID
- the UID of theChannel
to be createdchannelTypeUID
- theChannelTypeUID
for which theChannel
should be created- Returns:
- a preconfigured
ChannelBuilder
- Throws:
IllegalArgumentException
- if the referencedChannelType
is not known
-
editChannel
Creates aChannelBuilder
which is preconfigured with values from the givenChannel
and 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 theChannel
to be edited- Returns:
- a preconfigured
ChannelBuilder
- Throws:
IllegalArgumentException
- if noChannel
with the given UID exists for the givenThing
-
createChannelBuilders
List<ChannelBuilder> createChannelBuilders(ChannelGroupUID channelGroupUID, ChannelGroupTypeUID channelGroupTypeUID) Creates a list ofChannelBuilder
s which are preconfigured with values from the givenChannelGroupType
.- Parameters:
channelGroupUID
- the UID of the channel group to be createdchannelGroupTypeUID
- theChannelGroupUID
for which theChannel
s should be created- Returns:
- a list of preconfigured
ChannelBuilder
s - Throws:
IllegalArgumentException
- if the referencedChannelGroupType
is 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
-ThingUID
UID of the bridge (must not be null)- Returns:
- returns the bridge of the thing or null if the thing has no bridge
-