Announcement

Collapse
No announcement yet.

Low Battery Warning Script?

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

    Low Battery Warning Script?

    OK, who has a nice script that will text me if a low-battery warning is received from any motion sensor? Preferably it will include the location of the sensor, but not absolutely necessary.


    Jim Speiser
    38-year veteran of Home Automation
    Still don't know squat

    #2
    Originally posted by JimSpy View Post
    OK, who has a nice script that will text me if a low-battery warning is received from any motion sensor? Preferably it will include the location of the sensor, but not absolutely necessary.
    In this post is a nice little script that will update a virtual device with the lowest battery level. You can trigger emails or other warnings off of the virtual device.

    Mike posted a script in this post that will generate a nicely formatted report of all batteries.

    I use the virtual device to trigger a message with the full report when any battery is low. I also email the report to me on the first friday of each month so I can replace batteries over the weekend.
    Last edited by randy; January 11, 2016, 01:37 PM.
    HS4 Pro, 4.2.19.0 Windows 10 pro, Supermicro LP Xeon

    Comment


      #3
      Tried it, but...

      I tried this script, but I get an exception in the Log:
      Jan-10 1:54:43 PM Error Exception in script LowBatteryCheck: Object reference not set to an instance of an object.


      Jim Speiser
      38-year veteran of Home Automation
      Still don't know squat

      Comment


        #4
        I see that it is designed for Z-wave; will it also work with Insteon motion sensors?


        Jim Speiser
        38-year veteran of Home Automation
        Still don't know squat

        Comment


          #5
          Originally posted by JimSpy View Post
          I tried this script, but I get an exception in the Log:
          Jan-10 1:54:43 PM Error Exception in script LowBatteryCheck: Object reference not set to an instance of an object.
          I just added this in (not sure how I missed this awesome script), and it works for me. Did you make sure to put the refID in the event for the script to see your virtual device?

          Comment


            #6
            Originally posted by JimSpy View Post
            I see that it is designed for Z-wave; will it also work with Insteon motion sensors?
            I am sure you can make it work. Right now it is looking for a device type of Zwave batteries... you would just need to change this line to match what it is for insteon... I don't have any so I am not sure what it will look like:

            Code:
            If StrComp(dv.Device_Type_String(Nothing), "Z-Wave Battery") = 0 Then  'Only work with devices with a battery

            Comment


              #7
              Originally posted by waynehead99 View Post
              I am sure you can make it work. Right now it is looking for a device type of Zwave batteries... you would just need to change this line to match what it is for insteon... I don't have any so I am not sure what it will look like:

              Code:
              If StrComp(dv.Device_Type_String(Nothing), "Z-Wave Battery") = 0 Then  'Only work with devices with a battery
              The report I pointed to above uses "if device type contains 'battery'", so it catches all battery devices. I'm sure the script could be changed accordingly. I never bothered, because all of my battery operated devices are Z-Wave.
              HS4 Pro, 4.2.19.0 Windows 10 pro, Supermicro LP Xeon

              Comment


                #8
                Originally posted by rprade View Post
                The report I pointed to above uses "if device type contains 'battery'", so it catches all battery devices. I'm sure the script could be changed accordingly. I never bothered, because all of my battery operated devices are Z-Wave.
                I would need to take a refresher course on vbscript. Can you tell me the function name I would use to replace strComp (which IIRC is a full string comparison) to do a partial string comparison (or just "does the string contain")?

                Thanks.

                EDIT: Actually, never mind. As far as I know, Motion Sensors are the only Insteon devices that report a battery condition, so I could just strComp on Motion Sensor Battery Low or whatever.


                Jim Speiser
                38-year veteran of Home Automation
                Still don't know squat

                Comment


                  #9
                  Originally posted by JimSpy View Post
                  I would need to take a refresher course on vbscript. Can you tell me the function name I would use to replace strComp (which IIRC is a full string comparison) to do a partial string comparison (or just "does the string contain")?

                  Thanks.

                  EDIT: Actually, never mind. As far as I know, Motion Sensors are the only Insteon devices that report a battery condition, so I could just strComp on Motion Sensor Battery Low or whatever.
                  I am not a proficient script writer, but replacing "strComp" with "InStr" should allow you to "string contains" comparison. The report I linked to above used the following:

                  Code:
                  If InStr(UCase(dv.Device_Type_String(Nothing)), "BATTERY") > 1 Then
                  It will report all device types that have battery in them. It just uses a different approach of making the string uppercase then looking for "BATTERY" in the string.
                  HS4 Pro, 4.2.19.0 Windows 10 pro, Supermicro LP Xeon

                  Comment

                  Working...
                  X