Skip to content

Round reported Zigbee brightness percentage#48

Open
georgemclaughlin wants to merge 1 commit into
StuckAtPrototype:masterfrom
georgemclaughlin:fix/zha-brightness-rounding
Open

Round reported Zigbee brightness percentage#48
georgemclaughlin wants to merge 1 commit into
StuckAtPrototype:masterfrom
georgemclaughlin:fix/zha-brightness-rounding

Conversation

@georgemclaughlin
Copy link
Copy Markdown

@georgemclaughlin georgemclaughlin commented May 25, 2026

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_value attribute through Zigpy/Home Assistant. The firmware currently derives that value from:

led_get_intensity() * 100.0f

Because led_get_intensity() is a 0.0f to 1.0f float, values like 0.3f or 0.6f can become 30.0000019 or 60.0000038 when reported as a percentage.

Change

Clamp and round current_brightness_percent() so the firmware reports a clean whole-number percentage from 0 to 100.

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 build

Build completed successfully and generated firmware/build/AirCube.bin.

@georgemclaughlin
Copy link
Copy Markdown
Author

Closing this for now; I opened it prematurely while validating the local fork-side fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant