Battery

Devices using default battery configuration will only have reporting enabled for the PercentageRemaining attribute.

class st.zigbee.defaults.battery.BatteryVoltageConfiguration
cluster: number

PowerConfiguration ID 0x0001

attribute: number

BatteryVoltage ID 0x0020

minimum_interval: number

30 seconds

maximum_interval: number

21600 seconds (6 hours)

data_type: st.zigbee.data_types.Uint8

the Uint8 class

reportable_change: number

1 (.1 volts)

class st.zigbee.defaults.battery.BatteryPercentageConfiguration
cluster: number

PowerConfiguration ID 0x0001

attribute: number

BatteryPercentageRemaining ID 0x0021

minimum_interval: number

30 seconds

maximum_interval: number

21600 seconds (6 hours)

data_type: st.zigbee.data_types.Uint8

the Uint8 class

reportable_change: number

1 (.5 percent)

class st.zigbee.defaults.battery
zigbee_handlers: table
attribute_configurations: table
capability_handlers: table
default_voltage_configuration: st.zigbee.defaults.battery.BatteryVoltageConfiguration
default_percentage_configuration: st.zigbee.defaults.battery.BatteryPercentageConfiguration
DEVICE_MIN_VOLTAGE_KEY: str

a device field name to set the minimum voltage for default battery

DEVICE_MAX_VOLTAGE_KEY: str

a device field name to set the maximum voltage for default battery

DEVICE_VOLTAGE_TABLE_KEY: str

a device field name to set a table for voltage entries in default handling

static build_linear_voltage_init(bat_min, bat_max)

Build a function to set the devices battery_defaults.DEVICE_MIN_VOLTAGE_KEY and

battery_defaults.DEVICE_MAX_VOLTAGE_KEY in a devices init function to leverage the battery voltage default handler for alternative min and max volts. Will also disable battery percentage remaining attribute configuration and monitoring.

Parameters
  • bat_min (number) – the minimum voltage to consider for this devices scaling

  • bat_max (number) – the maximum voltage to consider for this devices scaling

Return type

fun(ZigbeeDriver, st.zigbee.Device, str, table)

static enable_battery_voltage_table(device, battery_table)

Enable the usage of a voltage to battery percentage table for reporting battery.

Will also disable battery percentage remaining attribute configuration and monitoring.

Parameters
  • device (st.zigbee.Device) – The device this message was received from containing identifying information

  • battery_table (table) – a map of battery voltages to battery percentages

static battery_volt_attr_handler(driver, device, value, zb_rx)

Default handler for battery voltage attribute on the power config cluster

This converts the Uint8 value from 0-254 to Battery.battery(0-100).

The exact behavior of this default function can be controlled by using a few fields set on a device

Using battery_defaults.DEVICE_VOLTAGE_TABLE_KEY If the device has a value set for the battery_defaults.DEVICE_VOLTAGE_TABLE_KEY this function will find the table entry whose key is the lowest number that is greater than or equal to the devices reported voltage. The value at that table entry is then used as the battery percentage

Using battery_defaults.DEVICE_MIN_VOLTAGE_KEY and battery_defaults.DEVICE_MAX_VOLTAGE_KEY If the device has values set for these keys, they are used for the bounds of linear scaling calculation of the battery percentage between the two reported values.

If none of the above keys are set, this will default to using a linear scaling between 2.0 and 3.0 volts.

Parameters
static battery_perc_attr_handler(driver, device, value, zb_rx)

Default handler for battery percentage attribute on the power config cluster

This converts the Uint8 value from 0-254 to Battery.battery(0-100).

Parameters