Skip to content

Xiaomi MiIO Light: Brightness mapping improved#12203

Merged
rytilahti merged 2 commits intohome-assistant:devfrom
syssi:feature/xiaomi-miio-philipslight-brightness-mapping-improved
Feb 6, 2018
Merged

Xiaomi MiIO Light: Brightness mapping improved#12203
rytilahti merged 2 commits intohome-assistant:devfrom
syssi:feature/xiaomi-miio-philipslight-brightness-mapping-improved

Conversation

@syssi
Copy link
Copy Markdown
Member

@syssi syssi commented Feb 5, 2018

Xiaomi Philips Lights accepts a brightness between 1 and 100 percent. HA has a brightness range of [1,255]. In the past the HA brightness 1, 2 and 3 was mapped to 0 percent. The mapping is shifted a bit now to improve the user experience.

if ATTR_BRIGHTNESS in kwargs:
brightness = kwargs[ATTR_BRIGHTNESS]
percent_brightness = int(100 * brightness / 255)
percent_brightness = int(ceil(100 * brightness / 255.0))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need int when you have ceil?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. python3 returns an int. math.ceil of python2.7 returns a float.

@rytilahti
Copy link
Copy Markdown
Member

Looks fine to me, thanks! 👍

@rytilahti rytilahti merged commit cee57aa into home-assistant:dev Feb 6, 2018
@balloob balloob mentioned this pull request Feb 9, 2018
@home-assistant home-assistant locked and limited conversation to collaborators May 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants