I know that the above is what all the examples show; but, I'm suspicious
as I don't use it that way and instead "roll my own" (see below).
Specifically, the lack of a secondary "ok_values" parm makes me wonder
what is actually going on.  Note my example (albeit different).


If no ok values are specified then Light_Restriction_Item just evals as true/false which is what I use for my vars:
         if ($$self{'last_watched_val'}) {


The code you have below is interesting I may have to incorporate some of that.  I never thought to manually control a Photocell_Item.  I don't use the real Photocell's I have because their definition of dark and mine differ greatly.  I'm assuming you then attach your photocells to the lights but then what do you use the $dark_restriction for ?

> $li_Laundry_Room_Lights->add($mi_Laundry_Room_Motion, $pm_Laundry_Room,
> $lr_only_when_dark);
>
> $li_Laundry_Room_Lights->delay_off(5*60);
>
> # noloop=stop
>
> </code>
>
> As a second note, how would I define a Light_Restriction that only allow
> the Light_item to be turned on between certain hours of the night?

The following is what I've done to accommodate what I think is more
realistic in terms of whether it really is dark or not inside.  If I
were a bit smarter, I'd factor time of year as well:

------------------------------------------

use vars '$inside_dark';

$duskdawn_photocell = new Photocell_Item();
$dark_restriction = new Light_Restriction_Item();
$dark_restriction->attach_scalar(\$inside_dark, 'dark'); # noloop
$house_photocell = new Photocell_Item();

if ($Reload or new_minute 1)
{
   if (&time_less_than("$Time_Sunset") &&
&time_greater_than("$Time_Sunrise"))
   {
      $duskdawn_photocell->set('light') unless
$duskdawn_photocell->state eq 'light';
   }
   else
   {
      $duskdawn_photocell->set('dark') unless
$duskdawn_photocell->state eq 'dark';
   }
   if ($Weather{Clouds} and ($Weather{Clouds} ne 'overcast'))
   {
      my $sunrise_offset = "1:30";
      my $sunset_offset = "1:45";
      if ($Weather{Clouds} eq 'few clouds')
      {
         $sunrise_offset = "1:45";
         $sunset_offset = "2:00";
      }
      elsif ($Weather{Clouds} eq 'scattered clouds')
      {
         $sunrise_offset = "2:30";
         $sunset_offset = "2:45";
      }
      elsif ($Weather{Clouds} eq 'broken clouds')
      {
         $sunrise_offset = "3:00";
         $sunset_offset = "3:15";
      }
      if (&time_less_than("$Time_Sunset - $sunset_offset") &&
&time_greater_than("$Time_Sunrise + $sunrise_offset"))
      {
         $house_photocell->set('light') unless $house_photocell->state
eq 'light';
         $inside_dark = 'light';
      }
      else
      {
         $house_photocell->set('dark') unless $house_photocell->state
eq 'dark';
         $inside_dark = 'dark';
      }
   }
   else
   {
      $house_photocell->set('dark') unless $house_photocell->state eq
'dark';
      $inside_dark = 'dark';
   }
}

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
________________________________________________________
To unsubscribe from this list, go to: http://sourceforge.net/mail/?group_id=1365




--
   Chris