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:

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

Type:
  • string

name :string

Source:

The name of the Item.

Type:
  • string

label :string

Source:

The label attached to the Item.

Type:
  • string

state :string

Source:

The state of the Item.

Type:
  • string

rawState :HostState

Source:

The raw state of the 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:

descendents :Array.<Item>

Source:

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

Type:

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(namespace) → {Object|null}

Source:

Gets metadata with the given name for this Item.

Parameters:
Name Type Description
namespace string

The namespace for the metadata to retrieve

Returns:

metadata or null if the Item has no metadata with the given name

Type
Object | null

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

Source:

Updates or adds the given metadata for 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 metadata or null if the Item has no metadata with the given name

Type
Object | null

removeMetadata(namespace) → {Object|null}

Source:

Removes metadata with a given name from a given Item.

Parameters:
Name Type Description
namespace string

name of the metadata

Returns:

removed metadata or null if the Item has no metadata with the given name

Type
Object | null

sendCommand(value)

Source:
See:
  • sendCommandIfDifferent
  • postUpdate

Sends a command to the Item.

Parameters:
Name Type Description
value string | time.ZonedDateTime | 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 | 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 | 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