Light_Restriction_Item.pm

Light_Restriction_Item

SYNOPSIS

Example initialization:

  # noloop=start
  use Light_Restriction_Item;
  my $only_when_dark = new Light_Restriction_Item();
  $only_when_dark->attach_scalar(\$Dark);
  # noloop=stop

  $om_auto_master_bath_light->add($om_motion_master_bath,
  $om_presence_master_bath, $only_when_dark);

Input states:

  # To enable the tied light
  set $test_restrict ON;
  set $test_restrict 'light_ok';

  # To disable the tied light
  set $test_restrict OFF;
  set $test_restrict 'no_light';

Output states: State is either 'light_ok' or 'no_light'

Attaching to a scalar: You can attach to a scalar to automatically allow or disallow lights based on its value. Any number of "light ok" values are allowed:

  # Light can turn on when $Dark is true
  # (defaults to true when no OK values are given)
  $only_when_dark->attach_scalar(\$Dark);

  # Light can turn on when the current second is 0-9
  $test_restrict->attach_scalar(\$Second, 0, 1, 2, 3, 4, 5, 6 , 7, 8, 9);

Obviously the scalar could be your own variable and you can use whatever logic you desire to determine its value and whatever frequency you desire. The value is checked once every second.

Attaching to a hash: Although you can attach to a hash entry by doing this:

  $only_when_dark->attach_scalar(\$hash_name{hash_key});

Sometimes this reference becomes invalid. In particular, the %Save hash is sometimes reloaded and the references to the values change. So, I recommend attaching to hash values as follows:

  $only_when_dark->attach_hash_key(\%hash_name, 'hash_key');

As with the functions above and below, these parameters can be followed by a list of any number of "okay" values.

Attaching to an object: You can attach to another object to automatically allow or disallow lights based on its state. Any number of "light ok" values are allowed:

  # Only allow lights to turn on when mode_occupied is 'home'
  $only_when_home->attach_object($mode_occupied, 'home');

  # Only allow lights to turn on when mode_sleeping is 'nobody'
  $only_when_awake->attach_object($mode_sleeping, 'nobody');

DESCRIPTION

Use this object with predictive/automatic lighting (i.e. Occupancy_Monitor.pm and Light_Item.pm) to place certain restrictions on when lights should and should not come on.

INHERITS

Base_Item

METHODS

UnDoc

INI PARAMETERS

NONE

AUTHOR

Kirk Bauer kirk@kaybee.org

Special Thanks to: Jason Sharpee jason@sharpee.com (for Occupancy_Monitor.pm, Light_Item.pm, Presence_Item.pm, etc)

SEE ALSO

NONE

LICENSE

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.

 Light_Restriction_Item.pm