Class: OpenHAB::Core::Things::ChannelUID

Inherits:
Object
  • Object
show all
Defined in:
lib/openhab/core/things/channel_uid.rb

Overview

ChannelUID represents a unique identifier for channels.

Instance Attribute Summary collapse

Instance Attribute Details

#itemItem? (readonly)

Return the item if this channel is linked with an item. If a channel is linked to more than one item, this method only returns the first item.

Returns:



33
34
35
# File 'lib/openhab/core/things/channel_uid.rb', line 33

def item
  items.first
end

#itemsArray<Item> (readonly)

Returns all of the channel's linked items.

Returns:

  • (Array<Item>)

    An array of things or an empty array



44
45
46
47
# File 'lib/openhab/core/things/channel_uid.rb', line 44

def items
  registry = OSGi.service("org.openhab.core.thing.link.ItemChannelLinkRegistry")
  registry.get_linked_items(self).map { |i| Items::Proxy.new(i) }
end

#thingThing? (readonly)

Return the thing this channel is associated with.

Returns:



21
22
23
# File 'lib/openhab/core/things/channel_uid.rb', line 21

def thing
  EntityLookup.lookup_thing(thing_uid)
end