Device status message shows conflicting battery level & external power source

On a device status message I am seeing batteryLevel of 0, which from docs indicates 0 means external power source. But the external power source field is false. The end device is externally powered, so it seems just the externalPowerSource field is incorrect while the batteryLevel is correct.

    "externalPowerSource": false,
    "batteryLevel": 0,
    "batteryLevelUnavailable": true
 }

Anything I could check in the config to see if I have something set wrong that would result in this output?

I have the same problem on my Raspberry Pi. Weird! But I think this must be a Raspberry Pi problem.

Hi @John_Roesler that might be something to fix in the docs, please see the definition of the status message here:

When battery_level_unavailable is set to true, then it means no battery-level status is available. I believe battery_level is actually converted to a percentage.

Ah, so when the batteryLevelUnavailable is true, I should expect batteryLevel to be the zero value the field, in this case 0 and can be ignored.

If the externalPowerSource is coming back false but the device is powered, would that be an issue with how the device is responding to the status message request from chirpstack?

Would probably be better if it were NULL instead of zero - wouldn’t it? 0 implies a value, null implies the absence of one.

@John_Roesler @Botched1

With Protobuf 3 you can’t specify a field as optional, thus it always defaults back to 0 when not set. You are correct that if batteryLevelUnavailable, the rest should be ignored.

If batteryLevelUnavailable is false and externalPowerSource is true, then you can ignore batteryLevel, in the last case you should check batteryLevel (as the device is not powered by an external source).

If one of you would like a pull-request to make the documentation more clear, that would be great :slight_smile:

2 Likes