Hello. I’m trying to report the battery remaining value from an STM32WB55 microcontroller.
I am reporting the battery voltage and remaining percentage to the ‘PowerConfig’ cluster, but it’s not showing up in ZHA.
I assume it’s because the Zigbee stack from ST doesn’t seem to allow for changing the power source in the Basic cluster, so I am trying to see if it is possible to change the node descriptor via a ZHA quirk and not having much luck.
So far my quirk looks like this:
class STM32Sensor(CustomDevice):
"""STM32 sensor device."""
def __init__(self, *args, **kwargs):
"""Init."""
self.temperature_bus = Bus()
super().__init__(*args, **kwargs)
signature = {
MODELS_INFO: [("stm32", "wb55")],
NODE_DESCRIPTOR: STM32_MAINS_NODE_DESC,
ENDPOINTS: {
1: {
PROFILE_ID: 260,
DEVICE_TYPE: 0x000c,
INPUT_CLUSTERS: [
#BasicCluster.cluster_id,
#Identify.cluster_id,
#TemperatureMeasurementCluster.cluster_id,
0x0000,
0x0001,
0x0402
],
OUTPUT_CLUSTERS: [
],
},
242: {
PROFILE_ID: 41440,
DEVICE_TYPE: 0x0061,
INPUT_CLUSTERS: [
],
OUTPUT_CLUSTERS: [
#Green power
0x0021
],
}
},
}
replacement = {
SKIP_CONFIGURATION: True,
NODE_DESCRIPTOR: STM32_BATTERY_NODE_DESC,
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
#BasicCluster.cluster_id,
#Identify.cluster_id,
#TemperatureMeasurementCluster.cluster_id,
0x0000,
0x0001,
0x0402
],
OUTPUT_CLUSTERS: [
],
},
242: {
#PROFILE_ID: 41440,
#DEVICE_TYPE: 0x0061,
INPUT_CLUSTERS: [
],
OUTPUT_CLUSTERS: [
#Green power
0x0021
],
}
},
}
STM32_MAINS_NODE_DESC = NodeDescriptor(
complex_descriptor_available=1,
user_descriptor_available=1,
reserved=0,
aps_flags=0,
#mac_capability_flags=<MACCapabilityFlags.AllocateAddress|RxOnWhenIdle|MainsPowered|FullFunctionDevice: 142>,
mac_capability_flags=142,
manufacturer_code=4311,
maximum_buffer_size=57,
maximum_incoming_transfer_size=2000,
server_mask=11264,
maximum_outgoing_transfer_size=128,
)
STM32_BATTERY_NODE_DESC = NodeDescriptor(
complex_descriptor_available=1,
user_descriptor_available=1,
reserved=0,
aps_flags=0,
#mac_capability_flags=<MACCapabilityFlags.AllocateAddress|RxOnWhenIdle|FullFunctionDevice: 138>,
mac_capability_flags=138,
manufacturer_code=4311,
maximum_buffer_size=57,
maximum_incoming_transfer_size=2000,
server_mask=11264,
maximum_outgoing_transfer_size=128,
)