Skip to content

Items Light_Restriction_Item

ggodart edited this page Jan 4, 2021 · 1 revision

Light_Restriction_Item

See original

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

INI PARAMETERS

None

METHODS

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

Clone this wiki locally