Package org.openhab.core.thing.binding
Class BaseDynamicCommandDescriptionProvider
java.lang.Object
org.openhab.core.thing.binding.AbstractDynamicDescriptionProvider
org.openhab.core.thing.binding.BaseDynamicCommandDescriptionProvider
- All Implemented Interfaces:
DynamicCommandDescriptionProvider
@NonNullByDefault
public abstract class BaseDynamicCommandDescriptionProvider
extends AbstractDynamicDescriptionProvider
implements DynamicCommandDescriptionProvider
The
BaseDynamicCommandDescriptionProvider
provides a base implementation for the
DynamicCommandDescriptionProvider
.
It provides localized dynamic CommandOption
s. Therefore the inheriting class has to request a reference for
the ChannelTypeI18nLocalizationService
on its own.
- Author:
- Christoph Weitkamp - Initial contribution, Christoph Weitkamp - Added ChannelStateDescriptionChangedEvent
-
Field Summary
Fields inherited from class org.openhab.core.thing.binding.AbstractDynamicDescriptionProvider
bundleContext, channelTypeI18nLocalizationService, eventPublisher, itemChannelLinkRegistry
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
@Nullable CommandDescription
getCommandDescription
(Channel channel, @Nullable CommandDescription originalCommandDescription, @Nullable Locale locale) For a givenChannel
, return aCommandDescription
that should be used for the channel, instead of the one defined statically in theChannelType
.protected List
<CommandOption> localizedCommandOptions
(List<CommandOption> options, Channel channel, @Nullable Locale locale) Localizes aList
ofCommandOption
s that should be used for the channel.void
setCommandOptions
(ChannelUID channelUID, List<CommandOption> options) For a givenChannelUID
, set aList
ofCommandOption
s that should be used for the channel, instead of the one defined statically in theChannelType
.Methods inherited from class org.openhab.core.thing.binding.AbstractDynamicDescriptionProvider
activate, postEvent
-
Field Details
-
channelOptionsMap
-
-
Constructor Details
-
BaseDynamicCommandDescriptionProvider
public BaseDynamicCommandDescriptionProvider()
-
-
Method Details
-
setCommandOptions
For a givenChannelUID
, set aList
ofCommandOption
s that should be used for the channel, instead of the one defined statically in theChannelType
.- Parameters:
channelUID
- theChannelUID
of the channeloptions
- aList
ofCommandOption
s
-
getCommandDescription
public @Nullable CommandDescription getCommandDescription(Channel channel, @Nullable CommandDescription originalCommandDescription, @Nullable Locale locale) Description copied from interface:DynamicCommandDescriptionProvider
For a givenChannel
, return aCommandDescription
that should be used for the channel, instead of the one defined statically in theChannelType
. For a particular channel, there should be only one provider of the dynamic command description. When more than one description is provided for the same channel (by different providers), only one will be used, from the provider that registered first. If the given channel will not be managed by the provider null should be returned. You never must return the original command description in such case.- Specified by:
getCommandDescription
in interfaceDynamicCommandDescriptionProvider
- Parameters:
channel
- channeloriginalCommandDescription
- original command description retrieved from the channel type this is the description to be replaced by the provided onelocale
- locale (can be null)- Returns:
- command description or null if none provided
-
localizedCommandOptions
protected List<CommandOption> localizedCommandOptions(List<CommandOption> options, Channel channel, @Nullable Locale locale) Localizes aList
ofCommandOption
s that should be used for the channel.- Parameters:
options
- aList
ofCommandOption
schannel
- the channellocale
- a locale- Returns:
- the localized
List
ofCommandOption
s
-
deactivate
public void deactivate()- Overrides:
deactivate
in classAbstractDynamicDescriptionProvider
-