Example initialization:

These are to be placed in a *.mht file in your user code directory.

First, define your actual light object:

  X10I,      H2,     x10_hallway_lights

Then, define the Light_Item and attach the real object:

  LIGHT, x10_hallway_lights, hallway_light

Finally, in your user code, you need to add one or more objects that will determine how the light is controlled. You can attach objects of type: Door_Item, Motion_Item, Photocell_Item, Presence_Item, and Light_Restriction_Item. You used the add() function:

  $om_presence_hall_bath, $only_when_home);

Input states:

      From a Light_Restriction_Item:
         light_ok: Light can be turned on (light will immediately turn on
            if room is occupied AND no other restrictions are active)
         no_light: Light can not be turned on (will not affect current state)
      From a Presence_Monitor:
         occupied: Turns on light if photocell object(s) say it is dark
            and there are no active restrictions.
         vacant: Light will turn off after the delay set by delay_off() unless
            the Presence_Monitor has a delay that was set by delay_off() in
            which case that delay is used.
         predict: If prediction is enabled (with predict(1)), then the light
            will turn on if photocell object(s) say it is dark and there are
            no active restrictions.  Light will turn off after delay set by
            predict_off_time() or the default of 60 seconds unless something
            else (presence, motion, etc) causes light to remain on.
      From a Motion_Item or a Door_Item:
         on: Turns on light if photocell object(s) say it is dark
            and there are no active restrictions.  Light will turn off after
            delay set by predict_off_time() or the default of 60 seconds
            unless something else (presence, motion, etc) causes light to
            remain on.  EXCEPTION: Light will not turn off if there is an
            attached Presence_Monitor that indicates somebody is present.
      From a Photocell_Item:
         dark: Indicates that it is dark in the room, which could allow the
            light to be turned on.  No immediate action will be taken unless
            there are no Motion_Items, Door_Items, AND Presence_Monitors
            attached to the light, in which case the light will imediately
            turn on if there are no active restrictions (Light_Restriction_Item)
      From internal timer object:
         When this internal timer object triggers, if the light is supposed to
         be off, then it will be re-set to off to make sure it really is off.

Output states:

      'off': Light is off
      'on': Light is on (note: if set_on_state() was called then this will
         instead be whatever state specified in that function call)


An abstract object that represents a light that can be automatically controlled by Door_Items, Motion_Items, Presence_Monitors, Photocell_Items, Light_Restriction_Items, and Light_Switch_Items.

Often times, Door_Items and Motion_Items are also used by the Occupancy Monitor which in turn manages the state of the Presence_Monitor objects.





How long the light should remain on after the last event (i.e. door, motion, occupancy) occurs. The light will not turn off as long as occupancy remains true. If this is set to 0, the light will never turn off based on a timer (but could still turn off because of a Photocell_Item/Light_Restriction_Item or if door_auto_off() is enabled.


Pass in a 1 to enable x10 sync, 0 to disable. Currently this will make sure lights that are supposed to be off really are off around once per hour. The default is enabled.


Pass in another state besides the default of ON to use when turning "on" the light. Set to empty ('') to prevent this light from turning on automatically (but it will still turn off automatically).


You can override the default 60-second off time when a light is predictively turned on but nobody actually enters the room.


Turn off this light X seconds after all attached doors are closed UNLESS an attached occupancy monitor has a state of 'occupied'. In that case, when the room is no longer occupied and if all doors are closed the light will immediately turn off. Set this to 0 to disable (default) or a number of seconds to wait to establish occupancy before the light is turned off.


This light should always be on whenever an attached door is open, assuming any attached photocell items say it is dark in the room and unless a light restriction item says otherwise.


The room must be continuously occupied for the specified number of seconds before the light will come on. Note that you do NOT want to attach door objects and motion objects to the object if using this feature -- just attach the presence object(s) and any light restriction objects (and possibly a Light_Switch_Object).


Set X to 1 to set the light into a full manual mode where it will never be turned on or off automatically unless optional time_on or time_off are set. Set X to the physical light to ensure that the light_item tracks the state of the physical light while in manual mode. Assign time_on and optionally time_off to time in secs for manual mode to be set until resuming to automatic mode. time_off is assigned to time_on if uninitialized.


set X to 0 to only set state when the state changes value. The default is 1 and allows any number of sets with the same value.


set X to 0 to prevent any attached light restriction items from preventing off states. The default is "0".


set X to 1 to force Light_Item states to be saved and restored across a restart. The default is "0".




Jason Sharpee -

Kirk Bauer -

Special Thanks to: Bruce Winter - MH




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.