Skip to content
ggodart edited this page Jan 1, 2021 · 7 revisions

Group

See original

SYNOPSIS

  $outside_lights = new Group($light1, $light2, $light3);
  $outside_lights-> add($light4, $light5);
  $outside_lights-> add($light6);
  set $outside_lights ON if time_now("$Time_Sunset + 0:15");

  for my $item (list $outside_lights) {
    print "member = $item->{object_name}\n";
  }

  if (my $member_name = member_changed $outside_lights) {
    my $member = &get_object_by_name($member_name);
    print_log "Group member $member_name changed to $member->{state}"
  }

  my @members = member_changed_log $sensors;

  # turn off all but the bedroom light when we are getting ready for bed
  if( state_now $bedroom_control eq ON ) {
    my $all = new Group(list $All_Lights);
    $all -> remove ( $master_bedroom );
    set $master_bedroom ON;
    set $all OFF;
  }

See mh/code/examples/test_group.pl and mh/code/public/monitor_occupancy_jason.pl for more examples.

DESCRIPTION

You can use this object to group and operate on groups of items:

INHERITS

Generic_Item

Items.mht

Defined in items.mht as

#GROUP, group_name,
GROUP, Lamps, 

METHODS

Method Description
new(@item_list)
add(@item_list)
set
list
member_changed Returns a member object name whenever one changes
member_changed_log Returns a list of recently changed members. The first one was the most recently changed.
remove Remove an item from a group

INHERITED METHODS

Method Description
state
state_now
Like the Generic_Item methods, these return the last state that the group was set to. If a group member changed, these methods will return 'member $state_name' rather than just '$state_name'. You can use the member_changed or get_set_by methods to see which member changed.
state_log Returns a list array of the last max_state_log_entries (mh.ini parm) time_date stamped states.

INI PARAMETERS

NONE

AUTHOR

UNK

SEE ALSO

NONE

Clone this wiki locally