Skip to content

Commit

Permalink
Use round() instead of int() (#288)
Browse files Browse the repository at this point in the history
Signed-off-by: Mick Vleeshouwer <[email protected]>
  • Loading branch information
iMicknl authored Oct 5, 2020
1 parent 5528c04 commit dfb8909
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion custom_components/tahoma/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""The TaHoma integration."""
import asyncio
from asyncio import TimeoutError
from collections import defaultdict
from datetime import timedelta
import logging
Expand Down
6 changes: 3 additions & 3 deletions custom_components/tahoma/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self, tahoma_device, controller):
def brightness(self) -> int:
"""Return the brightness of this light between 0..255."""
brightness = self.select_state(CORE_LIGHT_INTENSITY_STATE)
return int(brightness * 255 / 100)
return round(brightness * 255 / 100)

@property
def is_on(self) -> bool:
Expand Down Expand Up @@ -106,13 +106,13 @@ async def async_turn_on(self, **kwargs) -> None:
await self.async_execute_command(
COMMAND_SET_RGB,
*[
int(float(c))
round(float(c))
for c in color_util.color_hs_to_RGB(*kwargs[ATTR_HS_COLOR])
],
)

if ATTR_BRIGHTNESS in kwargs:
brightness = int(float(kwargs[ATTR_BRIGHTNESS]) / 255 * 100)
brightness = round(float(kwargs[ATTR_BRIGHTNESS]) / 255 * 100)
await self.async_execute_command(COMMAND_SET_INTENSITY, brightness)

elif ATTR_EFFECT in kwargs:
Expand Down

0 comments on commit dfb8909

Please sign in to comment.