Item

items. Item

Class representing an openHAB Item

Members

descendents :Array:.<Item:>

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

Source:

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

Type:
  • Array:.<Item:>

groupNames

Description:
  • Gets the names of the groups this Item is member of.

Source:

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

isUninitialized :boolean

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

Source:

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

Type:
  • boolean

label :string

Description:
  • Label attached to Item

Source:

Label attached to Item

Type:
  • string

members :Array:.<Item:>

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

Source:

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

Type:
  • Array:.<Item:>

name :string

Description:
  • Name of Item

Source:

Name of Item

Type:
  • string

numericState :number|null

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

Source:

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

Type:
  • number | null

persistence :ItemPersistence

Description:
Source:

Access historical states for this Item items.ItemPersistence

Type:
  • ItemPersistence

quantityState :Quantity|null

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

Source:

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

Type:

rawItem :HostItem

Description:
  • raw Java Item

Source:

raw Java Item

Type:
  • HostItem

rawState :HostState

Description:
Source:

Raw state of Item, as a Java State object

Type:
  • HostState

semantics :ItemSemantics

Description:
Source:

Access Semantic information of this Item items.ItemSemantics

Type:
  • ItemSemantics

state :string

Description:
  • String representation of the Item state.

Source:

String representation of the Item state.

Type:
  • string

tags :Array:.<string:>

Description:
  • Gets the tags from this Item

Source:

Gets the tags from this Item

Type:
  • Array:.<string:>

type :string

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

Source:

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

Type:
  • string

Methods

addGroups(…groupNamesOrItems)

Description:
  • Adds groups to this Item

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

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

addTags(…tagNames)

Description:
  • Adds tags to this Item

Source:
Parameters:
Name Type Attributes Description
tagNames string <repeatable>

names of the tags to add

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

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

Source:
See:
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

postToggleUpdate()

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

Source:
Throws:

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

postUpdate(value)

Description:
  • Posts an update to the Item.

Source:
See:
  • postToggleUpdate
  • sendCommand
Parameters:
Name Type Description
value string | number | time.ZonedDateTime | Quantity | HostState

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

removeGroups(…groupNamesOrItems)

Description:
  • Removes groups from this Item

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

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

removeMetadata(namespaceopt) → {ItemMetadata|null}

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

Source:
See:
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

removeTags(…tagNames)

Description:
  • Removes tags from this Item

Source:
Parameters:
Name Type Attributes Description
tagNames string <repeatable>

names of the tags to remove

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

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

Source:
See:
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

sendCommand(value)

Description:
  • Sends a command to the Item.

Source:
See:
  • sendCommandIfDifferent
  • postUpdate
Parameters:
Name Type Description
value string | number | time.ZonedDateTime | Quantity | HostState

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

sendCommandIfDifferent(value) → {boolean}

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

Source:
See:
  • sendCommand
Parameters:
Name Type Description
value string | number | 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

sendDecreaseCommand(value) → {boolean}

Description:
  • Decreases the value of this Item to the given value by sending a command, but only if the current state is greater than that value.

Source:
Parameters:
Name Type Description
value number | Quantity | HostState

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

Returns:

true if the command was sent, false otherwise

Type
boolean

sendIncreaseCommand(value) → {boolean}

Description:
  • Increase the value of this Item to the given value by sending a command, but only if the current state is less than that value.

Source:
Parameters:
Name Type Description
value number | Quantity | HostState

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

Returns:

true if the command was sent, false otherwise

Type
boolean

sendToggleCommand()

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

Source:
Throws:

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