Round reported Zigbee brightness percentage#48
Open
georgemclaughlin wants to merge 1 commit into
Open
Conversation
Author
|
Closing this for now; I opened it prematurely while validating the local fork-side fix. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix the ZHA long-decimal brightness value reported in #28 by rounding the firmware-reported Zigbee brightness percentage to a whole number.
Background
#36 fixed related brightness sync behavior and added rounding in the Zigbee2MQTT converters. However, ZHA does not use the Zigbee2MQTT converter, so it does not benefit from that converter-side rounding.
The ZHA quirk exposes the firmware’s Analog Output
present_valueattribute through Zigpy/Home Assistant. The firmware currently derives that value from:Because
led_get_intensity()is a0.0fto1.0ffloat, values like0.3for0.6fcan become30.0000019or60.0000038when reported as a percentage.Change
Clamp and round
current_brightness_percent()so the firmware reports a clean whole-number percentage from0to100.This only changes the value reported over Zigbee. It does not change internal LED intensity behavior or brightness persistence behavior.
Verification
Built locally with ESP-IDF 5.5.3:
cd firmware idf.py set-target esp32h2 buildBuild completed successfully and generated
firmware/build/AirCube.bin.