Class MagicChattyThingHandler

  • All Implemented Interfaces:
    ThingHandler

    @NonNullByDefault
    public class MagicChattyThingHandler
    extends BaseThingHandler
    ThingHandler that randomly sends numbers and strings to channels based on a configured interval
    Author:
    Stefan Triller - Initial contribution
    • Constructor Detail

      • MagicChattyThingHandler

        public MagicChattyThingHandler​(Thing thing)
    • Method Detail

      • initialize

        public void initialize()
        Description copied from interface: ThingHandler
        Initializes the thing handler, e.g. update thing status, allocate resources, transfer configuration.

        This method is only called, if the Thing contains all required configuration parameters.

        Only Things with status ThingStatus.UNKNOWN, ThingStatus.ONLINE or ThingStatus.OFFLINE are considered as initialized by the framework. To achieve that, the status must be reported via ThingHandlerCallback.statusUpdated(Thing, ThingStatusInfo).

        The framework expects this method to be non-blocking and return quickly. For longer running initializations, the implementation has to take care of scheduling a separate job which must guarantee to set the thing status eventually.

        Any anticipated error situations should be handled gracefully and need to result in ThingStatus.OFFLINE with the corresponding status detail (e.g. *COMMUNICATION_ERROR* or *CONFIGURATION_ERROR* including a meaningful description) instead of throwing exceptions.

        Specified by:
        initialize in interface ThingHandler
        Overrides:
        initialize in class BaseThingHandler
      • dispose

        public void dispose()
        Description copied from interface: ThingHandler
        Disposes the thing handler, e.g. deallocate resources.

        The framework expects this method to be non-blocking and return quickly.

        Specified by:
        dispose in interface ThingHandler
        Overrides:
        dispose in class BaseThingHandler
      • channelLinked

        public void channelLinked​(ChannelUID channelUID)
        Description copied from interface: ThingHandler
        Notifies the handler that a channel was linked.

        This method is only called, if the thing has been initialized (status ONLINE/OFFLINE/UNKNOWN).

        Specified by:
        channelLinked in interface ThingHandler
        Overrides:
        channelLinked in class BaseThingHandler
        Parameters:
        channelUID - UID of the linked channel
      • channelUnlinked

        public void channelUnlinked​(ChannelUID channelUID)
        Description copied from interface: ThingHandler
        Notifies the handler that a channel was unlinked.

        This method is only called, if the thing has been initialized (status ONLINE/OFFLINE/UNKNOWN).

        Specified by:
        channelUnlinked in interface ThingHandler
        Overrides:
        channelUnlinked in class BaseThingHandler
        Parameters:
        channelUID - UID of the unlinked channel
      • handleCommand

        public void handleCommand​(ChannelUID channelUID,
                                  Command command)
        Description copied from interface: ThingHandler
        Handles a command for a given channel.

        This method is only called, if the thing has been initialized (status ONLINE/OFFLINE/UNKNOWN).

        Parameters:
        channelUID - the ChannelUID of the channel to which the command was sent
        command - the Command
      • updateState

        protected void updateState​(ChannelUID channelUID,
                                   State state)
        Description copied from class: BaseThingHandler
        Updates the state of the thing.
        Overrides:
        updateState in class BaseThingHandler
        Parameters:
        channelUID - unique id of the channel, which was updated
        state - new state