Koenkk / zigbee2mqtt

Zigbee 🐝 to MQTT bridge 🌉, get rid of your proprietary Zigbee bridges 🔨
https://www.zigbee2mqtt.io
GNU General Public License v3.0
11.77k stars 1.64k forks source link

No battery update #21611

Open Ev15 opened 6 months ago

Ev15 commented 6 months ago

What happened?

Battery value of some (for example TS0203) shows 1%. Battery is new. After changing the name of the device (friendly name) the battery shows 100%. So when i change for example ''door'' into ''door1'' the value change from 1% to 100%.

But after some time the batt value changes back to 1%, no matter renaming. It look like there are no updates. Even after 48 hours. Update: after shortly press the pair button on the device battery level now show 100%. Now waiting if it updates correctly when draining. Update II: back to 1% after about one hour...

What did you expect to happen?

Getting the right battery values

How to reproduce it (minimal and precise)

rename device. After it battery shows 1% change the name to anything. Changing the name back to the previous one the battery shows 1% again.

Zigbee2MQTT version

1.35.3

Adapter firmware version

20220219

Adapter

Sonoff dongle ZBDongle-P

Setup

Pi4

Debug log

No response

krair commented 6 months ago

I have exactly the same issue, however I haven't found a way to even get it to even temporarily show the updated percentage after a replacement.

I replaced one battery about a month ago which is reporting correctly (started reporting correctly just after replacement), but two others I replaced about 5 days ago and they are not updated.

I am seeing the battery_low field as reporting false, so it's just the percentage that's not reading correctly.

krair commented 6 months ago

So I set herdsmen into debug mode, and clicked reconfigure for the "Window Lounge" TS0203 device. The only thing I can find here is that it seems to fail to find the genPowerCfg endpoint:

