External Power Boolean: Data Fields?

I am adding some logic to one of my existing custom data fields, to alert me when the battery goes below 8%. beep and display a brief msg each time the battery level drops a percentage point. 8%, 7%, 6%, etc.

To remind me to plug in external battery power.

Is there a call I can make to tell me I have external battery power supplied, to turn off alerts below 8%? I could implement that another way, since the battery level will be increasing, but curious if there is a "external power" boolean available to data fields. Could not find it in the API guides.

Thanks!
  • Former Member
    Former Member over 8 years ago
    There is not currently an API that provides the status of external power.
  • The only way you can really detect charging in CIQ is to watch to see if the battery level is increasing. Having something like an "isCharging" boolean in Sys.getSystemStats() (same place as "battery") has been requested in the past, but it's not there.

    I check for charging in watchfaces, etc, and it is a bit tricky. On some devices, the battery level is returned with an integer and decimal part, so you can watch for 10.01 to go to 10.02, but on others, you only see an integer value, so the first you see is when it goes from 10.0 to 11.0. On the Oregon, it's different too. The battery level is in 20% chunks, so if you're at 20.0, the next you see is 40.0.

    The other half of this is to also detect when you're no longer charging. What I do is both watch for the battery level to start dropping, as well as looking for the battery to be at the same level for a period of time (I use something like 1 minute). The drain from just a watchface an be very minor, and otherwise I show charging for 5+ minutes after it's unplugged. On devices with only the integer part, it could take quite some time to drop from 100.0 to 99.0, and you don't want to indicate it's still charging that whole time.

    These are kind of just "guesses" about when the device is charging, but it's something you can try.
  • Charging

    That helps a lot. Thanks!!


    The only way you can really detect charging in CIQ is to watch to see if the battery level is increasing. Having something like an "isCharging" boolean in Sys.getSystemStats() (same place as "battery") has been requested in the past, but it's not there.

    I check for charging in watchfaces, etc, and it is a bit tricky. On some devices, the battery level is returned with an integer and decimal part, so you can watch for 10.01 to go to 10.02, but on others, you only see an integer value, so the first you see is when it goes from 10.0 to 11.0. On the Oregon, it's different too. The battery level is in 20% chunks, so if you're at 20.0, the next you see is 40.0.

    The other half of this is to also detect when you're no longer charging. What I do is both watch for the battery level to start dropping, as well as looking for the battery to be at the same level for a period of time (I use something like 1 minute). The drain from just a watchface an be very minor, and otherwise I show charging for 5+ minutes after it's unplugged. On devices with only the integer part, it could take quite some time to drop from 100.0 to 99.0, and you don't want to indicate it's still charging that whole time.

    These are kind of just "guesses" about when the device is charging, but it's something you can try.
  • Oh, one thing I forgot, is when I talk about increasing, decreasing, and same on devices with the decimal part, you want to use a "range" when comparing the values. The least significant part can bounce around a bit. If you're going from cold to warm (at least on a watchface), the battery may go up a tiny bit as the battery warms up, and you may have to play around with the range to reduce "false positives" for charging.