Class NumberItem
- All Implemented Interfaces:
Identifiable<String>
,ActiveItem
,Item
,MetadataAwareItem
- Author:
- Kai Kreuzer - Initial contribution
-
Field Summary
Fields inherited from class org.openhab.core.items.GenericItem
category, eventPublisher, groupNames, itemStateConverter, label, listeners, name, state, tags, timeSeriesListeners, type
-
Constructor Summary
ConstructorDescriptionNumberItem
(String name) NumberItem
(String type, String name, @Nullable UnitProvider unitProvider) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addedMetadata
(Metadata metadata) Can be implemented by subclasses to be informed about added metadataThis 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 Class
<? extends javax.measure.Quantity<?>> Returns theDimension
associated with thisNumberItem
, may be null.@Nullable StateDescription
getStateDescription
(@Nullable Locale locale) Returns the first provided state description for a given locale.@Nullable javax.measure.Unit
<? extends javax.measure.Quantity<?>> getUnit()
Get the unit for this item, either: the unit retrieved from theunit
namespace in the item's metadata the default system unit for the item's dimension@Nullable String
Returns the optional unit symbol for thisNumberItem
.void
removedMetadata
(Metadata metadata) Can be implemented by subclasses to be informed about removed metadatavoid
send
(DecimalType command) void
send
(QuantityType<?> command) void
Set a new state.void
setTimeSeries
(TimeSeries timeSeries) Set a new time series.void
updatedMetadata
(Metadata oldMetadata, Metadata newMetadata) Can be implemented by subclasses to be informed about updated metadataMethods inherited from class org.openhab.core.items.GenericItem
addGroupName, addGroupNames, addGroupNames, addStateChangeListener, addTag, addTags, addTags, addTimeSeriesListener, applyState, applyTimeSeries, dispose, equals, getCategory, getCommandDescription, getCommandOptions, getGroupNames, getLabel, getName, getState, getStateAs, getStateDescription, getTags, getType, getUID, hashCode, hasTag, internalSend, isAcceptedState, logSetTypeError, logSetTypeError, notifyListeners, removeAllTags, removeGroupName, removeStateChangeListener, removeTag, removeTimeSeriesListener, send, setCategory, setCommandDescriptionService, setEventPublisher, setItemStateConverter, setLabel, setStateDescriptionService, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.openhab.core.items.Item
getCommandDescription
-
Field Details
-
UNIT_METADATA_NAMESPACE
- See Also:
-
-
Constructor Details
-
NumberItem
-
NumberItem
-
-
Method Details
-
getAcceptedDataTypes
Description copied from interface:Item
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.- Specified by:
getAcceptedDataTypes
in interfaceItem
- Returns:
- a list of data types that can be used to update the item state
-
getAcceptedCommandTypes
Description copied from interface:Item
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
,- Specified by:
getAcceptedCommandTypes
in interfaceItem
- Returns:
- a list of all command types that can be used for this item
-
send
-
send
-
getStateDescription
Description copied from interface:Item
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.- Specified by:
getStateDescription
in interfaceItem
- Overrides:
getStateDescription
in classGenericItem
- Parameters:
locale
- locale (can be null)- Returns:
- state description (can be null)
-
getDimension
Returns theDimension
associated with thisNumberItem
, may be null.- Returns:
- the
Dimension
associated with thisNumberItem
, may be null.
-
setState
Description copied from class:GenericItem
Set a new state. Subclasses may override this method in order to do necessary conversions upfront. Afterwards,GenericItem.applyState(State)
should be called by classes overriding this method.- Overrides:
setState
in classGenericItem
- Parameters:
state
- new state of this item
-
setTimeSeries
Description copied from class:GenericItem
Set a new time series. Subclasses may override this method in order to do necessary conversions upfront. Afterwards,GenericItem.applyTimeSeries(TimeSeries)
should be called by classes overriding this method. A time series may only contain events that are compatible with the item's internal state.- Overrides:
setTimeSeries
in classGenericItem
- Parameters:
timeSeries
- new time series of this item
-
getUnitSymbol
Returns the optional unit symbol for thisNumberItem
.- Returns:
- the optional unit symbol for this
NumberItem
.
-
getUnit
public @Nullable javax.measure.Unit<? extends javax.measure.Quantity<?>> getUnit()Get the unit for this item, either:- the unit retrieved from the
unit
namespace in the item's metadata - the default system unit for the item's dimension
- Returns:
- the
Unit
for this item if available,null
otherwise.
- the unit retrieved from the
-
addedMetadata
Description copied from interface:MetadataAwareItem
Can be implemented by subclasses to be informed about added metadata- Specified by:
addedMetadata
in interfaceMetadataAwareItem
- Parameters:
metadata
- the addedMetadata
object for thisItem
-
updatedMetadata
Description copied from interface:MetadataAwareItem
Can be implemented by subclasses to be informed about updated metadata- Specified by:
updatedMetadata
in interfaceMetadataAwareItem
- Parameters:
oldMetadata
- the oldMetadata
object for thisItem
newMetadata
- the newMetadata
object for thisItem
-
removedMetadata
Description copied from interface:MetadataAwareItem
Can be implemented by subclasses to be informed about removed metadata- Specified by:
removedMetadata
in interfaceMetadataAwareItem
- Parameters:
metadata
- the removedMetadata
object for thisItem
-