Skip to content

Commit

Permalink
fix candela testing no notif
Browse files Browse the repository at this point in the history
  • Loading branch information
hcoohb committed Aug 11, 2022
1 parent 7040115 commit 74ef6de
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions custom_components/yeelight_bt/yeelightbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ async def connect(self, num_tries: int = 3) -> None:
self._read_service = True
await asyncio.sleep(0.2)

_LOGGER.debug("Request Notify")
if self._model == MODEL_BEDSIDE:
_LOGGER.debug("Request Notify")
await self._client.start_notify(NOTIFY_UUID, self.notification_handler)
await asyncio.sleep(0.3)
_LOGGER.debug("Request Pairing")
Expand All @@ -185,7 +185,7 @@ async def connect(self, num_tries: int = 3) -> None:
if self._model == MODEL_CANDELA:
# let's assume we are connected without actual pairing:
# maybe we can still control on the candela?
self._conn == Conn.PAIRED
self._conn = Conn.PAIRED

_LOGGER.debug(f"Connection status: {self._conn}")

Expand Down Expand Up @@ -265,7 +265,8 @@ async def send_cmd(self, bits: bytes, wait_notif: float = 0.5) -> bool:
if self._conn == Conn.PAIRED and self._client is not None:
try:
await self._client.write_gatt_char(CONTROL_UUID, bytearray(bits))
await asyncio.sleep(wait_notif)
if self._model != MODEL_CANDELA:
await asyncio.sleep(wait_notif)
return True
except asyncio.TimeoutError:
_LOGGER.error("Send Cmd: Timeout error")
Expand All @@ -275,6 +276,8 @@ async def send_cmd(self, bits: bytes, wait_notif: float = 0.5) -> bool:

async def get_state(self) -> None:
"""Request the state of the lamp (send back state through notif)"""
if self._model == MODEL_CANDELA:
return
bits = struct.pack("BBB15x", COMMAND_STX, CMD_GETSTATE, CMD_GETSTATE_SEC)
_LOGGER.debug("Send Cmd: Get_state")
await self.send_cmd(bits)
Expand Down

0 comments on commit 74ef6de

Please sign in to comment.