From 89b69cc6a11b6a655ebb1b01e9d379e07bd6c1c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?So=CC=88ren=20Mu=CC=88ller?= Date: Tue, 4 Jun 2019 21:25:18 +0200 Subject: [PATCH] raise PlatformNotReady if communication with bulb failes --- homeassistant/components/avea/light.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/avea/light.py b/homeassistant/components/avea/light.py index 761a502d0f6..a3e36ede225 100644 --- a/homeassistant/components/avea/light.py +++ b/homeassistant/components/avea/light.py @@ -17,6 +17,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None): import avea nearbyBulbs = avea.discover_avea_bulbs() + try: + for bulb in nearbyBulbs: + bulb.get_name() + except: + raise PlatformNotReady add_devices(AveaLight(bulb) for bulb in nearbyBulbs) @@ -27,12 +32,9 @@ class AveaLight(Light): def __init__(self, light): """Initialize an AveaLight.""" self._light = light - self._name = light.get_name() - if int(light.get_brightness()) == 0: - self._state = False - else: - self._state = True - self._brightness = round(255 * (light.get_brightness() / 100)) + self._name = light.name + self._state = None + self._brightness = None @property def supported_features(self):