python-homely 0.1.4__tar.gz → 0.1.6__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.4
3
+ Version: 0.1.6
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.4"
7
+ version = "0.1.6"
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,
@@ -105,6 +105,7 @@ class HomelyWebSocket:
105
105
  self._status_update_callback = status_update_callback
106
106
  self._status = "Not initialized"
107
107
  self._status_reason: str | None = None
108
+ self._loop: asyncio.AbstractEventLoop | None = None
108
109
 
109
110
  def _ctx(self, device_id: str | None = None) -> str:
110
111
  """Build consistent log context."""
@@ -272,7 +273,13 @@ class HomelyWebSocket:
272
273
  try:
273
274
  loop = asyncio.get_running_loop()
274
275
  except RuntimeError:
275
- loop = asyncio.get_event_loop()
276
+ loop = self._loop
277
+ if loop is None:
278
+ _LOGGER.error(
279
+ "Cannot start reconnect loop: no event loop available %s",
280
+ self._ctx(),
281
+ )
282
+ return
276
283
 
277
284
  self._reconnect_task = loop.create_task(self._reconnect_loop())
278
285
  if reason:
@@ -332,6 +339,12 @@ class HomelyWebSocket:
332
339
  _LOGGER.debug("Skipping websocket connect during shutdown %s", self._ctx())
333
340
  return False
334
341
 
342
+ if self._loop is None:
343
+ try:
344
+ self._loop = asyncio.get_running_loop()
345
+ except RuntimeError:
346
+ pass
347
+
335
348
  try:
336
349
  import socketio # type: ignore[import-untyped]
337
350
  except ImportError:
@@ -358,7 +371,7 @@ class HomelyWebSocket:
358
371
  self.socket = socketio.AsyncClient(
359
372
  reconnection=False,
360
373
  logger=False,
361
- engineio_logger=False,
374
+ engineio_logger=logging.getLogger("engineio.client"),
362
375
  )
363
376
 
364
377
  async def connect() -> None:
@@ -450,7 +463,6 @@ class HomelyWebSocket:
450
463
  self.socket = None
451
464
  finally:
452
465
  self._set_status("Disconnected", "manual disconnect")
453
- self._is_closing = False
454
466
 
455
467
  async def close(self) -> None:
456
468
  """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.4
3
+ Version: 0.1.6
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
@@ -93,7 +93,7 @@ class _FakeAsyncCallable:
93
93
  async def test_sdk_exports_public_symbols():
94
94
  """The SDK should expose a clean public surface."""
95
95
  assert auth_header_value("token") == "Bearer token"
96
- assert __version__ == "0.1.3"
96
+ assert __version__ == "0.1.5"
97
97
 
98
98
 
99
99
  async def test_authenticate_returns_typed_token():
File without changes
File without changes
File without changes