Announcement

Collapse
No announcement yet.

How To Create A Low Battery Level Event

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

    #16
    Originally posted by cheeryfool View Post
    I have events similar to these and send all device friendly names and batt percentages in a single pushover msg using replacement variables. Just saves going to search in the device page

    Can you post or share how you did the replacement variables in HS3. It might be nice to see an example. Thank you

    Comment


      #17
      Actually, I figured out how to do this in HS3. This is working nicely...the email now contains the status of the devices. Attached is a screen print of the email part of the event. Replace ADDRESS with the device address in the HS3 device management page.

      For what it is worth, I totally agree that if you can, use events. The added grouping organization of events has made events much more organized and having the full event on one page (trigger, action, etc.) also aids in setting these up. The only things I wish you could do in 1 event are: IF, THEN, ELSE, somehow capture which trigger/condition actually triggered the actions to fire and use this variable within the action.
      Attached Files

      Comment


        #18
        Originally posted by heatvent View Post
        Actually, I figured out how to do this in HS3. This is working nicely...the email now contains the status of the devices. Attached is a screen print of the email part of the event. Replace ADDRESS with the device address in the HS3 device management page.

        For what it is worth, I totally agree that if you can, use events. The added grouping organization of events has made events much more organized and having the full event on one page (trigger, action, etc.) also aids in setting these up. The only things I wish you could do in 1 event are: IF, THEN, ELSE, somehow capture which trigger/condition actually triggered the actions to fire and use this variable within the action.
        That is very similar to what I ended up doing for my monthly reminders. The discussions in this thread gave me several ideas of what I would like to do and I changed everything yesterday after giving it some thought. I decided granularity wouldn't be very hard to achieve with events. It took less than thirty minutes to to create a new group dedicated to battery reminders. I use Pushover rather than email for my alerts and the body of a Pushover message is limited to 500 characters. With that constraint I still split my monthly status alerts into two groups - thermostats and multi-sensors. Building this on a laptop would take a little more time, but the real estate on my desktop made it a breeze. I opened device manager, filtered on batteries in one browser window. I opened events in another. I created a new group for battery warnings and an event for a single device battery alert. Then it was copy event, cut and paste changes, repeat for sixteen additional events. Then I created my two monthly reminders. Below it shown the structure of the events. I put the letter "A" in front of the battery group status events just for the purpose of sorting.

        Click on image to launch a larger version.



        When people talk about events and how tedious and complicated they are and how much more elegant a script is I just don't understand. Certainly a script and variables could reduce the event count, but once I was done, I have a reliable and highly detailed reporting system for my battery status on all 17 devices. If I add a device, then I add an event. Events work reliably, building an event is easy, copy and paste saves a lot of typing. Below is a screenshot of the events. Sure, it is a lot of events, but once they are done, the group is collapsed and I don't look at them again unless I need to change them. I get a monthly status alert at 9:00am the first Saturday of every month and a specific device low battery warning at 8:00am each day.

        Click on image to launch a larger version.

        Attached Files
        Last edited by randy; June 4, 2014, 08:05 PM.

        Comment


          #19
          Originally posted by heatvent View Post
          Actually, I figured out how to do this in HS3. This is working nicely...the email now contains the status of the devices. Attached is a screen print of the email part of the event. Replace ADDRESS with the device address in the HS3 device management page.



          For what it is worth, I totally agree that if you can, use events. The added grouping organization of events has made events much more organized and having the full event on one page (trigger, action, etc.) also aids in setting these up. The only things I wish you could do in 1 event are: IF, THEN, ELSE, somehow capture which trigger/condition actually triggered the actions to fire and use this variable within the action.

          Yes, that's exactly it. Apologies, I didn't have time to respond from the office further today. I use Pushover like Randy, but also drive all sensors off one event.

          If Device A <20%
          or
          If Device B <20%
          or
          If Device C <20%

          etc etc

          Then send Pushover message with battery status of all devices

          and do not run again for X period
          cheeryfool

          Comment


            #20
            Auto low battery script

            I'm fairly new to HS, but thought I'd weigh in on the events/script conversation relating to battery status. I debated doing this via events only or with a script and ultimately, I went with a script for this solution. The deciding factor was that I wanted a hands off way of managing battery levels. I didn't want to have to touch or update any events if I removed or added devices in the future. Since I also support other HomeSeer systems, having a script that would work on any install seemed the way to go.

            For me, I wanted a single virtual device that always reflected the device name and battery value of the device with the lowest battery. I also wanted to be alerted when this battery level dropped too low.

            After reading through various threads and the scripting documentation, I came up with the following script that does all of the above. In order to get this working, you'll need to do the following:
            1. Copy the script to the HS scripts folder
            2. Create a virtual device like in the attachments. The name is not important.
            3. Create a timed event that runs the script every day. You need to pass in the reference ID of the virtual device you created in step 2.
            4. Create an event that is triggered when the virtual device drops below a certain value and alerts/emails you. This can be an email, pushover, change the color of a lightbulb, etc.


            That's it. I now have one event that triggers the script every morning. Whenever the script runs, it will automatically discover all your z-wave battery devices and update the virtual device created with the level and name of the device with the lowest battery and then another event that does something based upon the value of this virtual device.

            Code:
            ' ==============================================================================================
                '
                ' Microsoft VB.NET Source File -- Created With tenScripting3 and Visual Studio Express 2015 for Windows Desktop
                '
                ' NAME: LowBatteryCheck.vb
                '
                ' AUTHOR: Stephen Buck 
                ' Date  : 9/1/2015
                '
                ' COMMENT: Locates the device with the lowest battery and updates a virtual device with this value and the name of the device
                '          Must create a virtual status only device and supply the reference ID of this device as a parameter
                '
                ' UPDATES: 9/1/2015 - initial release
                '
                ' ==============================================================================================
                Public Sub Main(ByVal lowBatDvRef As String)
                    Try
                        Dim lowBatVal As Double = 100  'start at 100% max for low battery value
                        Dim dv, dvLowBat As Scheduler.Classes.DeviceClass
                        Dim EN As Scheduler.Classes.clsDeviceEnumeration = hs.GetDeviceEnumerator  'Get all devices
            
                        If EN Is Nothing Then
                            hs.WriteLog("Low Battery Check", "Error getting Enumerator")
                            Exit Sub
                        End If
            
                        Do  'check each device that was enumerated
                            dv = EN.GetNext
                            If dv Is Nothing Then  'No device, so quit
                                hs.WriteLog("Low Battery Check", "No devices found")
                                Exit Sub
                            End If
                            If StrComp(dv.Device_Type_String(Nothing), "Z-Wave Battery") = 0 Then  'Only work with devices with a battery
                                If dv.devValue(Nothing) <= lowBatVal Then  'is current device value less than or equal to the current low battery value?
                                    dvLowBat = dv  'set lowbat device to the current device
                                    lowBatVal = dvLowBat.devValue(Nothing)  'set low battery value to current device value
                                End If
                            End If
                        Loop Until EN.Finished
            
                        hs.SetDeviceValueByRef(lowBatDvRef, dvLowBat.devValue(Nothing), True)  'Set the lowest battery virtual device to the lowest battery value found
                        hs.SetDeviceString(lowBatDvRef, dvLowBat.Location(Nothing) & " " & dvLowBat.Name(Nothing), True)  'Set the lowest battery virtual device string to the location and name of the device with the lowest battery
                        hs.WriteLog("Low Battery Check", "Updated device " & hs.DeviceName(lowBatDvRef) & " with battery value:  " & dvLowBat.devValue(Nothing) & " location: " & dvLowBat.Location(Nothing) & " device name: " & dvLowBat.Name(Nothing))
                    Catch ex As Exception
                        hs.WriteLog("Error", "Exception in script LowBatteryCheck:  " & ex.Message)
                    End Try
                End Sub
            Attached Files

            Comment


              #21
              This is nice Stephen. Thanks for sharing!


              Sent from my iPhone
              Tom
              baby steps...starting again with HS3
              HS3Pro: Z-NET & 80 Z wave Devices,
              HSTouch: 4 Joggler (Android Kitkat), 2 iPhone, 3 iPads
              Whole House Audio: 5 SqueezePlay Jogglers w Bose Speakers
              In The Works: 10 Cameras Geovision, new Adecmo/Envisalink Alarm, Arduinos
              System: XP on Fanless Mini-ITX w/ SSD

              Comment


                #22
                You guys may also want to look at the script found Here. It allows you to get an update on all your battery devices by email.

                Greig.
                Zwave = Z-Stick, 3xHSM100� 7xACT ZDM230, 1xEverspring SM103, 2xACT HomePro ZRP210.
                X10 = CM12U, 2xAM12, 1xAW10, 1 x TM13U, 1xMS13, 2xHR10, 2xSS13
                Other Hardware = ADI Ocelot + secu16, Global Cache GC100, RFXtrx433, 3 x Foscams.
                Plugings = RFXcom, ActiveBackup, Applied Digital Ocelot, BLDeviceMatrix, BLGarbage, BLLAN, Current Cost, Global Cache GC100,HSTouch Android, HSTouch Server, HSTouch Server Unlimited, NetCAM, PowerTrigger, SageWebcamXP, SqueezeBox, X10 CM11A/CM12U.
                Scripts =
                Various

                Comment


                  #23
                  Originally posted by slbuck View Post
                  I'm fairly new to HS, but thought I'd weigh in on the events/script conversation relating to battery status. I debated doing this via events only or with a script and ultimately, I went with a script for this solution. The deciding factor was that I wanted a hands off way of managing battery levels. I didn't want to have to touch or update any events if I removed or added devices in the future. Since I also support other HomeSeer systems, having a script that would work on any install seemed the way to go.

                  For me, I wanted a single virtual device that always reflected the device name and battery value of the device with the lowest battery. I also wanted to be alerted when this battery level dropped too low.

                  After reading through various threads and the scripting documentation, I came up with the following script that does all of the above. In order to get this working, you'll need to do the following:
                  1. Copy the script to the HS scripts folder
                  2. Create a virtual device like in the attachments. The name is not important.
                  3. Create a timed event that runs the script every day. You need to pass in the reference ID of the virtual device you created in step 2.
                  4. Create an event that is triggered when the virtual device drops below a certain value and alerts/emails you. This can be an email, pushover, change the color of a lightbulb, etc.


                  That's it. I now have one event that triggers the script every morning. Whenever the script runs, it will automatically discover all your z-wave battery devices and update the virtual device created with the level and name of the device with the lowest battery and then another event that does something based upon the value of this virtual device.
                  This is another good approach - I like it. I tried it out and it works great. I did my event a little differently, so I would get a report if the device was in an invalid state or low battery alert as well as a low level. I used greater than 100% which should work.

                  I would like it if the devices status text showed the level (in percentage) of the battery as well as which battery. The graphic is fine, but a percentage shown in the device manager would be helpful. I will see if I can make that change, but scripting is not one of my strengths.

                  .
                  Attached Files

                  Comment


                    #24
                    I likey likey this too Stephen. Thanks!
                    cheeryfool

                    Comment


                      #25
                      Originally posted by rprade View Post
                      I would like it if the devices status text showed the level (in percentage) of the battery as well as which battery. The graphic is fine, but a percentage shown in the device manager would be helpful. I will see if I can make that change, but scripting is not one of my strengths.

                      .
                      try changing the line:

                      hs.SetDeviceString(lowBatDvRef, dvLowBat.Location(Nothing) & " " & dvLowBat.Name(Nothing), True) 'Set the lowest battery virtual device string to the location and name of the device with the lowest battery

                      to

                      hs.SetDeviceString(lowBatDvRef, dvLowBat.Location(Nothing) & " " & dvLowBat.Name(Nothing) & " = " & dvLowBat.devValue(Nothing) & "%", True) 'Set the lowest battery virtual device string to the location and name of the device with the lowest battery


                      Greig.
                      Zwave = Z-Stick, 3xHSM100� 7xACT ZDM230, 1xEverspring SM103, 2xACT HomePro ZRP210.
                      X10 = CM12U, 2xAM12, 1xAW10, 1 x TM13U, 1xMS13, 2xHR10, 2xSS13
                      Other Hardware = ADI Ocelot + secu16, Global Cache GC100, RFXtrx433, 3 x Foscams.
                      Plugings = RFXcom, ActiveBackup, Applied Digital Ocelot, BLDeviceMatrix, BLGarbage, BLLAN, Current Cost, Global Cache GC100,HSTouch Android, HSTouch Server, HSTouch Server Unlimited, NetCAM, PowerTrigger, SageWebcamXP, SqueezeBox, X10 CM11A/CM12U.
                      Scripts =
                      Various

                      Comment


                        #26
                        Originally posted by enigmatheatre View Post
                        try changing the line:

                        hs.SetDeviceString(lowBatDvRef, dvLowBat.Location(Nothing) & " " & dvLowBat.Name(Nothing), True) 'Set the lowest battery virtual device string to the location and name of the device with the lowest battery

                        to

                        hs.SetDeviceString(lowBatDvRef, dvLowBat.Location(Nothing) & " " & dvLowBat.Name(Nothing) & " = " & dvLowBat.devValue(Nothing) & "%", True) 'Set the lowest battery virtual device string to the location and name of the device with the lowest battery


                        Greig.
                        See - that's why you are the brains and I am the brawn

                        It works great!
                        .
                        Attached Files

                        Comment


                          #27
                          Originally posted by enigmatheatre View Post
                          try changing the line:

                          hs.SetDeviceString(lowBatDvRef, dvLowBat.Location(Nothing) & " " & dvLowBat.Name(Nothing), True) 'Set the lowest battery virtual device string to the location and name of the device with the lowest battery

                          to

                          hs.SetDeviceString(lowBatDvRef, dvLowBat.Location(Nothing) & " " & dvLowBat.Name(Nothing) & " = " & dvLowBat.devValue(Nothing) & "%", True) 'Set the lowest battery virtual device string to the location and name of the device with the lowest battery


                          Greig.
                          I knew there was something I forgot Thanks for the edit.

                          Comment


                            #28
                            Originally posted by rprade View Post
                            This is another good approach - I like it. I tried it out and it works great. I did my event a little differently, so I would get a report if the device was in an invalid state or low battery alert as well as a low level. I used greater than 100% which should work.

                            I would like it if the devices status text showed the level (in percentage) of the battery as well as which battery. The graphic is fine, but a percentage shown in the device manager would be helpful. I will see if I can make that change, but scripting is not one of my strengths.

                            .
                            Yeah, thanks for the edit for the invalid state. I forgot to add that back in my event. I originally was alerting via email directly from the script, but thought there was more flexibility using an event to alert instead. I forgot to include the invalid states.

                            Comment


                              #29
                              Originally posted by slbuck View Post
                              Yeah, thanks for the edit for the invalid state. I forgot to add that back in my event. I originally was alerting via email directly from the script, but thought there was more flexibility using an event to alert instead. I forgot to include the invalid states.
                              There's nothing that beats a group effort.

                              Comment


                                #30
                                Originally posted by rprade View Post
                                There's nothing that beats a group effort.
                                And what a Dream Team this forum has!

                                This would be great to display on the HSTouch screen too I'm thinking. I get the low alert email and I plan on getting to it, but with a son, his soccer, his school, my work...It gets put on the back burner. But if it's constantly on the hstouch screen, which I walk by all the time, it would be a good reminder.

                                So what happens if you have two low battery devices, do they both get displayed or only one at a time?
                                Tom
                                baby steps...starting again with HS3
                                HS3Pro: Z-NET & 80 Z wave Devices,
                                HSTouch: 4 Joggler (Android Kitkat), 2 iPhone, 3 iPads
                                Whole House Audio: 5 SqueezePlay Jogglers w Bose Speakers
                                In The Works: 10 Cameras Geovision, new Adecmo/Envisalink Alarm, Arduinos
                                System: XP on Fanless Mini-ITX w/ SSD

                                Comment

                                Working...
                                X