2024-03-06T10:07:30.477Z zigbee-herdsman:controller:endpoint Bind 0xa4c1381753519a62/1 genPowerCfg from '0x00124b002a2e8f19/1'
2024-03-06T10:07:30.478Z zigbee-herdsman:adapter:zStack:znp:SREQ --> ZDO - bindReq - {"dstaddr":53990,"srcaddr":"0xa4c1381753519a62","srcendpoint":1,"clusterid":1,"dstaddrmode":3,"dstaddress":"0x00124b002a2e8f19","dstendpoint":1}
2024-03-06T10:07:30.478Z zigbee-herdsman:adapter:zStack:unpi:writer --> frame [254,23,37,33,230,210,98,154,81,83,23,56,193,164,1,1,0,3,25,143,46,42,0,75,18,0,1,94]
2024-03-06T10:07:30.489Z zigbee-herdsman:adapter:zStack:unpi:parser <-- [254,1,101,33,0,69]
2024-03-06T10:07:30.489Z zigbee-herdsman:adapter:zStack:unpi:parser --- parseNext [254,1,101,33,0,69]
2024-03-06T10:07:30.489Z zigbee-herdsman:adapter:zStack:unpi:parser --> parsed 1 - 3 - 5 - 33 - [0] - 69
2024-03-06T10:07:30.489Z zigbee-herdsman:adapter:zStack:znp:SRSP <-- ZDO - bindReq - {"status":0}
2024-03-06T10:07:30.489Z zigbee-herdsman:adapter:zStack:unpi:parser --- parseNext []
2024-03-06T10:07:31.737Z zigbee-herdsman:adapter:zStack:unpi:parser <-- [254,29,68,129,0,0,2,7,164,95,2,1,0,21,0,176,179,35,0,0,9,8,90,10,0,4,42,1,0,0,164,95,29,136]
2024-03-06T10:07:31.737Z zigbee-herdsman:adapter:zStack:unpi:parser --- parseNext [254,29,68,129,0,0,2,7,164,95,2,1,0,21,0,176,179,35,0,0,9,8,90,10,0,4,42,1,0,0,164,95,29,136]
2024-03-06T10:07:31.737Z zigbee-herdsman:adapter:zStack:unpi:parser --> parsed 29 - 2 - 4 - 129 - [0,0,2,7,164,95,2,1,0,21,0,176,179,35,0,0,9,8,90,10,0,4,42,1,0,0,164,95,29] - 136
2024-03-06T10:07:31.738Z zigbee-herdsman:adapter:zStack:znp:AREQ <-- AF - incomingMsg - {"groupid":0,"clusterid":1794,"srcaddr":24484,"srcendpoint":2,"dstendpoint":1,"wasbroadcast":0,"linkquality":21,"securityuse":0,"timestamp":2339760,"transseqnumber":0,"len":9,"data":{"type":"Buffer","data":[8,90,10,0,4,42,1,0,0]}}
2024-03-06T10:07:31.740Z zigbee-herdsman:controller:log Received 'zcl' data '{"frame":{"Header":{"frameControl":{"frameType":0,"manufacturerSpecific":false,"direction":1,"disableDefaultResponse":false,"reservedBits":0},"transactionSequenceNumber":90,"manufacturerCode":null,"commandIdentifier":10},"Payload":[{"attrId":1024,"dataType":42,"attrData":1}],"Command":{"ID":10,"name":"report","parameters":[{"name":"attrId","type":33},{"name":"dataType","type":32},{"name":"attrData","type":1000}]}},"address":24484,"endpoint":2,"linkquality":21,"groupID":0,"wasBroadcast":false,"destinationEndpoint":1}'
2024-03-06T10:07:31.744Z zigbee-herdsman:controller:endpoint DefaultResponse 0xe0798dfffe35f821/2 1794(10, {"timeout":10000,"disableResponse":false,"disableRecovery":false,"disableDefaultResponse":true,"direction":1,"srcEndpoint":null,"reservedBits":0,"manufacturerCode":null,"transactionSequenceNumber":null,"writeUndiv":false})
2024-03-06T10:07:31.745Z zigbee-herdsman:adapter:zStack:adapter sendZclFrameToEndpointInternal 0xe0798dfffe35f821:24484/2 (0,0,2)
2024-03-06T10:07:31.745Z zigbee-herdsman:adapter:zStack:znp:SREQ --> AF - dataRequest - {"dstaddr":24484,"destendpoint":2,"srcendpoint":1,"clusterid":1794,"transid":113,"options":0,"radius":30,"len":5,"data":{"type":"Buffer","data":[24,90,11,10,0]}}
2024-03-06T10:07:31.745Z zigbee-herdsman:adapter:zStack:unpi:writer --> frame [254,15,36,1,164,95,2,1,2,7,113,0,30,5,24,90,11,10,0,254]
2024-03-06T10:07:31.746Z zigbee-herdsman:adapter:zStack:unpi:parser --- parseNext []
Zigbee2MQTT:debug 2024-03-06 11:07:31: Received Zigbee message from 'Heater-Ext-Hallway', type 'attributeReport', cluster 'seMetering', data '{"instantaneousDemand":1}' from endpoint 2 with groupID 0
Zigbee2MQTT:info  2024-03-06 11:07:31: MQTT publish: topic 'zigbee2mqtt/Heater-Ext-Hallway', payload '{"energy":null,"linkquality":21,"local_temperature":15.75,"occupied_heating_setpoint":19.5,"pi_heating_demand":0,"power":1,"schneider_pilot_mode":"pilot","system_mode":"off"}'
2024-03-06T10:07:31.756Z zigbee-herdsman:adapter:zStack:unpi:parser <-- [254,1,100,1,0,100]
2024-03-06T10:07:31.756Z zigbee-herdsman:adapter:zStack:unpi:parser --- parseNext [254,1,100,1,0,100]
2024-03-06T10:07:31.756Z zigbee-herdsman:adapter:zStack:unpi:parser --> parsed 1 - 3 - 4 - 1 - [0] - 100
2024-03-06T10:07:31.757Z zigbee-herdsman:adapter:zStack:znp:SRSP <-- AF - dataRequest - {"status":0}
2024-03-06T10:07:31.757Z zigbee-herdsman:adapter:zStack:unpi:parser --- parseNext []
2024-03-06T10:07:31.759Z zigbee-herdsman:adapter:zStack:unpi:parser <-- [254,3,68,128,0,1,113,183]
2024-03-06T10:07:31.759Z zigbee-herdsman:adapter:zStack:unpi:parser --- parseNext [254,3,68,128,0,1,113,183]
2024-03-06T10:07:31.759Z zigbee-herdsman:adapter:zStack:unpi:parser --> parsed 3 - 2 - 4 - 128 - [0,1,113] - 183
2024-03-06T10:07:31.759Z zigbee-herdsman:adapter:zStack:znp:AREQ <-- AF - dataConfirm - {"status":0,"endpoint":1,"transid":113}
2024-03-06T10:07:31.759Z zigbee-herdsman:adapter:zStack:unpi:parser --- parseNext []
2024-03-06T10:07:40.493Z zigbee-herdsman:controller:endpoint Bind 0xa4c1381753519a62/1 genPowerCfg from '0x00124b002a2e8f19/1' failed (AREQ - ZDO - bindRsp after 10000ms)
Zigbee2MQTT:info  2024-03-06 11:07:40: Successfully configured 'Window Lounge'
lee-costa commented 5 months ago

