mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Report availability for TP-Link smart bulbs (#10976)
This commit is contained in:
parent
c7e327ea87
commit
aeba81e193
@ -72,6 +72,7 @@ class TPLinkSmartBulb(Light):
|
|||||||
if name is not None:
|
if name is not None:
|
||||||
self._name = name
|
self._name = name
|
||||||
self._state = None
|
self._state = None
|
||||||
|
self._available = True
|
||||||
self._color_temp = None
|
self._color_temp = None
|
||||||
self._brightness = None
|
self._brightness = None
|
||||||
self._rgb = None
|
self._rgb = None
|
||||||
@ -83,6 +84,11 @@ class TPLinkSmartBulb(Light):
|
|||||||
"""Return the name of the Smart Bulb, if any."""
|
"""Return the name of the Smart Bulb, if any."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def available(self) -> bool:
|
||||||
|
"""Return if bulb is available."""
|
||||||
|
return self._available
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
"""Return the state attributes of the device."""
|
"""Return the state attributes of the device."""
|
||||||
@ -132,6 +138,7 @@ class TPLinkSmartBulb(Light):
|
|||||||
"""Update the TP-Link Bulb's state."""
|
"""Update the TP-Link Bulb's state."""
|
||||||
from pyHS100 import SmartDeviceException
|
from pyHS100 import SmartDeviceException
|
||||||
try:
|
try:
|
||||||
|
self._available = True
|
||||||
if self._supported_features == 0:
|
if self._supported_features == 0:
|
||||||
self.get_features()
|
self.get_features()
|
||||||
self._state = (
|
self._state = (
|
||||||
@ -163,8 +170,10 @@ class TPLinkSmartBulb(Light):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
# device returned no daily/monthly history
|
# device returned no daily/monthly history
|
||||||
pass
|
pass
|
||||||
|
|
||||||
except (SmartDeviceException, OSError) as ex:
|
except (SmartDeviceException, OSError) as ex:
|
||||||
_LOGGER.warning('Could not read state for %s: %s', self._name, ex)
|
_LOGGER.warning("Could not read state for %s: %s", self._name, ex)
|
||||||
|
self._available = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self):
|
def supported_features(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user