No announcement yet.

Disarm partition 1 - time to execute from event/script.

  • Filter
  • Time
  • Show
Clear All
new posts

  • Disarm partition 1 - time to execute from event/script.


    First, I have been a user of this plugin for I can't remember how long bu way back in hs2 supported life cycle. It is is a wonderful tool, and I mine it for detecting motion for lighting, auto setting the alarm every day, autolock of zwave deadbolt based on door opening and closing, arm/disarm alarm based on specific users of zwave deadbolts, reminders based on doors opened or not and more. I love it.
    I do have one nuisance. In events, I look for a device change:
    IF Foyer Z-Wave Door Lock changes and becomes Unlocked

    OR IF Foyer Z-Wave Door Lock changes and becomes Locked

    Then Run the script: C:/Program Files/HomeSeer HS3/scripts/LockAlert-FrontDoor.txt
    and only allow one instance of the script to run at a time.

    Then Increment counter FD lock cycles

    and it runs this script. If the specific user code is entered at the zwave lockset, the alarm is disarmed. It takes about 7 seconds for the alarm to be disarmed. I wonder what if anything I can do to decrease that lag? The event is set as a priority event.

    sub main()
    hs.writelog "Lock Alert-FD","Script begins"

    Dim AccessDevRef
    Dim DoorLockRef

    AccessDevRef=521 ' front door ie accesscontrol notificaiton' 1=lock, 2 = unlock, above 6000 is user
    DoorLockRef=527 ' front door lock unlock button

    'AccessDevRef=538 ' garage door
    'DoorLockRef=544 ' garage door

    Blabber=hs.DeviceValue(270) ' if 100 chime is on ok to blabber 100
    AlarmStatus=hs.DeviceValue(269) ' 1 - disarmed ready, 2 faulted, 3 armed, 4 armed stay, 6 burgler

    Stale=DateDiff("s",hs.devicelastchangeref(AccessDevRef),now( ))


    ' if Lockvalue = 0 then Lock="No event."
    ' if Lockvalue = 1 then Lock="" 'Manual lock."
    ' if Lockvalue = 2 then Lock="" 'Manual unlock."
    If Lockvalue = 5 then Lock="Locked from the outside."
    ' if Lockvalue = 7 then Lock="" 'Manual not fully locked."
    ' if Lockvalue = 9 then Lock="Auto lock locked operation."
    ' if Lockvalue = 10 then Lock="Auto lock not full locked operation."
    if Lockvalue = 11 then Lock="Lock jammed."
    ' if Lockvalue = 14 then Lock="New user codes added."
    ' if Lockvalue = 254 then Lock="Unknown events."
    if Lockvalue = 6001 then Lock="Rick or Judy have unlocked the deadbolt."
    if Lockvalue = 6002 then Lock="Rob has unlocked the dead bolt."
    if Lockvalue = 6003 then Lock="Eric has unlocked the dead bolt."
    if Lockvalue = 6004 then Lock="Maryann has unlocked the dead bolt."
    if Lockvalue = 6005 then Lock="Marzena has unlocked the dead bolt."

    If lockvalue > 6000 and Stale <= 1 then

    if dbg="yes" then hs.writelog "Lock Alert-FD","DeBug Lockvalue > 6k will speak"

    if doorlockref=538 then hs.speak "Master's " & lock & " at the garage door." ,true,"*:*"
    if doorlockref=527 then hs.speak "Master's " & lock & " at the front door." ,true,"*:*"

    if lockvalue = 6001 then
    hs.CAPIControlHandler(hs.CAPIGetSingleControl(269,True,"Disa rm",False,False))
    hs.CAPIControlHandler(hs.CAPIGetSingleControl(653,True,"Gree n",False,False))
    hs.writelog "Lock Alert-FD","My Master's have unlocked the door, I'll disarm the alarm."
    end if
    end if

    if Lockvalue = 5 then
    hs.writelog "Lock Alert-FD","Manual Lock Outside - Arm Alarm" ' manual lock from outside button press
    if Blabber=100 then hs.speak "Master's the front door was just manually locked from the outside and I'm arming the alarm." ' Chime is on therefore its okay to speak
    hs.CAPIControlHandler(hs.CAPIGetSingleControl(269,True,"Arm-Stay",False,False)) ' arm the alaerm
    hs.CAPIControlHandler(hs.CAPIGetSingleControl(527,True,"Lock ",False,False)) ' lock the front door
    hs.CAPIControlHandler(hs.CAPIGetSingleControl(544,True,"Lock ",False,False)) ' lock the garage door
    end if

    if dbg="yes" then
    hs.writelog "Lock Alert-FD","DeBug DoorLockRef=" & cstr(doorlockref)
    hs.writelog "Lock Alert-FD","DeBug AccessDevRef=" & cstr(AccessDevRef)

    hs.writelog "Lock Alert-FD","DeBug Stale=" & cstr(Stale)
    hs.writelog "Lock Alert-FD","DeBug Lockvalue=" & cstr(Lockvalue)
    hs.writelog "Lock Alert-FD","DeBug Alarmstatus=" & cstr(AlarmStatus)
    hs.writelog "Lock Alert-FD","DeBug LockUnlock=" & cstr(lockunlock)
    hs.writelog "Lock Alert-FD","DeBug Lock=" & lock
    end if

    hs.writelog "Lock Alert-FD","Script completed"

    end sub

    'Function StripHTML(strText)
    'strtext= lcase(strtext)
    ' text = Replace(Replace(strText, "&nbsp;", "", 1, -1, vbTextCompare), "&nbsp", "", 1, -1, vbTextCompare)
    ' Do
    ' k = InStr(1, text, "<")
    ' If k > 0 Then
    ' j = InStr(k + 1, text, ">")
    ' If j > 0 Then
    ' If k = 1 Then
    ' text = Mid(text, j + 1)
    ' ElseIf j < Len(text) Then
    ' text = Left(text, k - 1) & Mid(text, j + 1)
    ' Else
    ' text = Left(text, k - 1)
    ' End If
    ' Else
    ' Exit Do
    ' End If
    ' Else
    ' Exit Do
    ' End If
    ' Loop
    ' firstletter=ucase(mid(text,1,1))
    ' therest=mid(text,2)
    ' text=firstletter+therest
    ' StripHTML = text
    'End Function

  • #2
    Rick, do you think the delay is in your script, or the response of the panel to just the call to Disarm?

    as a test, just run a small test script to disarm using the script command; what is the response time?

    small suggestion on your script...use a Case statement instead of the IFs. That way the script doesn't need to evaluate all the IF conditions; this will help a little

    HS3 Pro
    Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway
    Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 (by Kirby) | Ultra1Wire3 | RFXCOM | NetCAM | MyQ | BLRadar | BLDenon | Jon00 Charting
    Platform: HP h8-1360t, Windows Server 2012 R2, i7-3.4GHz, 16GB memory