diff --git a/src/wyzeapy/services/base_service.py b/src/wyzeapy/services/base_service.py index 4068b9c..990b4e4 100644 --- a/src/wyzeapy/services/base_service.py +++ b/src/wyzeapy/services/base_service.py @@ -610,4 +610,6 @@ async def _local_bulb_command(self, bulb, plist): async with session.post(url, data=payload_str) as response: print(await response.text()) except aiohttp.ClientConnectionError: - _LOGGER.warning("Failed to connect to bulb %s" % bulb.mac) + _LOGGER.warning("Failed to connect to bulb %s, reverting to cloud." % bulb.mac) + await self._run_action_list(bulb, plist) + bulb.cloud_fallback = True diff --git a/src/wyzeapy/services/bulb_service.py b/src/wyzeapy/services/bulb_service.py index 8327642..587ed14 100644 --- a/src/wyzeapy/services/bulb_service.py +++ b/src/wyzeapy/services/bulb_service.py @@ -21,6 +21,7 @@ class Bulb(Device): enr: str on: bool = False + cloud_fallback = False def __init__(self, dictionary: Dict[Any, Any]): super().__init__(dictionary) @@ -119,7 +120,10 @@ async def turn_on(self, bulb: Bulb, options=None): elif ( bulb.type in [DeviceTypes.MESH_LIGHT, DeviceTypes.LIGHTSTRIP] ): - await self._local_bulb_command(bulb, plist) + if not bulb.cloud_fallback: + await self._local_bulb_command(bulb, plist) + else: + await self._run_action_list(bulb, plist) async def turn_off(self, bulb: Bulb): plist = [ @@ -133,7 +137,10 @@ async def turn_off(self, bulb: Bulb): elif ( bulb.type in [DeviceTypes.MESH_LIGHT, DeviceTypes.LIGHTSTRIP] ): - await self._local_bulb_command(bulb, plist) + if not bulb.cloud_fallback: + await self._local_bulb_command(bulb, plist) + else: + await self._run_action_list(bulb, plist) async def set_color_temp(self, bulb: Bulb, color_temp: int): plist = [