Module: OpenHAB::Core::EntityLookup

Overview

Note:

Thing UIDs are separated by a colon ‘:`. Since it is not a valid symbol for an identifier, it must be replaced with an underscore `_`. So to access `astro:sun:home`, use `astro_sun_home` as an alternative to `things`

Manages access to openHAB entities

You can access openHAB items and things directly using their name, anywhere ‘EntityLookup` is available.

Examples:

Accessing Items and Groups

gAll_Lights       # Access the gAll_Lights group. It is the same as items["gAll_Lights"]
Kitchen_Light.on  # The openHAB object for the Kitchen_Light item and send an ON command

Accessing Things

smtp_mail_local.send_mail('[email protected]', 'Subject', 'Dear Person, ...')
# Is equivalent to:
things['smtp:mail:local'].send_mail('[email protected]', 'Subject', 'Dear Person, ...')

See Also:

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missingItem, ...

Automatically looks up openHAB items and things in appropriate registries

Returns:



74
75
76
77
78
79
80
81
# File 'lib/openhab/core/entity_lookup.rb', line 74

ruby2_keywords def method_missing(method, *args)
  return super unless args.empty? && !block_given?

  logger.trace { "method missing, performing openHAB Lookup for: #{method}" }
  EntityLookup.lookup_entity(method,
                             create_dummy_items: self.class.respond_to?(:create_dummy_items?) &&
                               self.class.create_dummy_items?) || super
end