Announcement

Collapse
No announcement yet.

Monthly Low Battery Check

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

    #46
    Sorry. . .and then I read the rest of the thread and got it working! :-)

    Originally posted by mwaite View Post
    I'm not really sure what the issue is. As a .NET environment, I'm not sure if it is a Linux problem, rather perhaps a data problem, although I know nothing about Linux.

    IComparable sorting on arrays is a skill set I have not mastered, rather found online.

    Try the attached, let me know if it makes any difference. If you still get the error, please comment out line 46, which removes the array sorting, and retest.

    Line 46 BEFORE: Array.Sort(myArray)
    Line 46 AFTER: 'Array.Sort(myArray) (notice the single quote)

    Please send me the report if successful after removing the sorting option.

    Remove the .txt from the attachment filename. Configure first 4 lines as needed.

    Comment


      #47
      Great script, thanks for sharing :-)

      Comment


        #48
        Mike, thank you for sharing your script, this was just what I was looking for!
        regards,
        Justin

        Comment


          #49
          Originally posted by mwaite View Post
          I added so many battery devices recently, I wanted a better way to report battery status w/o having to identify each device manually.

          I created a script that will email a battery report for all 'battery' type devices in HS3.

          Code:
           
           
          RefID Battery  Device Location / Name                         Last Changed
          ----- -------  ----------------------                         ------------
          [1369]      0%  Z-Wave Mailbox Battery                         1/1/0001 12:00:00 AM  
          [1119]      0%  Z-Wave Downstairs Bathroom Door Battery        1/1/0001 12:00:00 AM  
           [164]     25%  RFXCOM Wine Cellar Thermometer Battery         7/9/2015 4:58:47 AM   
           [462]     50%  Z-Wave Living Room Door Lock Battery           6/9/2015 2:50:27 AM   
          [1085]     50%  Z-Wave Porch Motion Battery                    7/26/2015 2:40:01 PM  
           [457]     60%  Z-Wave Garage Door Lock Battery                3/10/2015 12:14:55 PM 
           [158]     75%  RFXCOM Backyard Hot Tub Battery                3/6/2015 7:15:25 AM   
           [643]     75%  RFXCOM Garage Server Temperature Battery       10/8/2014 8:43:37 PM  
           [160]     75%  RFXCOM Pond Thermometer Battery                8/25/2014 9:20:30 PM  
           [171]     75%  RFXCOM Master Bedroom Thermometer Battery      8/25/2014 9:34:04 PM  
           [167]     75%  RFXCOM Downstairs Bathroom Thermometer Battery 12/23/2014 1:48:35 PM 
           [162]     75%  RFXCOM Living Room Fish Tank Battery           8/25/2014 9:23:01 PM  
          [1044]     75%  Z-Wave Downstairs Bathroom Vent Battery        7/26/2015 2:58:05 PM  
          [1100]     82%  Z-Wave Spare Motion Battery                    7/26/2015 3:28:46 PM  
           [475]     90%  Z-Wave Outside Side Gate Battery               7/25/2015 2:34:18 PM  
           [568]     90%  Z-Wave Kitchen Smoke/CO2 Detector Battery      7/22/2015 4:27:40 PM  
          [1163]    100%  Windows Living Room North Window Battery       7/25/2015 10:23:45 PM 
          [1167]    100%  Windows Guest Bathroom Window Battery          7/23/2015 10:29:20 PM 
          [1127]    100%  Z-Wave Kitchen Slider Battery                  6/19/2015 12:49:27 PM 
          [1201]    100%  Windows Master Bath Window Battery             6/13/2015 5:11:17 PM  
          [1123]    100%  Z-Wave Garage Slider Battery                   5/9/2015 1:36:41 PM   
          [1171]    100%  Windows Guest Room 2 Window Battery            7/18/2015 5:07:57 PM  
          [1185]    100%  Windows Z-Wave Spare - Battery                 7/9/2015 11:01:45 AM  
          [1205]    100%  Windows Master Bedroom West Window Battery     7/19/2015 6:31:22 AM  
          [1193]    100%  Windows Family Room Window Battery             7/20/2015 2:03:01 PM  
          [1197]    100%  Windows Kitchen Window Battery                 7/11/2015 3:56:14 PM  
          [1189]    100%  Windows Office Window Battery                  7/25/2015 5:15:06 AM  
          [1418]    100%  Node 4 Z-Wave Battery                          7/25/2015 3:41:07 PM  
          [1175]    100%  Windows Master Bedroom East Window Battery     7/6/2015 6:39:24 AM   
          [1208]    100%  Windows Guest Room 1 Window Battery            7/26/2015 3:52:41 PM  
          [1181]    100%  Windows Living Room West Window Battery        6/29/2015 6:12:52 AM  
           [450]   ERROR  Z-Wave Laundry Room FortrezZ Battery           7/19/2015 9:56:41 AM  
           [32 Battery Devices] - Report created 7/26/2015 5:30:45 PM
          To use, open the vb script with your favorite vb/txt editor, configure the first four lines, that's all that's to it. No attributes need to be sent to the script.

          The script can email the battery report as an attachment, or as the message body in the email [ReportAsAttachment = True/False].

          It defaults with a sort by lowest battery values first. It includes the device's 'Last Changed' value, so you can determine if the device is or is not reporting as expected.

          In the printout above, the last of my battery devices is reporting "ERROR". I discovered this device has an 'Invalid' range (as observed in device management) - so this is helpful to know as well.

          Note, the formatting is based on fixed-font spacing. So the attachment report looks pretty decent when viewed in Notepad, but the email body report viewed in Outlook loses some spacing characteristics. I'm over trying to clean this up any further - lol.

          Remove the .txt extension from the attached.
          I just tried this script, and it works fine...except that just about all my batteries are showing 0%, with a nonsense date last updated. Do I need to make any other changes to the script, or am I doing something wrong with my motion sensor definitions?


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

          Comment


            #50
            The script simply looks for the word "battery" in the device TYPE. Can you look in Device Management and see if the battery devices are showing the same level and date as in the report? I don't see how they can be different.
            Mike

            Comment


              #51
              See attached. It may very well be that I just don't have battery devices configured properly. (That's another confusing issue).
              Attached Files


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

              Comment


                #52
                <chirp chirp>


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

                Comment


                  #53
                  Sorry for the delay, was out on business...

                  The status of 'Off' indicates a problem. I do not have any Insteon battery devices, nor do I use the Insteon plugin (I use Bob's ISY plugin to access my insteon devices from an ISY994i).

                  That being said, your screenshot indicates some issue, as the status should be something more along the lines of a battery status (e.g. "OK") - however the actual status message depends on how the Insteon plugin created the device.

                  Check the Advanced tab of the battery device. In the attached example the battery level is 75%. If the battery indicator is working properly you would expect the "Value" entry to be some numeric value between 0 and 100. You likely don't have this, which is why the battery script is not displaying a value. You would need to check with the Insteon plugin as to why these battery devices are not configured correctly.
                  Attached Files
                  Mike

                  Comment


                    #54
                    Originally posted by mwaite View Post
                    Sorry for the delay, was out on business...

                    The status of 'Off' indicates a problem. I do not have any Insteon battery devices, nor do I use the Insteon plugin (I use Bob's ISY plugin to access my insteon devices from an ISY994i).

                    That being said, your screenshot indicates some issue, as the status should be something more along the lines of a battery status (e.g. "OK") - however the actual status message depends on how the Insteon plugin created the device.

                    Check the Advanced tab of the battery device. In the attached example the battery level is 75%. If the battery indicator is working properly you would expect the "Value" entry to be some numeric value between 0 and 100. You likely don't have this, which is why the battery script is not displaying a value. You would need to check with the Insteon plugin as to why these battery devices are not configured correctly.
                    This is weird, it's never happened before, or I didn't notice it until I ran your script. The status always showed a level, just as you say. Now the status on the configuration tab shows "0" for almost all my Type I motion sensors (my MSIIs show "full"). One MS shows 8.3, which is a correct voltage reading. I don't know how this happened, nor how to correct it.


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

                    Comment


                      #55
                      Addendum

                      I just checked the battery level entry in the Insteon plugin, and the devices are holding the proper battery level - figures between 8.1 and 9.0.

                      I also have no explanation for the last change field being blank, but I unchecked the box saying Do not update device last change time
                      if device value does not change:
                      I'll see if that makes a difference.


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

                      Comment


                        #56
                        Originally posted by mwaite View Post

                        I'm not really sure what the issue is. As a .NET environment, I'm not sure if it is a Linux problem, rather perhaps a data problem, although I know nothing about Linux.

                        IComparable sorting on arrays is a skill set I have not mastered, rather found online.

                        Try the attached, let me know if it makes any difference. If you still get the error, please comment out line 46, which removes the array sorting, and retest.

                        Line 46 BEFORE: Array.Sort(myArray)
                        Line 46 AFTER: 'Array.Sort(myArray) (notice the single quote)

                        Please send me the report if successful after removing the sorting option.

                        Remove the .txt from the attachment filename. Configure first 4 lines as needed.


                        To fix this for mono (which gives an Incomparable not found if apparently there is not Icomparible(object) available:

                        Public Class BatteryDevice : Implements IComparable

                        Public refID As String
                        Public devValue As String
                        Public lastChange As String
                        Public devName As String

                        Public Function CompareTo(ByVal other As Object) As Integer Implements IComparable.CompareTo
                        Dim otherBatteryDevice as BatteryDevice = CType(other, BatteryDevice)
                        Return Me.devValue.CompareTo(otherBatteryDevice.devValue)
                        End Function
                        End Class

                        Comment


                          #57
                          I finally implemented this script today. I took the liberty of making a few changes that might help others, I hope you'll consider merging them in:

                          1) Fix for Mono (ICompariable issue)
                          2) Added filtering for PHLocation devices (as mentioned in the thread)
                          3) For child devices, added parent device name into the report. For example, prior I had 3 batteries that all reported 'Main House Breakfast Room Battery'. But now since the parent device is used it is reported as: Main House Breakfast Room Dome Mouse Trap : Main House Breakfast Room Battery This change should help those that only name the parent devices and not each child.

                          Best
                          Bill

                          Attached Files

                          Comment


                            #58
                            Hi,

                            Thanks to mwaite for a really excellent script, which I have been using successfully since the first version was published.

                            However, I have run into a problem with a new sensor which only reports its battery level as: 'OK' or 'LOW'

                            This is not being picked up - I think the because the values are non numeric they are being lost somewhere. I am on linux and not really familiar with the VB scripting functions, so I cannot work out where the problem happens. But it would be really good if the script could pick these values up.

                            As an aside if you use the script on a linux system and want the report as an attachment you need to change the file path to a linux one eg:

                            Dim filename As String = "/home/homeseer/BatteryReport.html"

                            I tried to write a version with a mechanism to choose either windows or linux but failed miserably :'''(

                            Hopefully my effort could be used by someone with better VB skills to the general benefit.

                            AD


                            Attached Files
                            Last edited by ; August 1, 2018, 04:55 AM. Reason: Added non working draft

                            Comment


                              #59
                              Originally posted by adeux View Post
                              Hi,

                              Thanks to mwaite for a really excellent script, which I have been using successfully since the first version was published.

                              However, I have run into a problem with a new sensor which only reports its battery level as: 'OK' or 'LOW'

                              This is not being picked up - I think the because the values are non numeric they are being lost somewhere. I am on linux and not really familiar with the VB scripting functions, so I cannot work out where the problem happens. But it would be really good if the script could pick these values up.

                              As an aside if you use the script on a linux system and want the report as an attachment you need to change the file path to a linux one eg:

                              Dim filename As String = "/home/homeseer/BatteryReport.html"

                              I tried to write a version with a mechanism to choose either windows or linux but failed miserably :'''(

                              Hopefully my effort could be used by someone with better VB skills to the general benefit.

                              AD
                              Hi. Can you post a screen shot of the Status Graphics page from one of these devices? I also made some more updates last night and merged another script so that in addition to email you can update a virtual device with the lowest battery in your system. I meant to automate the path (windows/linux), I'll hit that after you post the screen shot. If the values are 'sane' it should be doable. Oh, can you also post the the first two Configuration and Advanced tab for one of the devices too?

                              Comment


                                #60
                                Originally posted by bsobel View Post

                                Hi. Can you post a screen shot of the Status Graphics page from one of these devices? I also made some more updates last night and merged another script so that in addition to email you can update a virtual device with the lowest battery in your system. I meant to automate the path (windows/linux), I'll hit that after you post the screen shot. If the values are 'sane' it should be doable. Oh, can you also post the the first two Configuration and Advanced tab for one of the devices too?
                                Hi,

                                thanks for the response. At the moment the device is a MQTT feed so that there are no status graphics. The OK and Low values come from the sensors manufacturer spec. As the batteries are new it is currently displaying OK.

                                The other alternative is to do some preprocessing in the MQTT feed and allocate arbitrary numeric values to OK eg 100% and Low eg 5%, but that is a bit of a kludge.

                                A

                                Comment

                                Working...
                                X