Announcement

Collapse
No announcement yet.

Display battery status in %

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

    Display battery status in %

    Hello!

    I am using the script from here: https://forums.homeseer.com/forum/ho...ck?postcount=6
    I find this script quite handy because it shows the % on each battery in my system. However this isnt workin with the Netatmo3 batteries because they have value from 1-10000, instead of 1-100 like many other battery devices. Is there a way to divide the value by 100 to get the correct %value or is this something that has to be done from the creator of the plugin?
    This could maybe be a feature in the plugin that we could check if we wanted?


    Note: Since the script checks if battery > 100 it will automaticly print out error on Netatmo device batteries since they have a valuerange 100x normal batteries.(See pic below) Click image for larger version

Name:	6.PNG
Views:	253
Size:	34.7 KB
ID:	1289835

    #2
    Zheep-

    Until the author updates the plugin, you will have to work around the issue. Here are a few ideas:

    1. Create a separate virtual device that will have the corrected value. Here is an excerpt from this post.

    Originally posted by mrhappy View Post
    If you create a new virtual device then set up a range value/status pair (end tab labelled status-graphics) that accepts a decimal value wide enough. Set the suffix to if you so wish, set it to status rather than both/control.

    Create an event and the trigger of the event is whenever your Neatatmo batteryvalue changes to anything, in the action add a single line scripting command which should be like this;

    &hs.setdevicevaluebyref(1234, (hs.devicevalueex(508) / 100), True)

    And see what it does, 1234 is the reference of your new virtual device and 508 is the reference of your Neatatmo input device.
    Note that I modified mrhappy's original quote to better suit your situation. I've highlighted my changes in purple italics. I have not tested this but it should at least get you started.


    2. You can modify the code of your script to handle the error differently...

    On lines 34-38 you have this IF statement:
    Code:
       If dv.devValue(Nothing) > 100 Then ' if battery value is larger than 100(%), battery is invalid state
          myArray(UBound(myArray) - 1).devValue = "  ERROR"
       Else
          myArray(UBound(myArray) - 1).devValue = (dv.devValue(Nothing).ToString & "%").PadLeft(7)
       End If
    If you wrap that with an IF statement looking for your device reference ID, you can do the math there...

    Code:
       If [ref id is 508]
          [save value as original value/100]
       Else
    [COLOR=#A9A9A9]      If dv.devValue(Nothing) > 100 Then ' if battery value is larger than 100(%), battery is invalid state
             myArray(UBound(myArray) - 1).devValue = "  ERROR"
          Else
             myArray(UBound(myArray) - 1).devValue = (dv.devValue(Nothing).ToString & "%").PadLeft(7)
          End If[/COLOR]
       End If
    Note... I can't be sure without testing what the correct code lines would be... but your basis is already in the original code. mwaite would be a good person to ask how to modify his code, but maybe this will get you going in the right direction:

    Code:
       If [I][COLOR=#800080]dv.Ref(Nothing).ToString = 508
          myArray(UBound(myArray) - 1).devValue = ((dv.devValue(Nothing) / 100).ToString & "%").PadLeft(7)[/COLOR][/I]
       Else
    [COLOR=#A9A9A9]      If dv.devValue(Nothing) > 100 Then ' if battery value is larger than 100(%), battery is invalid state
             myArray(UBound(myArray) - 1).devValue = "  ERROR"
          Else
             myArray(UBound(myArray) - 1).devValue = (dv.devValue(Nothing).ToString & "%").PadLeft(7)
          End If[/COLOR]
       End If
    The biggest thing I'm not sure about is doing math with the .ToString function. I hope some of this helps...

    Comment


      #3
      B1Trash

      Thanks for your quick reply!
      What i have done is almost what u said in suggestion 1. But instead of creating a virtual device, i just updated the value on the device itself.
      The reason for not using a virtual device is that i would have to change so many things to make it fit into the script mentioned.

      However by using this code &hs.setdevicevaluebyref(508, (hs.devicevalueex(508) / 100), True) in a script i was able to change the value until next change. To avoid looping(which happend when i first tried it) i have added a new then setting and added a delay for when it can run again. Look on the pic under for my event setup.

      Click image for larger version

Name:	prosent.PNG
Views:	195
Size:	54.0 KB
ID:	1289903
      This is how it looks in the advanced tab now, previously it was 6144. So the only thing left to do now is create a new statusgraphics acordingly to the changes, i.e Range value from 0-100 and graphics that correspond.
      Click image for larger version

Name:	prosent2.PNG
Views:	175
Size:	16.0 KB
ID:	1289904



      When i think about it now it probably should work with only the cannot re-run for timer set to 10 secs. This should be within the limit of the refresh rate of the sensor aswell which by the plug-ins standards cant be less than 5 minutes.

      Comment


        #4
        I never thought of resetting its own value. That's brilliant!

        Comment


          #5
          That's a great function; should be built-into HS.

          But, I coped the file into the HS3 scripts folder (running HS4) and added it to a manually executed event (for testing). I did edit the Email TO address.
          BUT, when I execute the event I get:

          HomeSeer Event Error Event (Low Battery, Send Email) action Run Script could not be completed - action does not have a valid script file or immediate command"

          I have a feeling I haven't done something fundamental correctly -- any ideas?

          Comment


            #6
            Jeff492
            If it is the script from the post i mentioned that is not working, you should probably try to ask in that thread.
            I currently dont have anything from HS running, as the reason why i used HS was for my bachelor thesis. So sadly I can't help you with this problem right now..

            I have no idea if anything major has changed from HS3 to HS4, and if that is the reason why it doesnt work.

            I hope you can figure it out, so you get the script up and running, because it is indeed a great function to have!

            Comment


              #7
              I am using the SDJ-Health plugin with HomeSeer to monitor battery levels in devices. It expects battery levels to be in percent, and thus gets very confused with values like 5000%.

              I found this page https://dev.netatmo.com/apidocumentation/weather which also tells us that it is not even possible just to divide by 100 to get the correct results. It also differs between different Netatmo sensors 🤔 Go Netatmo... 😜

              Please Ultrajones , could you update the plugin to do percent calculation within the plugin now that Netatmo actually has provided the correct intervals, or at least update the very low, low, medium, high, full, max ranges for the corresponding devices?

              Comment


                #8
                Originally posted by zyrgh View Post
                I am using the SDJ-Health plugin with HomeSeer to monitor battery levels in devices. It expects battery levels to be in percent, and thus gets very confused with values like 5000%.
                zyrgh
                Actually SDJ-Health can cope quite happily with battery ranges that aren't 0-100%. You can configure a scaling factor either globally or set differently for each battery device. See 'Miscellaneous Settings for Battery Device Monitoring' and 'Local Configuration for Battery Devices' in the guide.

                Presuming that most of your battery devices go from 0-100% you would leave the global factor at 1.0 and set the local Battery Level Factor for any devices that are different. If, for example, your battery device goes from 0-5000 then you would set the factor for that device to 0.02 so that 5000 represents 100%.

                Click image for larger version

Name:	BatteryFactor.JPG
Views:	108
Size:	71.9 KB
ID:	1447283

                I hope this helps.

                Steve

                Comment


                  #9
                  Thank you SteveMSJ, I looked at that earlier, but to me it doesn't seem to be just a conversion factor, but more of an "offset" + conversion factor in the Netatmo case but I might be wrong. The different modules all have max as 6000 but they have a different "very low" and no one starts at 0 according to the (currently unavailable) Netatmo web page. I pasted the values below for reference. The UltraNetatmo3 plugin has 10000 as max for all modules and different medium/low values for indoor and outdoor modules.

                  Smart anemometer battery status Description
                  6000 max
                  5590 full
                  5180 high
                  4770 medium
                  4360 low
                  <4360 very low
                  Outdoor Module and Rain
                  Gauge battery status
                  Description
                  6000 max
                  5500 full
                  5000 high
                  4500 medium
                  4000 low
                  <4000 very low
                  Indoor module battery status Description
                  6000 max
                  5640 full
                  5280 high
                  4920 medium
                  4560 low
                  <4560 very low

                  Comment


                    #10
                    Originally posted by zyrgh View Post
                    Thank you SteveMSJ, I looked at that earlier, but to me it doesn't seem to be just a conversion factor, but more of an "offset" + conversion factor in the Netatmo case but I might be wrong. The different modules all have max as 6000 but they have a different "very low" and no one starts at 0 according to the (currently unavailable) Netatmo web page. I pasted the values below for reference. The UltraNetatmo3 plugin has 10000 as max for all modules and different medium/low values for indoor and outdoor modules.
                    Smart anemometer battery status Description
                    6000 max
                    5590 full
                    5180 high
                    4770 medium
                    4360 low
                    <4360 very low
                    Outdoor Module and Rain
                    Gauge battery status
                    Description
                    6000 max
                    5500 full
                    5000 high
                    4500 medium
                    4000 low
                    <4000 very low
                    Indoor module battery status Description
                    6000 max
                    5640 full
                    5280 high
                    4920 medium
                    4560 low
                    <4560 very low
                    zyrgh If you set the Battery Level Factor in SDJ-Health to 0.0166 then it will show 100% when the battery levels are at their maximum of 6000.

                    You can then set your Battery Trigger Values 'Low Battery Level' to whatever you want to be alerted at. I don't know how accurate the battery levels are for these devices but if you wanted to be alerted when the reading dropped to say 4500 that would be a percentage of 75%. You can set the warning level different for each device if you want.

                    Not many devices actually report battery readings down to zero, although some do.

                    I hope that helps.

                    Steve

                    Comment


                      #11
                      Thank you SteveMSJ ! 😊

                      I'll use that as a workaround for now. I still hope that Ultrajones can update the UltraNetatmo3 plugin with the correct values and/or percent calculation some time in the future though.

                      Comment

                      Working...
                      X