Any update on this? I also have a couple devices that refuse to update. I wasted a few batteries before realizing it simply wasn't updating.

krair commented 3 months ago

Still an issue:

[2024-06-13 10:07:28] info:     z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Window-Kitchen', payload '{"battery":1,"battery_low":false,"contact":false,"last_seen":"2024-06-13T09:05:59+02:00","linkquality":167,"tamper":false,"voltage":2500}'

I tried following the guide here to see if I could at least see other data, but on creating the new external converter, it appears to use the new external converter on "receive", but then the old definitions when publishing to MQTT:

[2024-06-13 11:41:18] debug:    z2m:mqtt: Received MQTT message on 'homeassistant/sensor/0xa4c138013eb8652f/linkquality/config' with data '{"availability":[{"topic":"zigbee2mqtt/bridge/state","value_template":"{{ value_json.state }}"},{"topic":"zigbee2mqtt/Window-Kitchen/availability","value_template":"{{ value_json.state }}"}],"availability_mode":"all","device":{"identifiers":["zigbee2mqtt_0xa4c138013eb8652f"],"manufacturer":"Tuya","model":"Tuya Door/Window sensor (TS0203_new)","name":"Window-Kitchen","via_device":"zigbee2mqtt_bridge_0x00124b002a2e8f19"},"enabled_by_default":false,"entity_category":"diagnostic","icon":"mdi:signal","name":"Linkquality","object_id":"window-kitchen_linkquality","origin":{"name":"Zigbee2MQTT","sw":"1.38.0","url":"https://www.zigbee2mqtt.io"},"state_class":"measurement","state_topic":"zigbee2mqtt/Window-Kitchen","unique_id":"0xa4c138013eb8652f_linkquality_zigbee2mqtt","unit_of_measurement":"lqi","value_template":"{{ value_json.linkquality }}"}'
[2024-06-13 11:41:18] debug:    z2m:mqtt: Received MQTT message on 'homeassistant/sensor/0xa4c138013eb8652f/last_seen/config' with data '{"availability":[{"topic":"zigbee2mqtt/bridge/state","value_template":"{{ value_json.state }}"},{"topic":"zigbee2mqtt/Window-Kitchen/availability","value_template":"{{ value_json.state }}"}],"availability_mode":"all","device":{"identifiers":["zigbee2mqtt_0xa4c138013eb8652f"],"manufacturer":"Tuya","model":"Tuya Door/Window sensor (TS0203_new)","name":"Window-Kitchen","via_device":"zigbee2mqtt_bridge_0x00124b002a2e8f19"},"device_class":"timestamp","enabled_by_default":true,"entity_category":"diagnostic","icon":"mdi:clock","name":"Last seen","object_id":"window-kitchen_last_seen","origin":{"name":"Zigbee2MQTT","sw":"1.38.0","url":"https://www.zigbee2mqtt.io"},"state_topic":"zigbee2mqtt/Window-Kitchen","unique_id":"0xa4c138013eb8652f_last_seen_zigbee2mqtt","value_template":"{{ value_json.last_seen }}"}'
[2024-06-13 11:41:23] info:     z2m:mqtt: MQTT publish: topic 'homeassistant/binary_sensor/0xa4c138013eb8652f/contact/config', payload '{"availability":[{"topic":"zigbee2mqtt/bridge/state","value_template":"{{ value_json.state }}"},{"topic":"zigbee2mqtt/Window-Kitchen/availability","value_template":"{{ value_json.state }}"}],"availability_mode":"all","device":{"identifiers":["zigbee2mqtt_0xa4c138013eb8652f"],"manufacturer":"TuYa","model":"Door sensor (TS0203)","name":"Window-Kitchen","via_device":"zigbee2mqtt_bridge_0x00124b002a2e8f19"},"device_class":"door","object_id":"window-kitchen_contact","origin":{"name":"Zigbee2MQTT","sw":"1.38.0","url":"https://www.zigbee2mqtt.io"},"payload_off":true,"payload_on":false,"state_topic":"zigbee2mqtt/Window-Kitchen","unique_id":"0xa4c138013eb8652f_contact_zigbee2mqtt","value_template":"{{ value_json.contact }}"}'
[2024-06-13 11:41:23] info:     z2m:mqtt: MQTT publish: topic 'homeassistant/binary_sensor/0xa4c138013eb8652f/battery_low/config', payload '{"availability":[{"topic":"zigbee2mqtt/bridge/state","value_template":"{{ value_json.state }}"},{"topic":"zigbee2mqtt/Window-Kitchen/availability","value_template":"{{ value_json.state }}"}],"availability_mode":"all","device":{"identifiers":["zigbee2mqtt_0xa4c138013eb8652f"],"manufacturer":"TuYa","model":"Door sensor (TS0203)","name":"Window-Kitchen","via_device":"zigbee2mqtt_bridge_0x00124b002a2e8f19"},"device_class":"battery","entity_category":"diagnostic","object_id":"window-kitchen_battery_low","origin":{"name":"Zigbee2MQTT","sw":"1.38.0","url":"https://www.zigbee2mqtt.io"},"payload_off":false,"payload_on":true,"state_topic":"zigbee2mqtt/Window-Kitchen","unique_id":"0xa4c138013eb8652f_battery_low_zigbee2mqtt","value_template":"{{ value_json.battery_low }}"}'
[2024-06-13 11:41:23] info:     z2m:mqtt: MQTT publish: topic 'homeassistant/sensor/0xa4c138013eb8652f/battery/config', payload '{"availability":[{"topic":"zigbee2mqtt/bridge/state","value_template":"{{ value_json.state }}"},{"topic":"zigbee2mqtt/Window-Kitchen/availability","value_template":"{{ value_json.state }}"}],"availability_mode":"all","device":{"identifiers":["zigbee2mqtt_0xa4c138013eb8652f"],"manufacturer":"TuYa","model":"Door sensor (TS0203)","name":"Window-Kitchen","via_device":"zigbee2mqtt_bridge_0x00124b002a2e8f19"},"device_class":"battery","enabled_by_default":true,"entity_category":"diagnostic","object_id":"window-kitchen_battery","origin":{"name":"Zigbee2MQTT","sw":"1.38.0","url":"https://www.zigbee2mqtt.io"},"state_class":"measurement","state_topic":"zigbee2mqtt/Window-Kitchen","unique_id":"0xa4c138013eb8652f_battery_zigbee2mqtt","unit_of_measurement":"%","value_template":"{{ value_json.battery }}"}'
[2024-06-13 11:41:23] info:     z2m:mqtt: MQTT publish: topic 'homeassistant/sensor/0xa4c138013eb8652f/voltage/config', payload '{"availability":[{"topic":"zigbee2mqtt/bridge/state","value_template":"{{ value_json.state }}"},{"topic":"zigbee2mqtt/Window-Kitchen/availability","value_template":"{{ value_json.state }}"}],"availability_mode":"all","device":{"identifiers":["zigbee2mqtt_0xa4c138013eb8652f"],"manufacturer":"TuYa","model":"Door sensor (TS0203)","name":"Window-Kitchen","via_device":"zigbee2mqtt_bridge_0x00124b002a2e8f19"},"device_class":"voltage","enabled_by_default":false,"entity_category":"diagnostic","object_id":"window-kitchen_voltage","origin":{"name":"Zigbee2MQTT","sw":"1.38.0","url":"https://www.zigbee2mqtt.io"},"state_class":"measurement","state_topic":"zigbee2mqtt/Window-Kitchen","unique_id":"0xa4c138013eb8652f_voltage_zigbee2mqtt","unit_of_measurement":"mV","value_template":"{{ value_json.voltage }}"}'
[2024-06-13 11:41:23] info:     z2m:mqtt: MQTT publish: topic 'homeassistant/binary_sensor/0xa4c138013eb8652f/tamper/config', payload '{"availability":[{"topic":"zigbee2mqtt/bridge/state","value_template":"{{ value_json.state }}"},{"topic":"zigbee2mqtt/Window-Kitchen/availability","value_template":"{{ value_json.state }}"}],"availability_mode":"all","device":{"identifiers":["zigbee2mqtt_0xa4c138013eb8652f"],"manufacturer":"TuYa","model":"Door sensor (TS0203)","name":"Window-Kitchen","via_device":"zigbee2mqtt_bridge_0x00124b002a2e8f19"},"device_class":"tamper","object_id":"window-kitchen_tamper","origin":{"name":"Zigbee2MQTT","sw":"1.38.0","url":"https://www.zigbee2mqtt.io"},"payload_off":false,"payload_on":true,"state_topic":"zigbee2mqtt/Window-Kitchen","unique_id":"0xa4c138013eb8652f_tamper_zigbee2mqtt","value_template":"{{ value_json.tamper }}"}'
[2024-06-13 11:41:23] info:     z2m:mqtt: MQTT publish: topic 'homeassistant/sensor/0xa4c138013eb8652f/linkquality/config', payload '{"availability":[{"topic":"zigbee2mqtt/bridge/state","value_template":"{{ value_json.state }}"},{"topic":"zigbee2mqtt/Window-Kitchen/availability","value_template":"{{ value_json.state }}"}],"availability_mode":"all","device":{"identifiers":["zigbee2mqtt_0xa4c138013eb8652f"],"manufacturer":"TuYa","model":"Door sensor (TS0203)","name":"Window-Kitchen","via_device":"zigbee2mqtt_bridge_0x00124b002a2e8f19"},"enabled_by_default":false,"entity_category":"diagnostic","icon":"mdi:signal","name":"Linkquality","object_id":"window-kitchen_linkquality","origin":{"name":"Zigbee2MQTT","sw":"1.38.0","url":"https://www.zigbee2mqtt.io"},"state_class":"measurement","state_topic":"zigbee2mqtt/Window-Kitchen","unique_id":"0xa4c138013eb8652f_linkquality_zigbee2mqtt","unit_of_measurement":"lqi","value_template":"{{ value_json.linkquality }}"}'
[2024-06-13 11:41:23] info:     z2m:mqtt: MQTT publish: topic 'homeassistant/sensor/0xa4c138013eb8652f/last_seen/config', payload '{"availability":[{"topic":"zigbee2mqtt/bridge/state","value_template":"{{ value_json.state }}"},{"topic":"zigbee2mqtt/Window-Kitchen/availability","value_template":"{{ value_json.state }}"}],"availability_mode":"all","device":{"identifiers":["zigbee2mqtt_0xa4c138013eb8652f"],"manufacturer":"TuYa","model":"Door sensor (TS0203)","name":"Window-Kitchen","via_device":"zigbee2mqtt_bridge_0x00124b002a2e8f19"},"device_class":"timestamp","enabled_by_default":true,"entity_category":"diagnostic","icon":"mdi:clock","name":"Last seen","object_id":"window-kitchen_last_seen","origin":{"name":"Zigbee2MQTT","sw":"1.38.0","url":"https://www.zigbee2mqtt.io"},"state_topic":"zigbee2mqtt/Window-Kitchen","unique_id":"0xa4c138013eb8652f_last_seen_zigbee2mqtt","value_template":"{{ value_json.last_seen }}"}'

