Easy Homeseer Script/Event Question

hhnew

Member
Well, easy for you guys. Not so much for me or I wouldn't be asking :lol: .

My motion sensors have two events/scripts associated with them; one to turn a light on with motion and keep it on for 5 minutes after the last motion and a second event to turn the light off.

Event 1 is ‘MS8 On’ and is triggered to run a script upon motion detection from motion sensor B9 which turns on light O2 (and resets the device string but that is unimportant to my question). The script is this:

sub main()
hs.setDeviceString "B9","Motion Detected"
hs.execx10 "O2","on"
hs.removeDelayedEvent "","MS8 Off"
hs.delaytrigger 300,"MS8 Off"
end sub

Event 2 is ‘MS8 Off’ and is a ‘Manual Only’ event that simply turns off light O2 and runs a one liner (&hs.setDeviceString "B9", "No Motion") to reset the device string.

This setup is works fine to turn the light on when motion is detected and leave it on for 5 minutes then turn it off. However, in my log I get this:

12/16/2004 11:09:31 AM~!~Info~!~Exec command: Outside MS8 - Driveway On dim: 0 extra: 0
12/16/2004 11:09:31 AM~!~X10 Received~!~B9 (Outside MS8 - Driveway) B On
12/16/2004 11:09:31 AM~!~Event Trigger~!~X10 Trigger (MS8 On) O2 On (Outside Driveway Flood)
12/16/2004 11:09:31 AM~!~Info~!~Exec command: Outside Driveway Flood on dim: 0 extra: 0
12/16/2004 11:09:31 AM~!~Info~!~Script call "RemoveDelayedEvent" failed, event MS8 Off not found
12/16/2004 11:10:32 AM~!~Info~!~Exec command: Outside MS8 - Driveway Off dim: 0 extra: 0
12/16/2004 11:10:32 AM~!~X10 Received~!~B9 (Outside MS8 - Driveway) B Off
12/16/2004 11:10:49 AM~!~Info~!~Exec command: Outside MS8 - Driveway On dim: 0 extra: 0
12/16/2004 11:10:49 AM~!~X10 Received~!~B9 (Outside MS8 - Driveway) B On
12/16/2004 11:10:49 AM~!~Event Trigger~!~X10 Trigger (MS8 On) O2 On (Outside Driveway Flood)
12/16/2004 11:10:49 AM~!~Info~!~Exec command: Outside Driveway Flood on dim: 0 extra: 0
12/16/2004 11:11:50 AM~!~Info~!~Exec command: Outside MS8 - Driveway Off dim: 0 extra: 0
12/16/2004 11:11:50 AM~!~X10 Received~!~B9 (Outside MS8 - Driveway) B Off
12/16/2004 11:15:49 AM~!~Event Trigger~!~Delayed Trigger
12/16/2004 11:15:49 AM~!~Event Trigger~!~External Trigger (MS8 Off) O2 Off (Outside Driveway Flood)

I’m sure it is something I have done wrong or left out but I’m not sure what. Can anyone help?

TIA,
HH
 
I think you are ok with this message. In your script, you are removing the delayed event that turns off the light every time the motion is sensed. They you add it again with the new 5 minute delay. This keeps the light on as long as motion keeps being detected.

There's probably a way to check and see if the event exists before removing it, but I don't know what it is offhand.

I don't think you are hurting anything by removing an event that doesn't exist. The error message in the log shouldn't cause any problems.
 
if hs.EventExists("evening") then

hs.speak "The evening event exists",TRUE

else

hs.speak "The evening event does not exist",TRUE

end if

hs.EventExist("EventName")

Event Name is the Name of the event. The name is not case sensitive.

Returns the Event Index

Code:
sub main()
hs.setDeviceString "B9","Motion Detected"
hs.execx10 "O2","on"
if hs.EventExist("MS8") = FALSE then
  hs.removeDelayedEvent "","MS8 Off"
  hs.delaytrigger 300,"MS8 Off"
end if

end sub
 
Thanks Squintz.

But you want the
Code:
hs.delaytrigger 300,"MS8 Off"
outside the if...end if.
 
Wonderful! Thank you both.
Smee- You're right, as far as performance it makes no difference. It is just an annoying line in the log. But, since I knew one of the scripters on here would know how to fix it I thought I'd ask and not only get rid of the line but learn something on the way.
Squintz- Thanks for rattling that off so I didn't have to read the scripting section of the manual again and try to figure it out.
 
Back
Top