Report availability for TP-Link smart bulbs (#10976)
This commit is contained in:
parent
c7e327ea87
commit
aeba81e193
1 changed files with 10 additions and 1 deletions
|
@ -72,6 +72,7 @@ class TPLinkSmartBulb(Light):
|
|||
if name is not None:
|
||||
self._name = name
|
||||
self._state = None
|
||||
self._available = True
|
||||
self._color_temp = None
|
||||
self._brightness = None
|
||||
self._rgb = None
|
||||
|
@ -83,6 +84,11 @@ class TPLinkSmartBulb(Light):
|
|||
"""Return the name of the Smart Bulb, if any."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
"""Return if bulb is available."""
|
||||
return self._available
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes of the device."""
|
||||
|
@ -132,6 +138,7 @@ class TPLinkSmartBulb(Light):
|
|||
"""Update the TP-Link Bulb's state."""
|
||||
from pyHS100 import SmartDeviceException
|
||||
try:
|
||||
self._available = True
|
||||
if self._supported_features == 0:
|
||||
self.get_features()
|
||||
self._state = (
|
||||
|
@ -163,8 +170,10 @@ class TPLinkSmartBulb(Light):
|
|||
except KeyError:
|
||||
# device returned no daily/monthly history
|
||||
pass
|
||||
|
||||
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
|
||||
def supported_features(self):
|
||||
|
|
Loading…
Add table
Reference in a new issue