If I check the dev console to read the battery percentage, I get:

[2024-06-13 11:47:22] error:    z2m: Publish 'set' 'read' to 'Window-Kitchen' failed: 'Error: ZCL command 0xa4c138013eb8652f/1 genPowerCfg.read(["batteryPercentageRemaining"], {"timeout":10000,"disableResponse":false,"disableRecovery":false,"disableDefaultResponse":true,"direction":0,"srcEndpoint":null,"reservedBits":0,"manufacturerCode":null,"transactionSequenceNumber":null,"writeUndiv":false}) failed (Timeout - 38875 - 1 - 19 - 1 - 1 after 10000ms)'

Am I missing something? Is there another way I could debug this to dig into why we aren't seeing the battery endpoint update anymore?

java-devil commented 3 months ago

For whatever it's worth (spoiler: not much) I seem to have the same issue.

Possibly noteworthy: my window sensors seemed to permanently expose the battery levels that were true as of the moment of initial pairing... and simply never refreshed said values.

After bumping into this issue I decided to attempt short-pressing the power button and... lo and behold - "manually" refreshed battery levels (I will report back if they revert to their previous "corrupted" values as they did for @Ev15).

So it appears there is a mechanism through which Z2M is able to infer this information. However contrary to the documantation - it does so only during "power up", and not recurrently.

