Announcement

Collapse
No announcement yet.

Z-Wave Lock Events Script

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

  • Z-Wave Lock Events Script

    Hi all,

    Attached is a script that manages actions associated with z-wave locks opening, closing, etc. I originally wrote it to replace a HS2 script by rmasonjr that created logs and virtual devices that showed who had unlocked doors. I recently converted it to work with HS3. However, afterwards I realized I could use it to eliminate a bunch of my HS2 events that I still had to implement on HS3 but kept putting off due to the tedious nature of those events. For each lock, I used to have approximately 15 events or so. This one script replaces all of those, so for 3 locks, that means I now only have 3 events, rather than 45 .

    The discussion thread for this script is here: http://board.homeseer.com/showthread.php?t=174916

    The script can do the following:
    • Create and update a database in the \Data\Locks directory which contains activity info from the z-wave lock. If the directory does not exist it will be created by the script.
    • Speak who has unlocked a lock. If you use Jeff Farmer's very cool Random plugin, it can use it to randomize the announcements.
    • Update a HS device with the last number entries. This can be displayed in HS Touch or custom web pages.
    • Send email alerts and warnings for defined lock events (low batteries, locking action incomplete, etc.).
    • If you use mrhappy's fantastic Pushover plugin, it can send Pushover alerts and warnings for defined lock events.
    • If you use Jon00's equally fantastic Jon00RCCNM unmanaged plugin, it can send alerts and warnings to its clients as well.


    This script should work for any kind of lock that has a notification device.

    I call the script using the following event (one for each lock):

    Click image for larger version  Name:	Untitled.png Views:	2 Size:	27.5 KB ID:	1210286

    This is based on changes to the lock's notification child device. The script requires 1 parameter to be passed to it which is the door/lock name.

    The attached zip file contains 2 files:
    • doorlock.vb. Place this in your \Scripts folder
    • doorlock.aspx. Place this in your \html folder


    Important Note: You must modify your settings.ini file in the \Config folder for the script to work by adding the following setting to the ScriptingReferences= line under the [settings] section and restart HS. Adjust the path to System.Data.SQLite.dll as per your own system and only include the trailing comma if you have other scripting references after this one.

    Code:
    System.Data.SQLite;C:\Program Files (x86)\HomeSeer HS3\Bin\System.Data.SQLite.dll,
    If you don't have a ScriptingReferences line in your settings.ini file already, then add as follows right below the [settings] header:

    Code:
    [settings]
    ScriptingReferences=System.Data.SQLite;C:\Program Files (x86)\HomeSeer HS3\Bin\System.Data.SQLite.dll
    again adjusting the path to System.Data.SQLite.dll as per your own system.

    How the script behaves can be configured using the provided web page (doorlock.aspx) and the configuration parameters are stored in an INI file called doorlock.ini in the \Config subfolder. The INI file can also be manually updated if you wish. A default INI file is created when you first run the script or web page. When the web page (doorlock.aspx) is first loaded, it shows the General Settings:

    Click image for larger version  Name:	Capturedls.jpg Views:	1 Size:	154.2 KB ID:	1210341

    Once you add a lock by entering a name for it in the Locks field and clicking Submit, you are taken to the main configuration parameters for the lock where you enter the Reference ID for the lock's notification device and the Reference ID for the device where you want to log the latest lock events to:

    Click image for larger version  Name:	Door Lock - Lock Device Settings.png Views:	1 Size:	24.2 KB ID:	1210284

    Once you have entered those and clicked on Submit, the web page queries all the possible Value-Status pairs from the lock's notification device and displays them on the screen. Each one can now be configured as needed for notifications and announcements:

    Click image for larger version  Name:	Door Lock - Lock Config Settings.jpg Views:	1 Size:	122.6 KB ID:	1210285

    Cheers
    Al

    Changelog:

    3.x Original versions
    4.0 Internal version for testing
    5.x Test versions using database
    6.0 Now uses a database, all config options are moved to an INI File, and a Web Page for configuration is now included.
    6.1.1 Minor bug fix, improved debug logging and will use status-value pair for message if no specific message has been defined.
    6.2 Minor bug fixes, moved Pushover function to main script, easier config of Pushover settings. Now has option to create the logging device from the config page, and will try to determine the lock's notification device reference id.
    6.4 Added support for special tags in the Action Message and uses correct paths for Windows & linux.
    6.7 Added support for the Random plugin and also for sending notifications to the Jon00RCCNM client.
    6.9 Added support for linux (thanks to Igorski88 for all the testing!)
    6.95 Updated to support the additional Pushover Parameter.

    NOTE: The separator character in the INI file was changed from , to | in version 6.4. If you are upgrading from a 6.0-6.3 version, then you MUST open doorlock.aspx and look at the settings for each of your locks. Doing so updates the INI file to the new separator. If you are going straight from 3.x, 4.x, 5.x to 6.4 or newer, then this does not affect you.
    Last edited by sparkman; December 30th, 2018, 10:09 PM.
    HS 3.0.0.532: 1963 Devices 1141 Events
    Z-Wave 3.0.1.261: 122 Nodes on one Z-Net

  • #2
    Nice script! Will play around with this one, I already use the Pushover plugin so this will be a nice addition.
    Bryan
    Software/Hardware: Win10 Pro, HS 3 Pro, HS Touch, Echo, Edgeport/4, Z-Net w/88 Devices, Insteon PLM w/19 Devices, Nest, GC-100-6, W800RF32A, WS-2080 Weather Station (KMADRACU10)
    Plug-in/Scripts: Alexa API, BLBackup, BLGData, BLLED, BLLock, BLRF, BLTVGuide, Blue Iris, BLUPS, Current Cost 3P, DirectTV, FitbitSeer, Insteon, Nest, Pushover 3P, Random, Restart, Tasker, UltraGCIR3, UltraWeatherWU, Z-Wave

    Comment


    • #3
      Has anyone done something similar with Yale Locks (recent touchscreen ones)?
      This script looks phenomenal in it's simplicity with such a high level of reporting! But as I have never written one, would be lost where to make translations. But I'm sure I could figure out if basics for Yale was already there...
      Jim
      ----
      Plugins:Z Wave 3.0.1.55, HS3 Pro 3.0.0.208, HS3Touch, HS3Touch IOS, Z-Net, SceneMaster, XBMC, Sonos, Media Controller, Envisalink (52 Virtual nodes), JowiHue, EasyTrigger, Liftmaster MyQ, BLBackup, BLLAN, BLRadar, Pushover

      Devices:Cooper RF9540, Cooper Scene, Yale Locks, Sonos, Phillips Hue and Lux, DSC, Somfy Blinds

      Comment


      • #4
        o matter how I try to download the two files they come across as attachment.php instead of xxx.txt. What am I missing or what do I need to do in order to download them?

        Thanks

        Comment


        • #5
          Originally posted by 519zwave View Post
          Has anyone done something similar with Yale Locks (recent touchscreen ones)?
          This script looks phenomenal in it's simplicity with such a high level of reporting! But as I have never written one, would be lost where to make translations. But I'm sure I could figure out if basics for Yale was already there...
          I think the Yale locks should work with the script as is. To confirm, can you post a screen shot of the Status Graphics tab from the lock's notification child device?

          Cheers
          Al
          HS 3.0.0.532: 1963 Devices 1141 Events
          Z-Wave 3.0.1.261: 122 Nodes on one Z-Net

          Comment


          • #6
            Originally posted by Gunneyk View Post
            o matter how I try to download the two files they come across as attachment.php instead of xxx.txt. What am I missing or what do I need to do in order to download them?

            Thanks
            Hi Andrew,

            I just tried with Chrome and they downloaded properly for me. Which browser are you using?

            Cheers
            Al
            HS 3.0.0.532: 1963 Devices 1141 Events
            Z-Wave 3.0.1.261: 122 Nodes on one Z-Net

            Comment


            • #7
              StatusYALE - Graphics tab from the lock's notification child device

              Sure can!
              Attached Files
              Jim
              ----
              Plugins:Z Wave 3.0.1.55, HS3 Pro 3.0.0.208, HS3Touch, HS3Touch IOS, Z-Net, SceneMaster, XBMC, Sonos, Media Controller, Envisalink (52 Virtual nodes), JowiHue, EasyTrigger, Liftmaster MyQ, BLBackup, BLLAN, BLRadar, Pushover

              Devices:Cooper RF9540, Cooper Scene, Yale Locks, Sonos, Phillips Hue and Lux, DSC, Somfy Blinds

              Comment


              • #8
                I am using IE but I found that it is in fact the correct file it just renames it to attachment.php. All I have to do is rename it to .txt and I can see it fine and then rename it to the proper vb extension. Thanks.

                Comment


                • #9
                  Originally posted by 519zwave View Post
                  Sure can!
                  Ok, that will require a bit of tweaking as it's different than a Kwikset. I'll take a look at it tonight.

                  Cheers
                  Al
                  Last edited by sparkman; April 13th, 2015, 03:57 PM.
                  HS 3.0.0.532: 1963 Devices 1141 Events
                  Z-Wave 3.0.1.261: 122 Nodes on one Z-Net

                  Comment


                  • #10
                    Originally posted by Gunneyk View Post
                    I am using IE but I found that it is in fact the correct file it just renames it to attachment.php. All I have to do is rename it to .txt and I can see it fine and then rename it to the proper vb extension. Thanks.
                    Great!
                    HS 3.0.0.532: 1963 Devices 1141 Events
                    Z-Wave 3.0.1.261: 122 Nodes on one Z-Net

                    Comment


                    • #11
                      Originally posted by sparkman View Post

                      This is based on changes to the lock's notification child device. The script requires 3 parameters to be passed to it separated by commas: 1234,Door Name,5678
                      • 1234 is the device ID of the Z-Wave Lock's Notification device.
                      • Door Name is the name of the door.
                      • 5678 is the device ID of the HS3 device that holds the last 10 entries.
                      Al, I am not sure I know how to find the Device ID. Are you referring to the Reference ID as highlighted in yellow? If not please guide me to the correct place.

                      Another question is what holds the last 10 entries. I have a Kwikset lock and I assume that you mean the devices I have pointed out in the attached drawing. Is that correct? If I have the correct ID and devices I don't get the logging action and I don't see any errors listed anywhere. Any thoughts?

                      Thanks again.
                      Attached Files

                      Comment


                      • #12
                        Originally posted by Gunneyk View Post
                        Al, I am not sure I know how to find the Device ID. Are you referring to the Reference ID as highlighted in yellow? If not please guide me to the correct place.

                        Another question is what holds the last 10 entries. I have a Kwikset lock and I assume that you mean the devices I have pointed out in the attached drawing. Is that correct? If I have the correct ID and devices I don't get the logging action and I don't see any errors listed anywhere. Any thoughts?

                        Thanks again.
                        Hi Andrew,

                        Yes, the reference ID is what's needed. I'll update the original post to clarify that. For the device that holds the last 10 entries, you need to create a new (virtual) device and provide the reference ID to it.

                        Cheers
                        Al
                        HS 3.0.0.532: 1963 Devices 1141 Events
                        Z-Wave 3.0.1.261: 122 Nodes on one Z-Net

                        Comment


                        • #13
                          Originally posted by sparkman View Post
                          Hi Andrew,
                          For the device that holds the last 10 entries, you need to create a new (virtual) device and provide the reference ID to it.
                          Al
                          OK you lost me there . How does a Virtual Device help store the last 10 events and how does this use it? I created a VD and passed the ID that I pass in to this new VD. A VD is just an on / off by default. Is there something specific I need to set in the VD configuration for this to work?

                          Comment


                          • #14
                            Originally posted by Gunneyk View Post
                            OK you lost me there . How does a Virtual Device help store the last 10 events and how does this use it? I created a VD and passed the ID that I pass in to this new VD. A VD is just an on / off by default. Is there something specific I need to set in the VD configuration for this to work?


                            It stores it in the string portion of the VD. The intent of it was to allow someone to display it within HS Touch or in a custom web page. Take a look at the link in the first post as it'll provide some background. Nothing special is needed in the VD config.

                            Cheers
                            Al
                            HS 3.0.0.532: 1963 Devices 1141 Events
                            Z-Wave 3.0.1.261: 122 Nodes on one Z-Net

                            Comment


                            • #15
                              Originally posted by 519zwave View Post
                              Has anyone done something similar with Yale Locks (recent touchscreen ones)?
                              This script looks phenomenal in it's simplicity with such a high level of reporting! But as I have never written one, would be lost where to make translations. But I'm sure I could figure out if basics for Yale was already there...
                              Give the attached a try. Rename it to doorlock.vb.

                              Cheers
                              Al
                              Last edited by sparkman; April 13th, 2015, 09:59 PM.
                              HS 3.0.0.532: 1963 Devices 1141 Events
                              Z-Wave 3.0.1.261: 122 Nodes on one Z-Net

                              Comment

                              Working...
                              X