Announcement

Collapse
No announcement yet.

Looking for an MCSMovement script suggestion...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Looking for an MCSMovement script suggestion...

    Hello,

    First, let me say, Michael, thank you for creating MCSMovement, and also for posting your movement.txt which I used as a framework to manage the couple dozen sensors in the house. I was just about ready to give up on the HomeSeer trial version I had installed until I tried MCSMovement. I started working with home automation about 12 years ago when I bought a TimeCommander, and when I decided to try HomeSeer as an upgrade to the TimeCommander, I found the Event interface to be too cumbersome (and even ineffective) for proper management of motion/door sensors.

    I'm planning on buying the MCSAudrey so I can put my five Audreys to use, and would also like to pay you a token of thanks for MCSMovement.

    I actually have two questions. The first is with regards to figuring out the best way to handle "when sensor 1 goes on do something and if sensor 2 does not go on within a certain amount of time, consider it to be transient motion". The specific case in point is a motion sensor on the back door, and a door sensor on that same door. When motion is detected at the back door, and it's dark, the back door light goes on for 10 minutes. What I want to do is, if the back door is not opened within one minute of the back door motion sensor triggering, the back door light should be turned back off. What's the best way to handle this?

    The other question is regarding the known reliability (or the lack thereof) of X-10 signals and hardware, and using the MS13A's dusk sensor to confirm the command was sent. The example would be: "When motion is off, set the light device to off. Then, say, 30 seconds later, if the MS13A's dusk sensor is still in the OFF state, indicating that something didn't go quite right (i.e. X10 command didn't make it, device didn't respond, or possibly the MS13A's dusk sensor transmission didn't make it), set the light off again."

    Come to think of it, I guess both questions are variations on the same theme -- based on some sensor input, perform some action, and wait some predetermined amount of time. After that predetermined amount of time elapses, check some other sensors and possibly attempt to remedy errors from the initial sensor input based on those other sensors. Distilling it even further, it's sort of like a "movement" device, but more along the lines of "if sensor A, and not B within a period of time" type of device.


    Thanks,
    Chris

  • #2
    The way that I see these scenarios is that you want to run a monitor at some time after an action is taken. What first comes to mind is to use the hs function DelayTrigger to define the point in time when you want to check and then in the event script perform the necessary checks. If you just have a few of these then a dedicated event for each is easiest. If you many then a generalized event can be done with global variables used to hold the collection of parameters to the event. This would be like making an event with parameters.

    For the door example, assume you arrived at the following script point because motion and dusk conditions have been satisfied at the door and you want to turn the light on. The script then turns the light on and sets up another event to be executed in 60 seconds to do the monitoring.

    Code:
    hs.ExecX10ByName "Back Light","ON"
    hs.DelayTrigger 60,"CheckDoorOpen"
    You create a homeseer event CheckDoorOpen and this event calls for the following CheckDoorOpen.txt script to be run. It assumes an ON status means the door is open

    Code:
    'CheckDoorOpen.txt
    
    sub main
        if not hs.IsOnByName("Back Door") then
            hs.ExecX10ByName "Back Light", "OFF"
        end if
    end sub
    This handles the situation where the door remains open so its status is ON at approximatley 60 seconds after the light was turned ON. If you wanted to handle the situation where the door was opened in the next 60 seconds (e.g. somebody went through the doorway and then closed the door) then you need to remember the door opening event. The code would then look like the following

    When the light is turned on the status of the door open/closed is remembered in a global variable. This way if the door was already open you will leave the light ON.

    Code:
    hs.ExecX10ByName "Back Light","ON"
    hs.DelayTrigger 60,"CheckDoorOpen"
    hs.CreateVar "CheckDoorOpen"
    hs.SaveVar "CheckDoorOpen", hs.DeviceStatus(hs.GetDeviceCode("Back Door"))
    When the door is open then the action generates an event (or may be part of your movement script) and then the global variable is set to remember the door has beenn opened. The value 2 is the device status ON equivalent. FYI, the Value 3 is OFF.

    Code:
    'code segment in script that deals with the door opening event action
        hs.CreateVar "CheckDoorOpen"
        hs.SaveVar "CheckDoorOpen", 2
    The delayed 60 second monitoring event now looks for status over the past 60 seconds rather than the current status to make a decision.

    The global variable can also be deleted for cleanup as shown, but is not necessary. Another optimization that is not necessary, but availble is to do the CreateVaar one time in the startup.txt script and then it would not need to be created at each event execution. If you do this, then of course do not delete it as cleanup in the event script.

    Code:
    'CheckDoorOpen.txt
    
    sub main
        if hs.GetVar("CheckDoorOpen") <> 2 then
            hs.ExecX10ByName "Back Light", "OFF"
        end if
        hs.DeleteVar "CheckDoorOpen"
    end sub

    This same basic approach can be used for the X10 as well. Simply add a delayed event trigger in the script where the initial action is taken and then perform the desired monitoring in the event that is executed by the delayed trigger.

    Comment


    • #3
      Thank you for your reply!

      The DelayTrigger is what I was using before switching to MCSMovement, but I hadn't used variables yet. Thanks for providing examples of how to use variables. I'll get working on that.

      (Oh yeah, and one thing I learned the hard way was to make sure any previous DelayTrigger is deleted first before starting a new DelayTrigger, especially with X-10 motion sensors that go off every 10-15 seconds.)

      Chris
      Last edited by The Keeper; March 27th, 2006, 01:17 PM.

      Comment

      Working...
      X