Class: OpenHAB::DSL::Items::GroupItemBuilder

Inherits:
ItemBuilder
  • Object
show all
Includes:
Builder
Defined in:
lib/openhab/dsl/items/builder.rb

Overview

Allows customizing a group. You can also call any method from Builder, and those items will automatically be a member of this group.

Constant Summary

Constants included from OpenHAB::DSL

VERSION

Instance Attribute Summary collapse

Attributes inherited from ItemBuilder

#autoupdate, #channels, #dimension, #format, #groups, #icon, #label, #metadata, #name, #state, #tags, #type

Instance Method Summary collapse

Methods included from Builder

#color_item, #contact_item, #date_time_item, #dimmer_item, #group_item, #image_item, #location_item, #number_item, #player_item, #rollershutter_item, #string_item, #switch_item

Methods included from OpenHAB::DSL

after, between, debounce_for, ensure_states, holiday_file, holiday_file!, items, only_every, persistence, persistence!, profile, provider, provider!, rule, rules, scene, script, shared_cache, sitemaps, store_states, things, throttle_for, timers, transform, unit, unit!

Methods included from Rules::Terse

#changed, #channel, #channel_linked, #channel_unlinked, #cron, #every, #item_added, #item_removed, #item_updated, #on_start, #received_command, #thing_added, #thing_removed, #thing_updated, #updated

Methods included from Core::ScriptHandling

script_loaded, script_unloaded

Methods included from Core::Actions

notify

Methods included from Core::EntityLookup

#method_missing

Methods inherited from ItemBuilder

#alexa, #channel, #expire, #ga, #group, #homekit, #inspect, #tag, #to_s

Constructor Details

#initialize(*args, type: nil, function: nil, thing: nil, **kwargs) ⇒ GroupItemBuilder

Returns a new instance of GroupItemBuilder.

Parameters:

Raises:

  • (ArgumentError)


601
602
603
604
605
606
607
608
609
# File 'lib/openhab/dsl/items/builder.rb', line 601

def initialize(*args, type: nil, function: nil, thing: nil, **kwargs)
  raise ArgumentError, "invalid function #{function}" if function && !function.match?(FUNCTION_REGEX)
  raise ArgumentError, "state cannot be set on GroupItems" if kwargs[:state]

  super(type, *args, **kwargs)
  @function = function
  @members = []
  @thing = thing
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class OpenHAB::DSL

Instance Attribute Details

#functionString?

The combiner function for this group

Returns:

  • (String, nil)


582
583
584
# File 'lib/openhab/dsl/items/builder.rb', line 582

def function
  @function
end

#label_baseString?

A prefix to be added to the label of any member items

Returns:

  • (String, nil)


591
592
593
# File 'lib/openhab/dsl/items/builder.rb', line 591

def label_base
  @label_base
end

#membersArray<ItemBuilder> (readonly)

Members to be created in this group

Returns:



594
595
596
# File 'lib/openhab/dsl/items/builder.rb', line 594

def members
  @members
end

#name_baseString?

A prefix to be added to the name of any member items

Returns:

  • (String, nil)


588
589
590
# File 'lib/openhab/dsl/items/builder.rb', line 588

def name_base
  @name_base
end

#thingCore::Things::ThingUID, ...

A thing to be used as the base for the channel of any member items

Returns:



585
586
587
# File 'lib/openhab/dsl/items/builder.rb', line 585

def thing
  @thing
end

#unitString? (readonly)

Unit (for number items only)

Due to ItemBuilder#format inference, setting the unit is cross-compatible with openHAB 3.4 and 4.0.

Returns:

  • (String, nil)


563
564
565
# File 'lib/openhab/dsl/items/builder.rb', line 563

def unit
  @unit
end