Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions homeassistant/components/light/xiaomi_miio.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import asyncio
from functools import partial
import logging
from math import ceil

import voluptuous as vol

Expand Down Expand Up @@ -204,11 +205,11 @@ def async_turn_on(self, **kwargs):
"""Turn the light on."""
if ATTR_BRIGHTNESS in kwargs:
brightness = kwargs[ATTR_BRIGHTNESS]
percent_brightness = int(100 * brightness / 255)
percent_brightness = ceil(100 * brightness / 255.0)

_LOGGER.debug(
"Setting brightness: %s %s%%",
self.brightness, percent_brightness)
brightness, percent_brightness)

result = yield from self._try_command(
"Setting brightness failed: %s",
Expand All @@ -235,7 +236,7 @@ def async_update(self):
_LOGGER.debug("Got new state: %s", state)

self._state = state.is_on
self._brightness = int(255 * 0.01 * state.brightness)
self._brightness = ceil((255/100.0) * state.brightness)

except DeviceException as ex:
_LOGGER.error("Got exception while fetching the state: %s", ex)
Expand Down Expand Up @@ -306,11 +307,11 @@ def async_turn_on(self, **kwargs):

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

_LOGGER.debug(
"Setting brightness: %s %s%%",
self.brightness, percent_brightness)
brightness, percent_brightness)

result = yield from self._try_command(
"Setting brightness failed: %s",
Expand All @@ -331,7 +332,7 @@ def async_update(self):
_LOGGER.debug("Got new state: %s", state)

self._state = state.is_on
self._brightness = int(255 * 0.01 * state.brightness)
self._brightness = ceil((255/100.0) * state.brightness)
self._color_temp = self.translate(
state.color_temperature,
CCT_MIN, CCT_MAX,
Expand Down