zigpy / zha-device-handlers

ZHA device handlers bridge the functionality gap created when manufacturers deviate from the ZCL specification, handling deviations and exceptions by parsing custom messages to and from Zigbee devices.
Apache License 2.0
737 stars 675 forks source link

[BUG] IKEA TRADFRI SHORTCUT Button - Battery Level wrong state #2722

Closed mouz124 closed 8 months ago

mouz124 commented 11 months ago

Bug description

Since update to Firmware 0x24040006, the battery status has been reported incorrectly. In my case this only happens with one of the two buttons. I have already deleted and reset the device, reconnected it, power on/off, replaced the battery but nothing helped.

Another user reports the same problem here

Steps to reproduce

Firmware update OTA was carried out

Expected behavior

Actually the battery status should be at 100%, the measured voltage (2.9V) is correct but the scaling doesn't seem to fit.

Screenshots/Video

Screenshots/Video ![image](https://github.com/zigpy/zha-device-handlers/assets/70135357/b050f10c-ad19-47fc-9bfc-fb68e77bfbd9) ![image](https://github.com/zigpy/zha-device-handlers/assets/70135357/411b3751-6fc5-4b74-a59f-d7d099f79683)

Device signature

Device signature ```json { "node_descriptor": "NodeDescriptor(logical_type=, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=, mac_capability_flags=, manufacturer_code=4476, maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264, maximum_outgoing_transfer_size=82, descriptor_capability_field=, *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=True, *is_full_function_device=False, *is_mains_powered=False, *is_receiver_on_when_idle=False, *is_router=False, *is_security_capable=False)", "endpoints": { "1": { "profile_id": "0x0104", "device_type": "0x0820", "input_clusters": [ "0x0000", "0x0001", "0x0003", "0x0009", "0x0020", "0x1000" ], "output_clusters": [ "0x0003", "0x0004", "0x0006", "0x0008", "0x0019", "0x1000" ] } }, "manufacturer": "IKEA of Sweden", "model": "TRADFRI SHORTCUT Button", "class": "zhaquirks.ikea.shortcutbtn.IkeaTradfriShortcutBtn2" } ```

Diagnostic information

Diagnostic information ```json { "home_assistant": { "installation_type": "Home Assistant OS", "version": "2023.11.1", "dev": false, "hassio": true, "virtualenv": false, "python_version": "3.11.6", "docker": true, "arch": "aarch64", "timezone": "Europe/Berlin", "os_name": "Linux", "os_version": "6.1.21-v8", "supervisor": "2023.10.1", "host_os": "Home Assistant OS 11.1", "docker_version": "24.0.6", "chassis": "embedded", "run_as_root": true }, "custom_components": { "better_thermostat": { "version": "1.4.0", "requirements": [] }, "browser_mod": { "version": "2.3.0", "requirements": [] }, "climate_group": { "version": "0.4.2", "requirements": [] }, "hacs": { "version": "1.33.0", "requirements": [ "aiogithubapi>=22.10.1" ] } }, "integration_manifest": { "domain": "zha", "name": "Zigbee Home Automation", "after_dependencies": [ "onboarding", "usb" ], "codeowners": [ "@dmulcahey", "@adminiuga", "@puddly" ], "config_flow": true, "dependencies": [ "file_upload" ], "documentation": "https://www.home-assistant.io/integrations/zha", "iot_class": "local_polling", "loggers": [ "aiosqlite", "bellows", "crccheck", "pure_pcapy3", "zhaquirks", "zigpy", "zigpy_deconz", "zigpy_xbee", "zigpy_zigate", "zigpy_znp", "universal_silabs_flasher" ], "requirements": [ "bellows==0.36.8", "pyserial==3.5", "pyserial-asyncio==0.6", "zha-quirks==0.0.106", "zigpy-deconz==0.21.1", "zigpy==0.59.0", "zigpy-xbee==0.19.0", "zigpy-zigate==0.11.0", "zigpy-znp==0.11.6", "universal-silabs-flasher==0.0.14", "pyserial-asyncio-fast==0.11" ], "usb": [ { "vid": "10C4", "pid": "EA60", "description": "*2652*", "known_devices": [ "slae.sh cc2652rb stick" ] }, { "vid": "1A86", "pid": "55D4", "description": "*sonoff*plus*", "known_devices": [ "sonoff zigbee dongle plus v2" ] }, { "vid": "10C4", "pid": "EA60", "description": "*sonoff*plus*", "known_devices": [ "sonoff zigbee dongle plus" ] }, { "vid": "10C4", "pid": "EA60", "description": "*tubeszb*", "known_devices": [ "TubesZB Coordinator" ] }, { "vid": "1A86", "pid": "7523", "description": "*tubeszb*", "known_devices": [ "TubesZB Coordinator" ] }, { "vid": "1A86", "pid": "7523", "description": "*zigstar*", "known_devices": [ "ZigStar Coordinators" ] }, { "vid": "1CF1", "pid": "0030", "description": "*conbee*", "known_devices": [ "Conbee II" ] }, { "vid": "10C4", "pid": "8A2A", "description": "*zigbee*", "known_devices": [ "Nortek HUSBZB-1" ] }, { "vid": "0403", "pid": "6015", "description": "*zigate*", "known_devices": [ "ZiGate+" ] }, { "vid": "10C4", "pid": "EA60", "description": "*zigate*", "known_devices": [ "ZiGate" ] }, { "vid": "10C4", "pid": "8B34", "description": "*bv 2010/10*", "known_devices": [ "Bitron Video AV2010/10" ] } ], "zeroconf": [ { "type": "_esphomelib._tcp.local.", "name": "tube*" }, { "type": "_zigate-zigbee-gateway._tcp.local.", "name": "*zigate*" }, { "type": "_zigstar_gw._tcp.local.", "name": "*zigstar*" }, { "type": "_uzg-01._tcp.local.", "name": "uzg-01*" }, { "type": "_slzb-06._tcp.local.", "name": "slzb-06*" } ], "is_built_in": true }, "data": { "ieee": "**REDACTED**", "nwk": 32839, "manufacturer": "IKEA of Sweden", "model": "TRADFRI SHORTCUT Button", "name": "IKEA of Sweden TRADFRI SHORTCUT Button", "quirk_applied": true, "quirk_class": "zhaquirks.ikea.shortcutbtn.IkeaTradfriShortcutBtn2", "quirk_id": null, "manufacturer_code": 4476, "power_source": "Battery or Unknown", "lqi": 207, "rssi": -68, "last_seen": "2023-11-07T07:18:55", "available": true, "device_type": "EndDevice", "signature": { "node_descriptor": "NodeDescriptor(logical_type=, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=, mac_capability_flags=, manufacturer_code=4476, maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264, maximum_outgoing_transfer_size=82, descriptor_capability_field=, *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=True, *is_full_function_device=False, *is_mains_powered=False, *is_receiver_on_when_idle=False, *is_router=False, *is_security_capable=False)", "endpoints": { "1": { "profile_id": "0x0104", "device_type": "0x0820", "input_clusters": [ "0x0000", "0x0001", "0x0003", "0x0009", "0x0020", "0x1000" ], "output_clusters": [ "0x0003", "0x0004", "0x0006", "0x0008", "0x0019", "0x1000" ] } }, "manufacturer": "IKEA of Sweden", "model": "TRADFRI SHORTCUT Button" }, "active_coordinator": false, "entities": [ { "entity_id": "button.smartbutton_buero_identifizieren", "name": "IKEA of Sweden TRADFRI SHORTCUT Button" }, { "entity_id": "sensor.smartbutton_buero_batterie", "name": "IKEA of Sweden TRADFRI SHORTCUT Button" } ], "neighbors": [], "routes": [], "endpoint_names": [ { "name": "NON_COLOR_CONTROLLER" } ], "user_given_name": "smartbutton_buero", "device_reg_id": "727d7bca52f104723a8e10d8ae5b7142", "area_id": "buro", "cluster_details": { "1": { "device_type": { "name": "NON_COLOR_CONTROLLER", "id": 2080 }, "profile_id": 260, "in_clusters": { "0x0000": { "endpoint_attribute": "basic", "attributes": { "0x0004": { "attribute_name": "manufacturer", "value": "IKEA of Sweden" }, "0x0005": { "attribute_name": "model", "value": "TRADFRI SHORTCUT Button" } }, "unsupported_attributes": {} }, "0x0001": { "endpoint_attribute": "power", "attributes": { "0x0021": { "attribute_name": "battery_percentage_remaining", "value": 360 }, "0x0033": { "attribute_name": "battery_quantity", "value": 1 }, "0x0034": { "attribute_name": "battery_rated_voltage", "value": 30 }, "0x0031": { "attribute_name": "battery_size", "value": 10 }, "0x0020": { "attribute_name": "battery_voltage", "value": 29 } }, "unsupported_attributes": {} }, "0x0003": { "endpoint_attribute": "identify", "attributes": {}, "unsupported_attributes": {} }, "0x0009": { "endpoint_attribute": "alarms", "attributes": {}, "unsupported_attributes": {} }, "0x0020": { "endpoint_attribute": "poll_control", "attributes": { "0x0000": { "attribute_name": "checkin_interval", "value": 13200 } }, "unsupported_attributes": {} }, "0x1000": { "endpoint_attribute": "lightlink", "attributes": {}, "unsupported_attributes": {} } }, "out_clusters": { "0x0003": { "endpoint_attribute": "identify", "attributes": {}, "unsupported_attributes": {} }, "0x0004": { "endpoint_attribute": "groups", "attributes": {}, "unsupported_attributes": {} }, "0x0006": { "endpoint_attribute": "on_off", "attributes": {}, "unsupported_attributes": {} }, "0x0008": { "endpoint_attribute": "level", "attributes": {}, "unsupported_attributes": {} }, "0x0019": { "endpoint_attribute": "ota", "attributes": {}, "unsupported_attributes": {} }, "0x1000": { "endpoint_attribute": "lightlink", "attributes": {}, "unsupported_attributes": {} } } } } } } ```

Logs

Logs ```python [Paste the logs here] ```

Additional information

No response

Mayhem-SWE commented 11 months ago

Also happens with the Trådfri two button remote/dimmer that has the same form factor as the shortcut button.

kitkat270 commented 11 months ago

Same issue, not impacting all buttons though even though they are identical. Screenshot 2023-11-10 163833

stevegroom commented 11 months ago

Also affects Tredansen blinds.

image
MattWestb commented 11 months ago

You need deleting the blinds and waiting one minute or restart HA and adding it new and the as new so the undated signature i OK and the old quirk is not loading then all is being OK.

soonic6 commented 9 months ago

You need deleting the blinds and waiting one minute or restart HA and adding it new and the as new so the undated signature i OK and the old quirk is not loading then all is being OK.

that worked für my Stybar, but not for TRADFRI on/off switch.

any news about this?

mhl66 commented 9 months ago

Did not work for STYRBAR, and worse: no more group bindings with STYRBAR! EDIT: IKEA Motion sensor, too (currently: 160 percent battery power...)!

mhl66 commented 9 months ago

You need deleting the blinds and waiting one minute or restart HA and adding it new and the as new so the undated signature i OK and the old quirk is not loading then all is being OK.

"restart HA" did not improve anything at all in my year-long experience. ZHA did never work satisfactorily (the green check mark over the "BIND" button did not mean anything at all). Group bindings stopped and started working at random over the years with TRADFRI and STYRBAR switches (see above). Hope that gets resolved soon...

TheJulianJES commented 9 months ago

Related/same issues:

Comment on why this is still an issue: https://github.com/zigpy/zha-device-handlers/pull/2773#issuecomment-1826892883

To summarize, older devices require the percentage duplication, but newer ones don't. We can't match per firmware version though. An idea/workaround would be to re-scale the battery voltage to a percentage, as it's consistent across versions. We should ideally "emulate" the device behavior perfectly, so we'd need to find out if it's a linear function that's used to map from voltage to percentage and if it's the same for all/most devices (if we want to use this approach).

logan893 commented 8 months ago

I'm having the same doubling of battery percentage for 4/4 "TRADFRI on/off switch" after firmware upgrade.

Firmware: 0x24040006 Quirk: zhaquirks.ikea.twobtnremote.IkeaTradfriRemote2Btn

battery voltage 30 reads as 200% battery voltage 29 reads as 180% battery voltage 26 reads as 28%

TheJulianJES commented 8 months ago

This issue should be fixed in HA Core 2024.2.0 (currently in beta). Relevant PR:

If you still see new "double battery percentage" reports, wait a day. You can also try to press a button on the device or manually read the sw_build_id attriubte. Re-pairing/reconfiguring should also work.

If it's not fixed for you, please create a new issue and provide a new diagnostics file.