mirror of
https://github.com/home-assistant/core.git
synced 2025-08-03 20:55:10 +02:00
raise PlatformNotReady if communication with bulb failes
This commit is contained in:
@@ -17,6 +17,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
import avea
|
import avea
|
||||||
|
|
||||||
nearbyBulbs = avea.discover_avea_bulbs()
|
nearbyBulbs = avea.discover_avea_bulbs()
|
||||||
|
try:
|
||||||
|
for bulb in nearbyBulbs:
|
||||||
|
bulb.get_name()
|
||||||
|
except:
|
||||||
|
raise PlatformNotReady
|
||||||
|
|
||||||
add_devices(AveaLight(bulb) for bulb in nearbyBulbs)
|
add_devices(AveaLight(bulb) for bulb in nearbyBulbs)
|
||||||
|
|
||||||
@@ -27,12 +32,9 @@ class AveaLight(Light):
|
|||||||
def __init__(self, light):
|
def __init__(self, light):
|
||||||
"""Initialize an AveaLight."""
|
"""Initialize an AveaLight."""
|
||||||
self._light = light
|
self._light = light
|
||||||
self._name = light.get_name()
|
self._name = light.name
|
||||||
if int(light.get_brightness()) == 0:
|
self._state = None
|
||||||
self._state = False
|
self._brightness = None
|
||||||
else:
|
|
||||||
self._state = True
|
|
||||||
self._brightness = round(255 * (light.get_brightness() / 100))
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self):
|
def supported_features(self):
|
||||||
|
Reference in New Issue
Block a user