Announcement

Collapse
No announcement yet.

Notification when Battery Devices Fail

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

    Notification when Battery Devices Fail

    Which is the best way to configure events or a device to get a Root Error Status or notification when a battery operated device has failed to wake?

    #2
    I'm interested in this as well. Sometimes I have devices with 50% battery left, then all of a sudden, no update from these devices only to find out that the batteries died.

    Sent from my XT1060 using Tapatalk

    Comment


      #3
      I'm starting to think there is probably no one good way to do this, my Fibaro motion sensors started to send ghost motion signals when no one was in the room (the local exorcist couldn't find anything). The battery status devices have never worked right and the device would still send the temp/light just fine so it would not appear dead. Replacing the battery cures them and they are all starting to behave the same at installation+sixish months.

      For monitoring some of the devices I use a script, there is another script out there that looks for anything with the device type of battery whereas I look at devices I am interested in and check when they last updated. If they last updated some time ago (18hrs) I just send myself a notification to check them.

      Code:
      Sub Main(ByVal Parm As Object)
      
          Try
              'careful with ref 33 as it might not change for days (front door sensor)
              Dim dvRefList() As Integer = {299, 300, 152, 151, 38, 39, 141, 142, 159, 160}
      
              For Each DeviceReference As Integer In dvRefList
      
                  'hs.writelog("BatteryMonitor", "Device Name: " & DeviceReference & " Last Change Status: " & hs.DeviceLastChangeRef(DeviceReference))
      
                  Dim dFrom As DateTime = hs.DeviceLastChangeRef(DeviceReference)
                  Dim dTo As DateTime = DateTime.Now
                  Dim TS As TimeSpan = dTo - dFrom
      
                  'hs.writelog("BatteryMonitor", "Hours: " & TS.Hours) 'output 16 mins in format 00:16:00
      
                  If TS.Hours > 18 Then
                      'should capture all devices
                      'warn about the devices but do not warn excessively
                      'perhaps change a device value? 
      
                      'if I get the reference from the global variable and trigger the event if the reference has changed then this should be good enough to warn of the last device?
      
                      If hs.GetVar("BM-LastBatteryReference") <> DeviceReference Then
      
                          hs.writelog("BatteryMonitor", "Timer Elapsed - New Reference: " & DeviceReference)
      
                          Dim dv As Scheduler.Classes.DeviceClass
                          dv = hs.GetDeviceByRef(DeviceReference)
      
                          hs.saveVar("BM-LastBatteryReference", DeviceReference)
                          hs.saveVar("BM-LastBatteryName", dv.Location(Nothing) & " " & dv.Name(Nothing))
                          hs.triggerevent("Warn About Battery Status")
      
                      End If
      
                  End If
      
              Next
      
          Catch ex As Exception : hs.writelog("BatteryMonitor", "Exception: " & ex.message.tostring)
          End Try
      
      End Sub
      
      Sub CreateGVar(ByVal Parms As Object)
      
          Try
              hs.writelog("BatteryMonitor", "Creating Global Variables")
              hs.createVar("BM-LastBatteryReference")
              hs.saveVar("BM-LastBatteryReference", 0)
              hs.createVar("BM-LastBatteryName")
              hs.saveVar("BM-LastBatteryName", "Awaiting Data")
          Catch ex As Exception : hs.writelog("BatteryMonitor", "Exception Creating Global Variables")
          End Try
      
      End Sub

      Comment

      Working...
      X