Announcement

Collapse
No announcement yet.

Battery reset button

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

    Battery reset button

    I have a number of Z-Wave devices which report battery status, but they only do so when it changes and tend to miss when a new battery is installed.

    Here are two scripts which will add a "Reset" button to the battery device, which then calls a script to set the value to 100(%).

    Put this script in yous scripts folder, named battery_reset.vb, to be called by the button:

    Code:
    Sub Main(parms as object)
      Dim ref as Integer = CInt(parms(0))
    
      hs.WriteLog("Script", "Battery reset button device " & ref)
    
      hs.SetDeviceValueByRef(ref, 100, true)
    End Sub
    For each battery device, use this command in Script Commands (HS4) or Control Panel (HS3), replacing REF with the device reference:

    [CODE]
    hs.DeviceScriptButton_AddButton(REF, "Reset", 1.0, "battery_reset.vb", Nothing, Nothing, 1, 1, 1)
    [CODE]

    #2

    Tried this and go this error on HS4. Used the Script Commands in the Tools Menu. HS added the "&".

    8/21/2020 11:26:07 PM
    HomeSeer
    System
    Control Panel Immediate Script: &hs.DeviceScriptButton_AddButton(214, "Reset", 1.0, "battery_reset.vb", Nothing, Nothing, 1, 1, 1))

    8/21/2020 11:26:07 PM

    HomeSeer
    Error
    Running script(2) &hs.DeviceScriptButton_AddButton(214, "Reset", 1.0, "battery_reset.vb", Nothing, Nothing, 1, 1, 1)), init error: Syntax error



    Comment


      #3
      Figured out the problem. You have a extra ")" at the end of the add button script command. Should be:

      Code:
      hs.DeviceScriptButton_AddButton(REF, "Reset", 1.0, "battery_reset.vb", Nothing, Nothing, 1, 1, 1)

      Comment


        #4
        Originally posted by srodgers View Post
        Figured out the problem. You have a extra ")" at the end of the add button script command. Should be:

        Code:
        hs.DeviceScriptButton_AddButton(REF, "Reset", 1.0, "battery_reset.vb", Nothing, Nothing, 1, 1, 1)
        Thanks for the correction.

        Comment


          #5
          New problem. I updated to HS4 V4.1.4.0 and When HS4 restarted all the battery reset buttons were gone. Does this change persist across restarts or did the HS update kill this mod?

          Comment


            #6
            Just restarted and again the reset button disappear. I like this mod so will try adding the script line for adding the reset button to the startup.vb t restore them after each restart unless there is a better way.

            Comment


              #7
              Originally posted by srodgers View Post
              Just restarted and again the reset button disappear. I like this mod so will try adding the script line for adding the reset button to the startup.vb t restore them after each restart unless there is a better way.
              Thanks for the info - I hadn't restarted HS4 since I re-added my buttons and see the same thing, they all disappear :-(

              Will have to do the same with the startup.

              Comment


                #8
                I would like to try/use this as well (all my smoke detectors say 0%).

                What do I do with the [CODE]
                hs.DeviceScriptButton_AddButton(REF, "Reset", 1.0, "battery_reset.vb", Nothing, Nothing, 1, 1, 1)
                [CODE]

                Do I insert this in an event?

                Thanks,
                Cor

                Comment


                  #9
                  Originally posted by Corvl1 View Post
                  I would like to try/use this as well (all my smoke detectors say 0%).

                  What do I do with the [CODE]
                  hs.DeviceScriptButton_AddButton(REF, "Reset", 1.0, "battery_reset.vb", Nothing, Nothing, 1, 1, 1)
                  [CODE]

                  Do I insert this in an event?

                  Thanks,
                  Cor
                  1. Make sure the battery_reset.vb script is in your scripts folder.
                  2. Run that command for each device, either in an event or in the Script Commands / Control Panel option from the UI - replacing "REF" with the reference of your device.

                  If you're using HS4, unfortunately it forgets them on restart - but for that you can put it in a startup event to recreate them (see https://forums.homeseer.com/forum/ho...artup-shutdown).

                  I have another script which helps with that - it takes a comma separated list of device IDs as a parameter and creates a button for each.

                  battery-reset-button.vb
                  Code:
                  Sub Main(parms as object)
                    Dim p() As String = CStr(parms).Split(",")
                  
                    For Each ref as String in p
                      hs.WriteLog("Script", "Setting battery reset button device " & ref)
                      hs.DeviceScriptButton_AddButton(CInt(ref), "Reset", 1.0, "battery_reset.vb", Nothing, Nothing, 1, 1, 1)
                    Next
                  End Sub
                  Click image for larger version

Name:	Capture.PNG
Views:	272
Size:	199.1 KB
ID:	1414435

                  Comment


                    #10
                    Thank you,

                    I did as you described in your last post. I do get the reset button ( I tried a fibaro window -door sensor and a popp smoke detector) , but when I click the "reset" button , nothing happends.
                    Click image for larger version

Name:	2020-08-30 11_51_01-Devices.jpg
Views:	238
Size:	39.7 KB
ID:	1415272

                    Thanks,
                    Cor

                    Comment


                      #11
                      Is there anything in the log?

                      Comment


                        #12
                        *edit* : got it; there needs to be 2 scripts in the scripts folder:
                        battery_reset.vb & battery-reset-button.vb

                        I only had the button-script

                        Thanks,
                        Cor


                        Comment


                          #13
                          I know this forum is about scripts and development, but in case anyone was interested, there is a free plug in called SDJ-Health I'm using that does this -- monitors battery and provides with manual or auto reset upon battery change.

                          Comment

                          Working...
                          X