Item

items. Item

Class representing an openHAB Item

Members

rawItem :HostItem

Source:

raw Java Item

Type:
  • HostItem

history :ItemHistory

Source:

Access historical states for this Item items.ItemHistory

Type:
  • ItemHistory

semantics :ItemSemantics

Source:

Access Semantic information of this Item items.ItemSemantics

Type:
  • ItemSemantics

type :string

Source:

Type of Item: the Simple (without package) name of the Java Item type, such as 'Switch'.

Type:
  • string

name :string

Source:

Name of Item

Type:
  • string

label :string

Source:

Label attached to Item

Type:
  • string

state :string

Source:

String representation of the Item state.

Type:
  • string

numericState :number|null

Source:

Numeric representation of Item state, or null if state is not numeric

Type:
  • number | null

quantityState :Quantity|null

Source:

Item state as Quantity or null if state is not Quantity-compatible or Quantity would be unit-less (without unit)

Type:

rawState :HostState

Source:

Raw state of Item, as a Java State object

Type:
  • HostState

members :Array.<Item>

Source:

Members / children / direct descendents of the current group Item (as returned by 'getMembers()'). Must be a group Item.

Type:
  • Array.<Item>

descendents :Array.<Item>

Source:

All descendents of the current group Item (as returned by 'getAllMembers()'). Must be a group Item.

Type:
  • Array.<Item>

isUninitialized :boolean

Source:

Whether this Item is uninitialized (true if it has not been initialized).

Type:
  • boolean

groupNames

Source:

Gets the names of the groups this Item is member of.

tags :Array.<string>

Source:

Gets the tags from this Item

Type:
  • Array.<string>

Methods

getMetadata(namespaceopt) → {Object|ItemMetadata|null}

Source:
See:

Gets metadata of a single namespace or of all namespaces from this Item.

Example
// Get metadata of ALL namespaces
var meta = Item.getMetadata();
var namespaces = Object.keys(meta); // Get metadata namespaces
// Get metadata of a single namespace
meta = Item.getMetadata('expire');
Parameters:
Name Type Attributes Description
namespace string <optional>

name of the metadata: if provided, only metadata of this namespace is returned, else all metadata is returned

Returns:

all metadata as an object with the namespaces as properties OR metadata of a single namespace or null if that namespace doesn't exist; the metadata itself is of type items.metadata.ItemMetadata

Type
Object | ItemMetadata | null

replaceMetadata(namespace, value, configurationopt) → {Object|null}

Source:
See:

Updates or adds metadata of a single namespace to this Item.

Parameters:
Name Type Attributes Description
namespace string

name of the metadata

value string

value for this metadata

configuration object <optional>

optional metadata configuration

Returns:

old items.metadata.ItemMetadata or null if the Item has no metadata with the given name

Type
Object | null

removeMetadata(namespaceopt) → {ItemMetadata|null}

Source:
See:

Removes metadata of a single namespace or of all namespaces from a given Item.

Parameters:
Name Type Attributes Description
namespace string <optional>

name of the metadata: if provided, only metadata of this namespace is removed, else all metadata is removed

Returns:

removed items.metadata.ItemMetadata OR null if the Item has no metadata under the given namespace or all metadata was removed

Type
ItemMetadata | null

sendCommand(value)

Source:
See:
  • sendCommandIfDifferent
  • postUpdate

Sends a command to the Item.

Parameters:
Name Type Description
value string | time.ZonedDateTime | Quantity | HostState

the value of the command to send, such as 'ON'

sendCommandIfDifferent(value) → {boolean}

Source:
See:
  • sendCommand

Sends a command to the Item, but only if the current state is not what is being sent.

Parameters:
Name Type Description
value string | time.ZonedDateTime | Quantity | HostState

the value of the command to send, such as 'ON'

Returns:

true if the command was sent, false otherwise

Type
boolean

getToggleState()

Source:

Calculates the toggled state of this Item. For Items like Color and Dimmer, getStateAs(OnOffType) is used and the toggle calculated off of that.

Throws:

error if the Item is uninitialized or is a type that doesn't make sense to toggle

Returns:

the toggled state (e.g. 'OFF' if the Item is 'ON')

sendToggleCommand()

Source:

Sends a command to flip the Item's state (e.g. if it is 'ON' an 'OFF' command is sent).

Throws:

error if the Item is uninitialized or a type that cannot be toggled or commanded

postToggleUpdate()

Source:

Posts an update to flip the Item's state (e.g. if it is 'ON' an 'OFF' update is posted).

Throws:

error if the Item is uninitialized or a type that cannot be toggled

postUpdate(value)

Source:
See:
  • postToggleUpdate
  • sendCommand

Posts an update to the Item.

Parameters:
Name Type Description
value string | time.ZonedDateTime | Quantity | HostState

the value of the command to send, such as 'ON'

addGroups(…groupNamesOrItems)

Source:

Adds groups to this Item

Parameters:
Name Type Attributes Description
groupNamesOrItems string | Item <repeatable>

one or more names of the groups (or the group Items themselves)

removeGroups(…groupNamesOrItems)

Source:

Removes groups from this Item

Parameters:
Name Type Attributes Description
groupNamesOrItems string | Item <repeatable>

one or more names of the groups (or the group Items themselves)

addTags(…tagNames)

Source:

Adds tags to this Item

Parameters:
Name Type Attributes Description
tagNames string <repeatable>

names of the tags to add

removeTags(…tagNames)

Source:

Removes tags from this Item

Parameters:
Name Type Attributes Description
tagNames string <repeatable>

names of the tags to remove