diff --git a/homeassistant/components/light/decora.py b/homeassistant/components/light/decora.py index bc45870f5f2..17cc741c593 100644 --- a/homeassistant/components/light/decora.py +++ b/homeassistant/components/light/decora.py @@ -16,7 +16,7 @@ from homeassistant.components.light import ( PLATFORM_SCHEMA) import homeassistant.helpers.config_validation as cv -REQUIREMENTS = ['decora==0.6'] +REQUIREMENTS = ['decora==0.6', 'bluepy==1.1.1'] _LOGGER = logging.getLogger(__name__) @@ -39,6 +39,7 @@ def retry(method): """Try send command and retry on error.""" # pylint: disable=import-error import decora + import bluepy initial = time.monotonic() while True: @@ -46,7 +47,10 @@ def retry(method): return None try: return method(device, *args, **kwds) - except (decora.decoraException, AttributeError): + except (decora.decoraException, AttributeError, + bluepy.btle.BTLEException): + _LOGGER.warning("Decora connect error for device %s. " + "Reconnecting...", device.name) # pylint: disable=protected-access device._switch.connect() return wrapper_retry @@ -119,7 +123,7 @@ class DecoraLight(Light): @retry def set_state(self, brightness): """Set the state of this lamp to the provided brightness.""" - self._switch.set_brightness(brightness / 2.55) + self._switch.set_brightness(int(brightness / 2.55)) self._brightness = brightness @retry diff --git a/requirements_all.txt b/requirements_all.txt index 0eccc3c0aa2..c11959387b1 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -106,6 +106,9 @@ blinkstick==1.1.8 # homeassistant.components.sensor.bitcoin blockchain==1.3.3 +# homeassistant.components.light.decora +# bluepy==1.1.1 + # homeassistant.components.notify.aws_lambda # homeassistant.components.notify.aws_sns # homeassistant.components.notify.aws_sqs