Class NumberItem
- All Implemented Interfaces:
Identifiable<String>,ActiveItem,Item,MetadataAwareItem
- Author:
- Kai Kreuzer - Initial contribution
-
Field Summary
FieldsFields inherited from class org.openhab.core.items.GenericItem
category, eventPublisher, groupNames, itemStateConverter, label, lastState, lastStateChange, lastStateUpdate, listeners, name, state, tags, timeSeriesListeners, type -
Constructor Summary
ConstructorsConstructorDescriptionNumberItem(String name) NumberItem(String type, String name, @Nullable UnitProvider unitProvider) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddedMetadata(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 theDimensionassociated with thisNumberItem, may be null.@Nullable StateDescriptiongetStateDescription(@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 theunitnamespace in the item's metadata the default system unit for the item's dimension@Nullable StringReturns the optional unit symbol for thisNumberItem.voidremovedMetadata(Metadata metadata) Can be implemented by subclasses to be informed about removed metadatavoidsend(DecimalType command) Send a DecimalType command to the item.voidsend(DecimalType command, @Nullable String source) Send a DecimalType command to the item.voidsend(QuantityType<?> command) Send a QuantityType command to the item.voidsend(QuantityType<?> command, @Nullable String source) Send a QuantityType command to the item.voidSet a new state.voidsetTimeSeries(TimeSeries timeSeries) Set a new time series.voidupdatedMetadata(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, getLastState, getLastStateChange, getLastStateUpdate, getName, getState, getStateAs, getStateDescription, getTags, getType, getUID, hashCode, hasTag, internalSend, isAcceptedState, logSetTypeError, logSetTypeError, notifyListeners, removeAllTags, removeGroupName, removeStateChangeListener, removeTag, removeTimeSeriesListener, send, send, setCategory, setCommandDescriptionService, setEventPublisher, setItemStateConverter, setLabel, setState, setStateDescriptionService, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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:ItemThis 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, andUnDefTypeThe 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
PercentTypecarries more information than the , hence it is listed first.- Specified by:
getAcceptedDataTypesin interfaceItem- Returns:
- a list of data types that can be used to update the item state
-
getAcceptedCommandTypes
Description copied from interface:ItemThis 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:
getAcceptedCommandTypesin interfaceItem- Returns:
- a list of all command types that can be used for this item
-
send
Send a DecimalType command to the item.- Parameters:
command- the command to be sent
-
send
Send a DecimalType command to the item.- Parameters:
command- the command to be sentsource- the source of the command. See https://www.openhab.org/docs/developer/utils/events.html#the-core-events
-
send
Send a QuantityType command to the item.- Parameters:
command- the command to be sent
-
send
Send a QuantityType command to the item.- Parameters:
command- the command to be sentsource- the source of the command. See https://www.openhab.org/docs/developer/utils/events.html#the-core-events
-
getStateDescription
Description copied from interface:ItemReturns 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:
getStateDescriptionin interfaceItem- Overrides:
getStateDescriptionin classGenericItem- Parameters:
locale- locale (can be null)- Returns:
- state description (can be null)
-
getDimension
Returns theDimensionassociated with thisNumberItem, may be null.- Returns:
- the
Dimensionassociated with thisNumberItem, may be null.
-
setState
Description copied from class:GenericItemSet 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:
setStatein classGenericItem- Parameters:
state- new state of this item
-
setTimeSeries
Description copied from class:GenericItemSet 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:
setTimeSeriesin 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
unitnamespace in the item's metadata - the default system unit for the item's dimension
- Returns:
- the
Unitfor this item if available,nullotherwise.
- the unit retrieved from the
-
addedMetadata
Description copied from interface:MetadataAwareItemCan be implemented by subclasses to be informed about added metadata- Specified by:
addedMetadatain interfaceMetadataAwareItem- Parameters:
metadata- the addedMetadataobject for thisItem
-
updatedMetadata
Description copied from interface:MetadataAwareItemCan be implemented by subclasses to be informed about updated metadata- Specified by:
updatedMetadatain interfaceMetadataAwareItem- Parameters:
oldMetadata- the oldMetadataobject for thisItemnewMetadata- the newMetadataobject for thisItem
-
removedMetadata
Description copied from interface:MetadataAwareItemCan be implemented by subclasses to be informed about removed metadata- Specified by:
removedMetadatain interfaceMetadataAwareItem- Parameters:
metadata- the removedMetadataobject for thisItem
-