Interface Item
- All Superinterfaces:
Identifiable<String>
- All Known Subinterfaces:
ActiveItem
- All Known Implementing Classes:
CallItem
,ColorItem
,ContactItem
,DateTimeItem
,DimmerItem
,GenericItem
,GroupItem
,ImageItem
,LocationItem
,NumberItem
,PlayerItem
,RollershutterItem
,StringItem
,SwitchItem
This interface defines the core features of an openHAB item.
Item instances are used for all stateful services and are especially important for the ItemRegistry
.
- Author:
- Kai Kreuzer - Initial contribution
-
Method Summary
Modifier and TypeMethodDescriptionThis method provides a list of all command types that can be used for this itemThis method provides a list of all data types that can be used to update the item state@Nullable String
Returns the category of the item or null if no category is set.default @Nullable CommandDescription
Returns theCommandDescription
for this item.@Nullable CommandDescription
getCommandDescription
(@Nullable Locale locale) Returns theCommandDescription
for the given locale.Returns a list of the names of the groups this item belongs to.@Nullable String
getLabel()
Returns the label of the item or null if no label is set.getName()
returns the name of the itemgetState()
returns the current state of the item<T extends State>
@Nullable TgetStateAs
(Class<T> typeClass) returns the current state of the item as a specific type@Nullable StateDescription
Returns the first provided state description (uses the default locale).@Nullable StateDescription
getStateDescription
(@Nullable Locale locale) Returns the first provided state description for a given locale.getTags()
Returns a set of tags.getType()
returns the item type as defined byItemFactory
sboolean
Returns true if the item's tags contains the specific tag, otherwise false.Methods inherited from interface org.openhab.core.common.registry.Identifiable
getUID
-
Method Details
-
getState
State getState()returns the current state of the item- Returns:
- the current state
-
getStateAs
returns the current state of the item as a specific type- Returns:
- the current state in the requested type or null, if state cannot be provided as the requested type
-
getName
String getName()returns the name of the item- Returns:
- the name of the item
-
getType
String getType()returns the item type as defined byItemFactory
s- Returns:
- the item type
-
getAcceptedDataTypes
This method provides a list of all data types that can be used to update the item state
Imagine e.g. a dimmer device: It's status could be 0%, 10%, 50%, 100%, but also OFF or ON and maybe UNDEFINED. So the accepted data types would be in this case
PercentType
, andUnDefType
The order of data types denotes the order of preference. So in case a state needs to be converted in order to be accepted, it will be attempted to convert it to a type from top to bottom. Therefore the type with the least information loss should be on top of the list - in the example above the
PercentType
carries more information than the , hence it is listed first.- Returns:
- a list of data types that can be used to update the item state
-
getAcceptedCommandTypes
This method provides a list of all command types that can be used for this item
Imagine e.g. a dimmer device: You could ask it to dim to 0%, 10%, 50%, 100%, but also to turn OFF or ON. So the accepted command types would be in this case
PercentType
,- Returns:
- a list of all command types that can be used for this item
-
getGroupNames
Returns a list of the names of the groups this item belongs to.- Returns:
- list of item group names
-
getTags
Returns a set of tags. If the item is not tagged, an empty set is returned.- Returns:
- set of tags.
-
getLabel
@Nullable String getLabel()Returns the label of the item or null if no label is set.- Returns:
- item label or null
-
hasTag
Returns true if the item's tags contains the specific tag, otherwise false.- Parameters:
tag
- a tag whose presence in the item's tags is to be tested.- Returns:
- true if the item's tags contains the specific tag, otherwise false.
-
getCategory
@Nullable String getCategory()Returns the category of the item or null if no category is set.- Returns:
- category or null
-
getStateDescription
@Nullable StateDescription getStateDescription()Returns the first provided state description (uses the default locale). If options are defined on the channel, they are included in the returned state description.- Returns:
- state description (can be null)
-
getStateDescription
Returns the first provided state description for a given locale. If options are defined on the channel, they are included in the returned state description.- Parameters:
locale
- locale (can be null)- Returns:
- state description (can be null)
-
getCommandDescription
Returns theCommandDescription
for this item. In case no dedicatedCommandDescription
is provided theStateOption
s from theStateDescription
will be served as validCommandOption
s.- Returns:
- the
CommandDescription
for the default locale (can be null).
-
getCommandDescription
Returns theCommandDescription
for the given locale. In case no dedicatedCommandDescription
is provided theStateOption
s from theStateDescription
will be served as validCommandOption
s.- Parameters:
locale
- locale (can be null)- Returns:
- command description (can be null)
-