java-devil commented 2 months ago

image

So as you can see - it's relatively safe to assume that:

Soukyuu commented 1 month ago

I'm having the same issue, but I'm pretty sure it's not initially working as @java-devil is describing it. On the first battery the TS0203 sensor came with, the battery level properly declined until it reached 1%. After that, only short pressing the reset button will update the level.

Soukyuu commented 1 month ago

I just noticed that some of my TS0203 window contacts have a different zigbee manufacturer.

Those that update the battery level fine are _TZ3000_oxslv1c9 Those that do not update the battery level after initial battery runs out are _TZ3000_26fmupbb

PaulHam211 commented 1 month ago

I just noticed that some of my TS0203 window contacts have a different zigbee manufacturer.

Those that update the battery level fine are _TZ3000_oxslv1c9 Those that do not update the battery level after initial battery runs out are _TZ3000_26fmupbb

I have one with manufacturer _TZ3000_oxslv1c9 with the 1% battery issue

image
Ev15 commented 1 month ago

After the latest update (1.39.1), most sensors indicate either 100, 87 or 22 percent. All my sensors are of this type: TZ3000_oxslv1c9. For example, I have 3 sensors that indicate 87 percent but I am sure the battery level is different.

java-devil commented 4 weeks ago
Screenshot 2024-08-16 at 17 17 42

Potential lead.

As you can see while trying to query the batteryPercentageRemaining attribute in the "reporting" tab I recieve a timeout that as far as I am able to tell is indicative of Z2M not being possible to query the device as long as it is in sleep mode. And since the device is a Zigbee battery powered window sensor it is pretty much always in sleep mode unless you are opening or closing the window.

However now short-pressing the "RESET" button doesn't help either :P I assume due to some recent Z2M version bump.

Now if we could only somehow query the batteryPercentageRemaining attribute whenever the door/window opens/closes... Any ideas anyone?

My sensor is of type: _TZ3000_6zvw8ham

hardwareadictos commented 3 weeks ago

Same issue here, battery percentages not updating rear replacing batteries.