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 CommandOptions. 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
FieldsFields inherited from class org.openhab.core.thing.binding.AbstractDynamicDescriptionProvider
bundleContext, channelTypeI18nLocalizationService, eventPublisher, itemChannelLinkRegistry -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid@Nullable CommandDescriptiongetCommandDescription(Channel channel, @Nullable CommandDescription originalCommandDescription, @Nullable Locale locale) For a givenChannel, return aCommandDescriptionthat 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 aListofCommandOptions that should be used for the channel.voidsetCommandOptions(ChannelUID channelUID, List<CommandOption> options) For a givenChannelUID, set aListofCommandOptions 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 aListofCommandOptions that should be used for the channel, instead of the one defined statically in theChannelType.- Parameters:
channelUID- theChannelUIDof the channeloptions- aListofCommandOptions
-
getCommandDescription
public @Nullable CommandDescription getCommandDescription(Channel channel, @Nullable CommandDescription originalCommandDescription, @Nullable Locale locale) Description copied from interface:DynamicCommandDescriptionProviderFor a givenChannel, return aCommandDescriptionthat 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:
getCommandDescriptionin 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 aListofCommandOptions that should be used for the channel.- Parameters:
options- aListofCommandOptionschannel- the channellocale- a locale- Returns:
- the localized
ListofCommandOptions
-
deactivate
public void deactivate()- Overrides:
deactivatein classAbstractDynamicDescriptionProvider
-