mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Throttle unavailability warnings for tplink light/switch (#15591)
This commit is contained in:
parent
ae2ee8f006
commit
ef3a83048c
@ -140,8 +140,6 @@ 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()
|
||||||
|
|
||||||
@ -182,9 +180,13 @@ class TPLinkSmartBulb(Light):
|
|||||||
# device returned no daily/monthly history
|
# device returned no daily/monthly history
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
self._available = True
|
||||||
|
|
||||||
except (SmartDeviceException, OSError) as ex:
|
except (SmartDeviceException, OSError) as ex:
|
||||||
_LOGGER.warning("Could not read state for %s: %s", self._name, ex)
|
if self._available:
|
||||||
self._available = False
|
_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):
|
||||||
|
@ -87,8 +87,6 @@ class SmartPlugSwitch(SwitchDevice):
|
|||||||
"""Update the TP-Link switch's state."""
|
"""Update the TP-Link switch's state."""
|
||||||
from pyHS100 import SmartDeviceException
|
from pyHS100 import SmartDeviceException
|
||||||
try:
|
try:
|
||||||
self._available = True
|
|
||||||
|
|
||||||
self._state = self.smartplug.state == \
|
self._state = self.smartplug.state == \
|
||||||
self.smartplug.SWITCH_STATE_ON
|
self.smartplug.SWITCH_STATE_ON
|
||||||
|
|
||||||
@ -121,6 +119,10 @@ class SmartPlugSwitch(SwitchDevice):
|
|||||||
# Device returned no daily history
|
# Device returned no daily history
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
self._available = True
|
||||||
|
|
||||||
except (SmartDeviceException, OSError) as ex:
|
except (SmartDeviceException, OSError) as ex:
|
||||||
_LOGGER.warning("Could not read state for %s: %s", self.name, ex)
|
if self._available:
|
||||||
self._available = False
|
_LOGGER.warning(
|
||||||
|
"Could not read state for %s: %s", self.name, ex)
|
||||||
|
self._available = False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user