aioWiserHeatAPI 1.5.9__tar.gz → 1.5.10__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.
Files changed (52) hide show
  1. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/PKG-INFO +6 -2
  2. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/README.md +5 -1
  3. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/__init__.py +1 -1
  4. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/exceptions.py +4 -0
  5. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/rest_controller.py +55 -11
  6. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/wiserhub.py +1 -3
  7. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI.egg-info/PKG-INFO +6 -2
  8. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/LICENSE +0 -0
  9. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/cli.py +0 -0
  10. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/const.py +0 -0
  11. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/devices.py +0 -0
  12. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/discovery.py +0 -0
  13. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/heating.py +0 -0
  14. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/heating_actuator.py +0 -0
  15. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/helpers/__init__.py +0 -0
  16. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/helpers/automations.py +0 -0
  17. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/helpers/battery.py +0 -0
  18. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/helpers/capabilities.py +0 -0
  19. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/helpers/cloud.py +0 -0
  20. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/helpers/device.py +0 -0
  21. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/helpers/equipment.py +0 -0
  22. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/helpers/extra_config.py +0 -0
  23. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/helpers/firmware.py +0 -0
  24. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/helpers/gps.py +0 -0
  25. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/helpers/misc.py +0 -0
  26. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/helpers/network.py +0 -0
  27. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/helpers/opentherm.py +0 -0
  28. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/helpers/signal.py +0 -0
  29. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/helpers/special_times.py +0 -0
  30. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/helpers/status.py +0 -0
  31. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/helpers/temp.py +0 -0
  32. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/helpers/zigbee.py +0 -0
  33. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/hot_water.py +0 -0
  34. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/light.py +0 -0
  35. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/moments.py +0 -0
  36. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/pte.py +0 -0
  37. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/room.py +0 -0
  38. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/roomstat.py +0 -0
  39. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/schedule.py +0 -0
  40. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/shutter.py +0 -0
  41. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/smartplug.py +0 -0
  42. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/smartvalve.py +0 -0
  43. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/smokealarm.py +0 -0
  44. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/system.py +0 -0
  45. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI/ufh.py +0 -0
  46. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI.egg-info/SOURCES.txt +0 -0
  47. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI.egg-info/dependency_links.txt +0 -0
  48. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI.egg-info/entry_points.txt +0 -0
  49. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI.egg-info/requires.txt +0 -0
  50. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/aioWiserHeatAPI.egg-info/top_level.txt +0 -0
  51. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/setup.cfg +0 -0
  52. {aioWiserHeatAPI-1.5.9 → aioWiserHeatAPI-1.5.10}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aioWiserHeatAPI
3
- Version: 1.5.9
3
+ Version: 1.5.10
4
4
  Summary: An AsyncIO API for controlling the Drayton Wiser Heating system
5
5
  Home-page: https://github.com/msp1974/aioWiserHeatAPI
6
6
  Author: Mark Parker
@@ -18,7 +18,7 @@ Requires-Dist: aiohttp>=3.9.3
18
18
  Requires-Dist: aiofiles>=23.2.1
19
19
  Requires-Dist: pyyaml>=6.0.1
20
20
 
21
- # Drayton Wiser Hub API Async v1.5.8
21
+ # Drayton Wiser Hub API Async v1.5.10
22
22
 
23
23
  This repository contains a simple API which queries the Drayton Wiser Heating sysystem used in the UK.
24
24
 
