python-swidget 1.3.0__tar.gz → 1.3.2__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,8 +1,7 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: python-swidget
3
- Version: 1.3.0
3
+ Version: 1.3.2
4
4
  Summary: Python API for Swidget smart devices
5
- Home-page: https://github.com/swidget/python-swidget
6
5
  License: GPL-3.0-or-later
7
6
  Author: Swidget
8
7
  Requires-Python: >=3.8,<4.0
@@ -21,13 +20,13 @@ Requires-Dist: asyncclick (>=8)
21
20
  Requires-Dist: importlib-metadata
22
21
  Requires-Dist: m2r (>=0,<1) ; extra == "docs"
23
22
  Requires-Dist: mistune (<2.0.0) ; extra == "docs"
24
- Requires-Dist: pydantic (>=1,<2)
23
+ Requires-Dist: pydantic (>=2,<3)
25
24
  Requires-Dist: requests (==2.32.3)
26
25
  Requires-Dist: sphinx (>=4,<5) ; extra == "docs"
27
26
  Requires-Dist: sphinx_rtd_theme (>=0,<1) ; extra == "docs"
28
27
  Requires-Dist: sphinxcontrib-programoutput (>=0,<1) ; extra == "docs"
29
28
  Requires-Dist: ssdp (==1.1.1)
30
- Requires-Dist: types-requests (==2.31.0.6)
29
+ Requires-Dist: types-requests (>=2.3.0,<3.0.0)
31
30
  Requires-Dist: urllib3 (==1.26.5)
32
31
  Project-URL: Repository, https://github.com/swidget/python-swidget
33
32
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-swidget"
3
- version = "1.3.0"
3
+ version = "1.3.2"
4
4
  description = "Python API for Swidget smart devices"
5
5
  license = "GPL-3.0-or-later"
6
6
  authors = ["Swidget"]
@@ -20,10 +20,10 @@ aiohttp = ">=3.8.1"
20
20
  anyio = "*" # see https://github.com/python-trio/asyncclick/issues/18
21
21
  importlib-metadata = "*"
22
22
  asyncclick = ">=8"
23
- pydantic = "^1"
23
+ pydantic = "^2"
24
24
  ssdp = "1.1.1"
25
25
  requests = "2.32.3"
26
- types-requests = "2.31.0.6"
26
+ types-requests = "^2.3.0"
27
27
  urllib3 = '1.26.5'
28
28
 
29
29
  # required only for docs
@@ -6,7 +6,7 @@ import time
6
6
  from collections.abc import Callable
7
7
  from enum import Enum
8
8
  from types import TracebackType
9
- from typing import Any, Dict, List
9
+ from typing import Any, Dict, List, Optional
10
10
 
11
11
  from aiohttp import ClientSession, TCPConnector
12
12
 
@@ -98,11 +98,11 @@ class SwidgetDevice:
98
98
  """Property to represent if the client is connected to the device."""
99
99
  return self._websocket.connected
100
100
 
101
- def get_websocket(self) -> SwidgetWebsocket | None:
101
+ def get_websocket(self) -> Optional[SwidgetWebsocket]:
102
102
  """Return the SwidgetWebsocket class instance if possible."""
103
103
  if self.use_websockets:
104
104
  return self._websocket
105
- return None
105
+ raise RuntimeError("Swidget instance is not configured to use websockets")
106
106
 
107
107
  def set_countdown_timer(self, minutes) -> Any:
108
108
  """Set the countdown timer."""
@@ -27,7 +27,7 @@ class SwidgetWebsocket:
27
27
  session: aiohttp.ClientSession | None = None,
28
28
  use_security: bool = True,
29
29
  retry_interval: int = 30, # Initial retry interval in seconds
30
- max_retries: int = 200, # Maximum number of reconnection attempts
30
+ max_retries: int | None = None, # Maximum number of reconnection attempts
31
31
  ):
32
32
  """Initialize the SwidgetWebsocket.
33
33
 
@@ -93,8 +93,8 @@ class SwidgetWebsocket:
93
93
  )
94
94
  self.retry_count = 0
95
95
  _LOGGER.debug("Websocket now connected")
96
- except (ClientConnectionError, WSServerHandshakeError) as e:
97
- _LOGGER.error(f"Error connecting to websocket: {e}")
96
+ except (ClientConnectionError, WSServerHandshakeError):
97
+ _LOGGER.error("Error connecting to websocket")
98
98
  self._client = None
99
99
  except socket.gaierror as e:
100
100
  _LOGGER.error(f"Error resolving host: {e}")
@@ -167,7 +167,7 @@ class SwidgetWebsocket:
167
167
  self.retry_count += 1
168
168
  delay = self.retry_interval * (2 ** (self.retry_count - 1))
169
169
  _LOGGER.warning(
170
- f"Reconnecting in {delay} seconds (attempt {self.retry_count})..."
170
+ f"Reconnecting to Swidget device: {self.host} in {delay} seconds (attempt {self.retry_count})..."
171
171
  )
172
172
  await asyncio.sleep(delay)
173
173
  await self.connect()
File without changes