python-homely 0.1.5__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.5
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.5"
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"
@@ -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:
@@ -403,7 +416,7 @@ class HomelyWebSocket:
403
416
  await asyncio.wait_for(
404
417
  self.socket.connect(
405
418
  url,
406
- transports=["polling", "websocket"],
419
+ transports=["websocket"],
407
420
  headers={"Authorization": bearer_token},
408
421
  ),
409
422
  timeout=10,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-homely
3
- Version: 0.1.5
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