Class MagicChattyThingHandler
- All Implemented Interfaces:
ThingHandler
- Author:
- Stefan Triller - Initial contribution
-
Field Summary
Fields inherited from class org.openhab.core.thing.binding.BaseThingHandler
scheduler, thing
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
channelLinked
(ChannelUID channelUID) Notifies the handler that a channel was linked.void
channelUnlinked
(ChannelUID channelUID) Notifies the handler that a channel was unlinked.void
dispose()
Disposes the thing handler, e.g.void
handleCommand
(ChannelUID channelUID, Command command) Handles a command for a given channel.void
Initializes the thing handler, e.g.protected void
updateState
(ChannelUID channelUID, State state) Updates the state of the thing.Methods inherited from class org.openhab.core.thing.binding.BaseThingHandler
bridgeStatusChanged, changeThingType, editConfiguration, editProperties, editThing, getBridge, getCallback, getConfig, getConfigAs, getConfigDescription, getConfigDescription, getThing, handleConfigurationUpdate, handleRemoval, isInitialized, isLinked, isLinked, isModifyingCurrentConfig, postCommand, postCommand, sendTimeSeries, sendTimeSeries, setCallback, thingUpdated, triggerChannel, triggerChannel, triggerChannel, triggerChannel, updateConfiguration, updateProperties, updateProperty, updateState, updateStatus, updateStatus, updateStatus, updateThing, validateConfigurationParameters
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.openhab.core.thing.binding.ThingHandler
getServices
-
Constructor Details
-
MagicChattyThingHandler
-
-
Method Details
-
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
Thing
s with statusThingStatus.UNKNOWN
,ThingStatus.ONLINE
orThingStatus.OFFLINE
are considered as initialized by the framework. To achieve that, the status must be reported viaThingHandlerCallback.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. -
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 interfaceThingHandler
- Overrides:
dispose
in classBaseThingHandler
-
channelLinked
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 interfaceThingHandler
- Overrides:
channelLinked
in classBaseThingHandler
- Parameters:
channelUID
- UID of the linked channel
-
channelUnlinked
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 interfaceThingHandler
- Overrides:
channelUnlinked
in classBaseThingHandler
- Parameters:
channelUID
- UID of the unlinked channel
-
handleCommand
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
- theChannelUID
of the channel to which the command was sentcommand
- theCommand
-
updateState
Description copied from class:BaseThingHandler
Updates the state of the thing.- Overrides:
updateState
in classBaseThingHandler
- Parameters:
channelUID
- unique id of the channel, which was updatedstate
- new state
-