@@ -72,6 +72,10 @@ Documentation available in [info.md](https://github.com/msp1974/wiserHeatAPIv2/b
72
72
 
73
73
  ## Changelog
74
74
 
75
+ ### v1.5.10
76
+
77
+ * Add retry routine to prevent hub response errors
78
+
75
79
  ### v1.5.9
76
80
 
77
81
  * Force schedules endpoint to use http/1.0
@@ -1,4 +1,4 @@
1
- # Drayton Wiser Hub API Async v1.5.8
1
+ # Drayton Wiser Hub API Async v1.5.10
2
2
 
3
3
  This repository contains a simple API which queries the Drayton Wiser Heating sysystem used in the UK.
4
4
 
@@ -52,6 +52,10 @@ Documentation available in [info.md](https://github.com/msp1974/wiserHeatAPIv2/b
52
52
 
53
53
  ## Changelog
54
54
 
55
+ ### v1.5.10
56
+
57
+ * Add retry routine to prevent hub response errors
58
+
55
59
  ### v1.5.9
56
60
 
57
61
  * Force schedules endpoint to use http/1.0
@@ -3,6 +3,6 @@ import logging
3
3
  name = "aioWiserHeatAPI"
4
4
  __all__ = ["wiserAPI", "wiserDiscovery"]
5
5
 
6
- __VERSION__ = "1.5.9"
6
+ __VERSION__ = "1.5.10"
7
7
 
8
8
  _LOGGER = logging.getLogger(__name__)
@@ -3,6 +3,10 @@ class WiserHubConnectionError(Exception):
3
3
  pass
4
4
 
5
5
 
6
+ class WiserHubResponseError(Exception):
7
+ """Response error mainly for bad request"""
8
+
9
+
6
10
  class WiserHubAuthenticationError(Exception):
7
11
  pass
8
12
 
@@ -20,6 +20,7 @@ from .exceptions import (
20
20
  WiserExtraConfigError,
21
21
  WiserHubAuthenticationError,
22
22
  WiserHubConnectionError,
23
+ WiserHubResponseError,
23
24
  WiserHubRESTError,
24
25
  )
25
26
  from .helpers.extra_config import _WiserExtraConfig
@@ -81,17 +82,49 @@ class _WiserRestController(object):
81
82
  url: str,
82
83
  data: dict = None,
83
84
  raise_for_endpoint_error: bool = True,
85
+ ):
86
+ """Function to retry on response errors due to inconsistant isues reading from the hub."""
87
+ backoff = [1, 2, 3, 5, 10]
88
+ http_version = aiohttp.HttpVersion11
89
+ for i in range(0, 5):
90
+ if i > 2:
91
+ http_version = aiohttp.HttpVersion10
92
+ try:
93
+ response = await self._execute_request(
94
+ action,
95
+ url,
96
+ data,
97
+ raise_for_endpoint_error,
98
+ http_version,
99
+ i + 1,
100
+ )
101
+ return response
102
+ except WiserHubResponseError as ex:
103
+ # Last 2 attempts try http 1.0
104
+ _LOGGER.debug("%s. Retrying in %is", ex, backoff[i])
105
+ # Backing off pause
106
+ await asyncio.sleep(backoff[i])
107
+
108
+ raise WiserHubConnectionError(
109
+ f"Unable to get a valid response from the Wiser hub. "
110
+ f"{self._wiser_connection_info.host} for url {url}"
111
+ )
112
+
113
+ async def _execute_request( # noqa
114
+ self,
115
+ action: WiserRestActionEnum,
116
+ url: str,
117
+ data: dict = None,
118
+ raise_for_endpoint_error: bool = True,
119
+ http_version=aiohttp.HttpVersion11,
120
+ attempt: int = 1,
84
121
  ):
85
122
  """
86
- Send patch update to hub and raise errors if fails
123
+ Send request to hub and raise errors if fails
87
124
  param url: url of hub rest api endpoint
88
125
  param patchData: json object containing command and values to set
89
126
  return: boolean
90
127
  """
91
- if url in [WISERHUBDOMAIN]:
92
- http_version = aiohttp.HttpVersion11
93
- else:
94
- http_version = aiohttp.HttpVersion10
95
128
 
96
129
  url = url.format(
97
130
  self._wiser_connection_info.host,
@@ -101,22 +134,31 @@ class _WiserRestController(object):
101
134
  kwargs = {}
102
135
  kwargs["headers"] = {
103
136
  "SECRET": self._wiser_connection_info.secret,
104
- "Content-Type": "application/json;charset=UTF-8",
137
+ "Connection": "close",
105
138
  }
106
139
 
107
- if data is not None:
140
+ # if data is not None:
141
+ if data:
108
142
  kwargs["json"] = data
143
+ kwargs["headers"].update(
144
+ {
145
+ "Content-Type": "application/json;charset=UTF-8",
146
+ }
147
+ )
109
148
  if self._timeout is not None:
110
149
  kwargs["timeout"] = self._timeout
111
150
 
112
151
  try:
152
+ _LOGGER.debug(
153
+ "URL: %s, Attempt: %i, Http: %s", url, attempt, http_version
154
+ )
113
155
  async with aiohttp.ClientSession(
114
156
  version=http_version,
115
157
  ) as session:
116
- async with getattr(session, action.value)(
117
- url,
118
- **kwargs,
158
+ async with session.request(
159
+ action.value, url, **kwargs
119
160
  ) as response:
161
+ # await asyncio.sleep(1)
120
162
  if not response.ok:
121
163
  self._process_nok_response(
122
164
  response, url, data, raise_for_endpoint_error
@@ -149,7 +191,7 @@ class _WiserRestController(object):
149
191
  f"{self._wiser_connection_info.host} for url {url}. Error is {ex}"
150
192
  ) from ex
151
193
  except aiohttp.ClientResponseError as ex:
152
- raise WiserHubConnectionError(
194
+ raise WiserHubResponseError(
153
195
  f"Response error trying to communicate with Wiser Hub "
154
196
  f"{self._wiser_connection_info.host} for url {url}. Error is {ex}"
155
197
  ) from ex
@@ -166,6 +208,8 @@ class _WiserRestController(object):
166
208
  data: dict,
167
209
  raise_for_endpoint_error: bool = True,
168
210
  ):
211
+ if response.status == 400:
212
+ _LOGGER.debug("400 error")
169
213
  if response.status == 401:
170
214
  raise WiserHubAuthenticationError(
171
215
  f"Error authenticating to Wiser Hub "
@@ -56,7 +56,7 @@ from .schedule import WiserScheduleTypeEnum, _WiserScheduleCollection
56
56
  from .system import _WiserSystem
57
57
 
58
58
 
59
- class WiserAPI(object):
59
+ class WiserAPI:
60
60
  """
61
61
  Main api class to access all entities and attributes of wiser system
62
62
  """
@@ -67,12 +67,10 @@ class WiserAPI(object):
67
67
  secret: str,
68
68
  port: Optional[int] = 80,
69
69
  units: Optional[WiserUnitsEnum] = WiserUnitsEnum.metric,
70
- session: Optional[aiohttp.ClientSession] = None,
71
70
  extra_config_file: Optional[str] = None,
72
71
  enable_automations: Optional[bool] = True,
73
72
  ):
74
73
  # Connection variables
75
- self._session = session
76
74
  self._wiser_api_connection = _WiserConnectionInfo()
77
75
  self._wiser_rest_controller = None
78
76
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aioWiserHeatAPI
3
- Version: 1.5.9
3
+ Version: 1.5.10
4
4
  Summary: An AsyncIO API for controlling the Drayton Wiser Heating system
5
5
  Home-page: https://github.com/msp1974/aioWiserHeatAPI
6
6
  Author: Mark Parker
@@ -18,7 +18,7 @@ Requires-Dist: aiohttp>=3.9.3
18
18
  Requires-Dist: aiofiles>=23.2.1
19
19
  Requires-Dist: pyyaml>=6.0.1
20
20
 
21
- # Drayton Wiser Hub API Async v1.5.8
21
+ # Drayton Wiser Hub API Async v1.5.10
22
22
 
23
23
  This repository contains a simple API which queries the Drayton Wiser Heating sysystem used in the UK.
24
24
 
@@ -72,6 +72,10 @@ Documentation available in [info.md](https://github.com/msp1974/wiserHeatAPIv2/b
72
72
 
73
73
  ## Changelog
74
74
 
75
+ ### v1.5.10
76
+
77
+ * Add retry routine to prevent hub response errors
78
+
75
79
  ### v1.5.9
76
80
 
77
81
  * Force schedules endpoint to use http/1.0