Premise [download] Module: DarkIndicator - indicates darkness based on mulitple sensors.

Motorola Premise

123

Senior Member
index.php
File Name: Module: DarkIndicator - indicates darkness based on mulitple sensors.
File Submitter: 123
File Submitted: 30 Sep 2009
File Updated: 30 Sep 2009
File Category: Premise
Author: 123
Contact: PM me
Version: 1

Summary

DarkIndicator is a Home object that indicates if it is dark. It is useful only if two or more light sensors are employed.

DarkIndicator analyzes the state of multiple sensors and determines if it is dark. Sensors can be assigned to one of two Zones: Interior or Exterior. DarkIndicator can use one of four algorithms to determine if it is dark:

Unanimity
All sensors must report it is dark.

MajorityAllZones
50% or more of all sensors must report it is dark.

MajorityEachZone
50% or more of all sensors in each zone must report it is dark.

Uninominal
At least one sensor from each Zone must report it is dark.


Pre-installation
For DarkIndicator to provide value, you must have at least two light sensors. The ADICON driver supports BOBCAT light sensors and the X10 MS16A Motion Detector includes a dawn/dusk indicator.

Installation
Unzip the attached file and, using Builder, import the XDO file.

Usage
  1. In Builder's Shortcut bar, click Home.
  2. In the Explorer window, right-click Home and select DarkIndicator.
  3. Right-click the DarkIndicator object and select New > DarkSensor.
  4. Add at least two DarkSensors.
  5. Bind each DarkSensor to an appropriate Device object (light sensor).

A note about binding.
Each DarkSensor has a bindable property called "State", but it will not bind automatically! You must manually bind "State" to the Device object's appropriate property. For example, the appropriate property for a BOBCAT Light Sensor is called "State" but it is "PowerState" for an X10 Appliance. Whatever property you choose, it must be Boolean.

Here's how to manually bind a property:
  1. Use the traditional technique and drag a Device object from the Pallete and drop it onto a DarkSensor in the Explorer window.
  2. In the DarkSensor's properties, locate its Values property (under Device Connection) and click its Browse button (...).
  3. In the resulting dialog box, draw a line between the DarkSensor's "State" and the bound object's appropriate property (i.e. State, PowerState, etc).
  4. Click OK, or Apply, and the binding will be finalized.

Adjusting the darkness threshold.
This step depends upon the light sensor being employed. The Device driver for a BOBCAT Light Sensor includes a property called DarkThreshold. I don't believe the MS16A permits threshold adjustments.

Using DarkIndicator
  1. Right-click the DarkIndicator and select New > Script > PropertyChange.
  2. Choose the "IsDark" property.
  3. Proceed to write a script that does something useful whenever it becomes dark.

Click here to download this file
 
Thanks 123.

For other newbies like me: I just happened to purchase 3 MS14A X10 motion sensors from ebay. It appears these also have dawn/dusk sensing and send the signal to unit code + 1 (ie A1 is the default for motion sensing, so A2 is the default for dusk/dawn sensing). I'm going to try this module when I get back home.

Any good uses for knowing whether it's dark? A few ideas that come to my mind: one could use this for exterior lamps that may not have a sensor, opening blinds as the sun rises and lastly (and probably the most useful) receiving confirmation that a light in a room (without too many windows) has come on. I really like the idea of using this as a light on/off feedback device for internal use.

Additionally, I'm also kind of curious to know how this compares to using the longitude/latitude to figure out if it's dawn/dusk. Are there advantages to one over the other?

PS: I learned that the MS14A has a dusk/dawn sensor the hard way as I assigned each MS14A a consecutive unit code and it appears my lights would come on and off without motion being sensed. I'm not at home to fix this, so I'm going to have to install builder if I want to fix it now. Doh! Always read the directions ;)
 
DarkIndicator is designed to monitor multiple light sensors to prevent a 'false positive' generated by a single sensor. It lets you choose a 'voting system' that provides the best representation for multiple interior and/or exterior sensors.

I use it to offset the time when interior lighting is activated. My interior lighting is scheduled to turn on shortly before sundown. That generally works well when the weather is fine because there's sufficient sunshine to illuminate my home's interior. However, when it is cloudy, there's insufficient exterior light and the interior lights ought to turn on well before sundown.

In my case, a single function (gAdjustForLowLightCondition) performs the following test:
  1. Time
    Is the current time between sundown and two hours prior to sundown? (Simple calculation)
  2. Illumination
    Is it currently dark? (Use DarkIndicator)
  3. Occupancy
    Is anyone home? (SecuritySystem is Disarmed)
If all conditions are true, the Evening lighting scene is activated.

The gAdjustForLowLightCondition function is triggered by any of the following three events:
  1. Scheduled Task (two hours before sunset)
  2. DarkIndicator (interior lighting drops below a threshold)
  3. SecuritySystem (ELK M1 is disarmed)

Code:
' gAdjustForLowLightCondition
' Activate the Evening scene if
' Within 2 hours of sunset and
' It is dark and
' The security system is disarmed (someone is home).
' This function is called by the DarkIndicator, SecuritySystem, and a Scheduled Task.
sub gAdjustForLowLightCondition()
	EndTime = system.times.sysSunset(Date)
	StartTime = dateadd("h", -2, EndTime)
	
	if (system.times.sysTime >= StartTime) and (system.times.sysTime < EndTime) then
		if Home.Hidden.DarkIndicator = true then
			if Home.SecuritySystem.SecurityState = 1 then
				Scenes.Evening.Play = true
			end if
		end if
	end if
end sub
 
Back
Top