-
Notifications
You must be signed in to change notification settings - Fork 131
Light_Restriction
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.
Usage: Example initialization:
- noloop=start
- noloop=stop
Input states:
- To enable the tied light
- To disable the tied 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)
- Light can turn on when the current second is 0-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 allow lights to turn on when mode_sleeping is 'nobody'