Battery status
The battery status object represents the status of a device battery. This object is normally used to update the battery level through the updateDeviceBattery method of the device object, usually as part of a LoRaWAN or MQTT data conversion script.
Properties
### type (int enum)
The type property indicates the battery type. The possible values for this property are as follows:
- batteryType.default (1): this is the default value for this property, normally used when the device has a single battery.
- batteryType.primary (2): when the device has more than one battery, this value indicates it is the primary battery.
- batteryType.secondary (3): when the device has more than one battery, this value indicates it is the secondary battery.
- batteryType.backup (4): when the device has more than one battery, this value indicates it is the backup battery.
Examples
This example shows how to report a battery level of 72% for the primary battery, and 68% for the secondary battery, on a device that has both primary and secondary batteries.
myDevice.updateDeviceBattery
(
[
{ type: batterytype.primary, percentage: 72 },
{ type: batteryType.secondary, percentage: 68}
]
);### percentage (int) The percentage property indicates the battery charge percentage (0-100%).
Examples
This example shows how to report a battery level of 72% for the primary battery, and 68% for the secondary battery, on a device that has both primary and secondary batteries.
myDevice.updateDeviceBattery
(
[
{ type: batterytype.primary, percentage: 72 },
{ type: batteryType.secondary, percentage: 68}
]
);### voltage (double) The voltage property allows indicating the battery voltage.
Examples
This example shows how to report a battery voltage of 2.95V for a device that has a single battery.
myDevice.updateDeviceBattery({ voltage: 2.95 });### state (int enum)
The state property allows indicating the battery status. The possible values for this property are as follows:
- batteryState.ok (1): indicates that the battery charge allows the device to function normally.
- batteryState.low (2): indicates that the battery charge is low and should be replaced.
If the battery state is not reported, the platform will assume the ok state.
Examples
This example shows how to report a low battery state for a device that has a single battery.
myDevice.updateDeviceBattery({ voltage: 2.95, state: batteryState.low });