From: Eloy P. <pe...@ch...> - 2012-02-14 01:47:58
|
On 02/13/2012 08:32 PM, Douglas Parrish wrote: > Alright, figured it out myself. Here's a more interesting example. > > if ( $state = said $v_basic_lights ) { > my $all = new Group ( $Inside_Lights -> list() ); > > if ($state eq 'on') { > $all -> remove ( $summers_lamp ); > $all -> remove ( $office_corner ); > $all -> remove ( $over_cabinet_lights ); > $all -> remove ( $bookshelf_light ); > > set $summers_lamp '20%'; > set $office_corner '75%'; > set $over_cabinet_lights '70%'; > set $bookshelf_light ON; > } > > set $all OFF; > } > > I use this for scenes where I want to set a few specific lights and turn > everything else in a group off. This format makes it trivially easy for > me to take a lamp out of the scene and have it turned off. Good deal; thanks for sharing. This is not INSTEON, is it? I don't use scenes myself very much (only for a 2-way switch set up) but I understand scenes are an integral part of INSTEON and the above can be done with a simple: set $my_insteon_scene ON Cheers, Eloy Paris.- > > On Sat, Feb 11, 2012 at 10:26 AM, Michael Stovenour > <mi...@st... <mailto:mi...@st...>> wrote: > > On 02/11/2012 09:31 AM, Douglas Parrish wrote: > > >How do I make $all a *copy* of $Inside_Lights so this works twice? > > In Perl it is possible to create an object copy or “clone”; you can > Google it http://lmgtfy.com/?q=perl+copy+an+object; however there > are a lot of pitfalls waiting for you because there are references > that will not be copied without a lot of work. If you really want > to use the all group but not affect "all" the items; wouldn’t it be > better just to loop over all the items calling set? You could have > a couple of next if($item->{object_name} eq > $item_i_want_to_exclude); checks in the loop to skip over the ones > you want to exclude. > > for my $item (list $Inside_Lights) { > next if($item->{object_name} eq "dougs_lamp"); > next if($item->{object_name} eq "summers_lamp"); > ... > > set $item ON; > } > > But.. Do you really want to maintain the list of excluded items in > your user code? Would it be easier to use the group method > described earlier by Eloy? > > Yet another method is to assign event filters to the items you want > to exclude. Then you can rely on the set_by indication to make the > excluded group ignore the command. Filtering events are described > in the Misterhouse man page: http://misterhouse.sourceforge.net/mh.html. > > Sincerely, > Michael > > |