| Group.pm | 
  $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.
You can use this object to group and operate on groups of items:
Generic_Item
new(@item_list)add(@item_list)setlistmember_changedReturns a member object name whenever one changes
member_changed_logReturns a list of recenty changed members. The first one was the most recently changed.
removeRemove an item from a group
statestate_nowLike 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_logReturns a list array of the last max_state_log_entries (mh.ini parm) time_date stamped states.
NONE
UNK
NONE
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
| Group.pm |