python-homely 0.1.3__tar.gz → 0.1.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-homely
3
- Version: 0.1.3
3
+ Version: 0.1.5
4
4
  Summary: Async Python client for the Homely cloud API, built for Home Assistant but usable anywhere.
5
5
  Author: Ludvik Blichfeldt Rød
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "python-homely"
7
- version = "0.1.3"
7
+ version = "0.1.5"
8
8
  description = "Async Python client for the Homely cloud API, built for Home Assistant but usable anywhere."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.12"
@@ -1,6 +1,6 @@
1
1
  """Reusable Homely client package extracted from the integration."""
2
2
 
3
- __version__ = "0.1.3"
3
+ __version__ = "0.1.5"
4
4
 
5
5
  from .client import (
6
6
  BASE_URL,
@@ -98,6 +98,7 @@ class HomelyWebSocket:
98
98
  self.on_data_update = on_data_update
99
99
  self.socket: Any | None = None
100
100
  self._is_closing = False
101
+ self._cleaning_up_socket = False
101
102
  self._reconnect_task: asyncio.Task[None] | None = None
102
103
  self._reconnect_interval = self._reconnect_interval_for_attempt(1)
103
104
  self._reconnect_warn_every = 12
@@ -248,6 +249,8 @@ class HomelyWebSocket:
248
249
  if self._is_closing:
249
250
  self._set_status("Disconnected", "manual disconnect")
250
251
  return
252
+ if self._cleaning_up_socket:
253
+ return
251
254
  self._set_status("Disconnected", reason)
252
255
  if not self._is_closing:
253
256
  self._start_reconnect_loop("disconnect event")
@@ -341,10 +344,13 @@ class HomelyWebSocket:
341
344
  return True
342
345
 
343
346
  if self.socket is not None:
347
+ self._cleaning_up_socket = True
344
348
  try:
345
349
  await asyncio.wait_for(self.socket.disconnect(), timeout=2)
346
350
  except Exception:
347
351
  pass
352
+ finally:
353
+ self._cleaning_up_socket = False
348
354
  self.socket = None
349
355
 
350
356
  self._set_status("Connecting")
@@ -352,7 +358,7 @@ class HomelyWebSocket:
352
358
  self.socket = socketio.AsyncClient(
353
359
  reconnection=False,
354
360
  logger=False,
355
- engineio_logger=False,
361
+ engineio_logger=logging.getLogger("engineio.client"),
356
362
  )
357
363
 
358
364
  async def connect() -> None:
@@ -397,7 +403,7 @@ class HomelyWebSocket:
397
403
  await asyncio.wait_for(
398
404
  self.socket.connect(
399
405
  url,
400
- transports=["websocket", "polling"],
406
+ transports=["polling", "websocket"],
401
407
  headers={"Authorization": bearer_token},
402
408
  ),
403
409
  timeout=10,
@@ -444,7 +450,6 @@ class HomelyWebSocket:
444
450
  self.socket = None
445
451
  finally:
446
452
  self._set_status("Disconnected", "manual disconnect")
447
- self._is_closing = False
448
453
 
449
454
  async def close(self) -> None:
450
455
  """Alias for disconnect, matching common client-library conventions."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-homely
3
- Version: 0.1.3
3
+ Version: 0.1.5
4
4
  Summary: Async Python client for the Homely cloud API, built for Home Assistant but usable anywhere.
5
5
  Author: Ludvik Blichfeldt Rød
6
6
  License-Expression: MIT
File without changes
File without changes
File without changes