libraries batteryLib - kkossev/Hubitat GitHub Wiki
batteryLib
importUrl: 'https://raw.githubusercontent.com/kkossev/Hubitat/refs/heads/development/Libraries/batteryLib.groovy'
The 'batteryLib.groovy' must be included when the driver handles battery-powered devices. Including the library adds the following :
- Capabilities:
- 'Battery'
- **Attributes **:
- 'battery'
- 'batteryVoltage'
- 'lastBattery''
- Preferences
- 'voltageToPercent' - will be shown only when the 'advancedOptions' is enabled and 'BatteryVoltage' is defined in DEVICE.capabilities.
- 'BatteryDelay'- will be shown only when the 'advancedOptions' is enabled and 'batteryDelay' is defined in DEVICE.capabilities. This is an anti-spam filter for some Tuya devices that send battery reports very frequently.
Public methods:
- standardParsePowerCluster()
- processes Zigbee messages from the Power cluster 0x0001, attributes 0x020 and 0x021
- updates state.lastRx['batteryTime'], state.stats['bVoltCtr'], state.stats['battCtr']
- sendBatteryVoltageEvent()
- sendBatteryPercentageEvent()
- tuyaToBatteryLevel()
- batteryInitializeVars()
- batteryRefresh()