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 Details

    • stateUpdated

      void stateUpdated(ChannelUID channelUID, State state)
      Informs about an updated state for a channel.
      Parameters:
      channelUID - channel UID (must not be null)
      state - state (must not be null)
    • postCommand

      void postCommand(ChannelUID channelUID, Command command)
      Informs about a command, which is sent from the channel.
      Parameters:
      channelUID - channel UID
      command - command
    • sendTimeSeries

      void sendTimeSeries(ChannelUID channelUID, TimeSeries timeSeries)
      Informs about a time series, whcihs is send from the channel.
      Parameters:
      channelUID - channel UID
      timeSeries - time series
    • statusUpdated

      void statusUpdated(Thing thing, ThingStatusInfo thingStatus)
      Informs about an updated status of a thing.
      Parameters:
      thing - thing (must not be null)
      thingStatus - thing status (must not be null)
    • thingUpdated

      void thingUpdated(Thing thing)
      Informs about an update of the whole thing.
      Parameters:
      thing - thing that was updated (must not be null)
      Throws:
      IllegalStateException - if the Thing is can't be found
    • validateConfigurationParameters

      void validateConfigurationParameters(Thing thing, Map<String,Object> configurationParameters)
      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

      void validateConfigurationParameters(Channel channel, Map<String,Object> configurationParameters)
      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

      @Nullable ConfigDescription getConfigDescription(ChannelTypeUID channelTypeUID)
      Parameters:
      channelTypeUID - the channel type UID
      Returns:
      the corresponding configuration description (or null if not found)
    • getConfigDescription

      @Nullable ConfigDescription getConfigDescription(ThingTypeUID thingTypeUID)
      Parameters:
      thingTypeUID - the thing type UID
      Returns:
      the corresponding configuration description (or null if not found)
    • configurationUpdated

      void configurationUpdated(Thing thing)
      Informs about an updated configuration of a thing.
      Parameters:
      thing - thing with the updated configuration (must no be null)
    • migrateThingType

      void migrateThingType(Thing thing, ThingTypeUID thingTypeUID, Configuration configuration)
      Informs the framework that the ThingType of the given Thing 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 given Thing
    • channelTriggered

      void channelTriggered(Thing thing, ChannelUID channelUID, String event)
      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

      ChannelBuilder createChannelBuilder(ChannelUID channelUID, ChannelTypeUID channelTypeUID)
      Creates a ChannelBuilder which is preconfigured with values from the given ChannelType.
      Parameters:
      channelUID - the UID of the Channel to be created
      channelTypeUID - the ChannelTypeUID for which the Channel should be created
      Returns:
      a preconfigured ChannelBuilder
      Throws:
      IllegalArgumentException - if the referenced ChannelType is not known
    • editChannel

      ChannelBuilder editChannel(Thing thing, ChannelUID channelUID)
      Creates a ChannelBuilder which is preconfigured with values from the given Channel and allows to modify it. The methods BaseThingHandler.editThing() and BaseThingHandler.updateThing(Thing) must be called to persist the changes.
      Parameters:
      thing - Thing (must not be null)
      channelUID - the UID of the Channel to be edited
      Returns:
      a preconfigured ChannelBuilder
      Throws:
      IllegalArgumentException - if no Channel with the given UID exists for the given Thing
    • createChannelBuilders

      List<ChannelBuilder> createChannelBuilders(ChannelGroupUID channelGroupUID, ChannelGroupTypeUID channelGroupTypeUID)
      Creates a list of ChannelBuilders which are preconfigured with values from the given ChannelGroupType.
      Parameters:
      channelGroupUID - the UID of the channel group to be created
      channelGroupTypeUID - the ChannelGroupUID for which the Channels should be created
      Returns:
      a list of preconfigured ChannelBuilders
      Throws:
      IllegalArgumentException - if the referenced ChannelGroupType is not known
    • isChannelLinked

      boolean isChannelLinked(ChannelUID channelUID)
      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

      @Nullable Bridge getBridge(ThingUID bridgeUID)
      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