Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix_light_level_math #416

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sparkym3
Copy link

Since the brightness in home assistant entity is stored as an integer and matter passes the value as an integer, but with slightly different max, we must round it to the closest value when converting.

This causes incorrect values in consumer solutions such as the below.

  1. 10% = Matter 25 = converted 25.098425196850396 = homeassistant 25 = converted back 24.901960784313725 = Matter 24 = 9%
  2. 90% = Matter 229 = converted 229.9015748031496 = homeassistant 229 = converted back 228.101960784313725 = Matter 228 = 89%

Since the brightness in home assistant entity is stored as an integer and matter passes the value as an integer, but with slightly different max, we must round it to the closest value when converting.
@sparkym3
Copy link
Author

I didn't look into the hue and saturation conversions, but I have a feeling they may have the same issue since they do similar math without the rounding

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