aioWiserHeatAPI 1.5.2__tar.gz → 1.5.3__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 (51) hide show
  1. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/PKG-INFO +6 -2
  2. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/README.md +5 -1
  3. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/__init__.py +1 -1
  4. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/rest_controller.py +49 -25
  5. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/wiserhub.py +0 -5
  6. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI.egg-info/PKG-INFO +6 -2
  7. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/LICENSE +0 -0
  8. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/cli.py +0 -0
  9. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/const.py +0 -0
  10. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/devices.py +0 -0
  11. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/discovery.py +0 -0
  12. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/exceptions.py +0 -0
  13. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/heating.py +0 -0
  14. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/heating_actuator.py +0 -0
  15. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/helpers/__init__.py +0 -0
  16. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/helpers/automations.py +0 -0
  17. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/helpers/battery.py +0 -0
  18. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/helpers/capabilities.py +0 -0
  19. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/helpers/cloud.py +0 -0
  20. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/helpers/device.py +0 -0
  21. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/helpers/equipment.py +0 -0
  22. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/helpers/extra_config.py +0 -0
  23. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/helpers/firmware.py +0 -0
  24. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/helpers/gps.py +0 -0
  25. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/helpers/misc.py +0 -0
  26. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/helpers/network.py +0 -0
  27. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/helpers/opentherm.py +0 -0
  28. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/helpers/signal.py +0 -0
  29. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/helpers/special_times.py +0 -0
  30. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/helpers/status.py +0 -0
  31. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/helpers/temp.py +0 -0
  32. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/helpers/zigbee.py +0 -0
  33. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/hot_water.py +0 -0
  34. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/light.py +0 -0
  35. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/moments.py +0 -0
  36. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/pte.py +0 -0
  37. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/room.py +0 -0
  38. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/roomstat.py +0 -0
  39. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/schedule.py +0 -0
  40. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/shutter.py +0 -0
  41. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/smartplug.py +0 -0
  42. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/smartvalve.py +0 -0
  43. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/system.py +0 -0
  44. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI/ufh.py +0 -0
  45. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI.egg-info/SOURCES.txt +0 -0
  46. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI.egg-info/dependency_links.txt +0 -0
  47. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI.egg-info/entry_points.txt +0 -0
  48. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI.egg-info/requires.txt +0 -0
  49. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/aioWiserHeatAPI.egg-info/top_level.txt +0 -0
  50. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/setup.cfg +0 -0
  51. {aioWiserHeatAPI-1.5.2 → aioWiserHeatAPI-1.5.3}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aioWiserHeatAPI
3
- Version: 1.5.2
3
+ Version: 1.5.3
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.1
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.2
21
+ # Drayton Wiser Hub API Async v1.5.3
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.3
76
+
77
+ * Fixed issue whereby json conversion errors due to control characters in string
78
+
75
79
  ### v1.5.2
76
80
 
77
81
  * Revert to aiohttp and fix errors with v3.9.x that caused move to httpx
@@ -1,4 +1,4 @@
1
- # Drayton Wiser Hub API Async v1.5.2
1
+ # Drayton Wiser Hub API Async v1.5.3
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.3
56
+
57
+ * Fixed issue whereby json conversion errors due to control characters in string
58
+
55
59
  ### v1.5.2
56
60
 
57
61
  * Revert to aiohttp and fix errors with v3.9.x that caused move to httpx
@@ -3,6 +3,6 @@ import logging
3
3
  name = "aioWiserHeatAPI"
4
4
  __all__ = ["wiserAPI", "wiserDiscovery"]
5
5
 
6
- __VERSION__ = "1.5.2"
6
+ __VERSION__ = "1.5.3"
7
7
 
8
8
  _LOGGER = logging.getLogger(__name__)
@@ -1,6 +1,8 @@
1
+ """Module to manage rest commands of Wiser hub"""
1
2
  import asyncio
2
3
  import enum
3
4
  import json
5
+ import re
4
6
  from dataclasses import dataclass
5
7
  from typing import Optional
6
8
 
@@ -25,6 +27,8 @@ from .exceptions import (
25
27
 
26
28
  @dataclass
27
29
  class WiserAPIParams:
30
+ """Class to hold default values"""
31
+
28
32
  passive_mode_increment = 0.5
29
33
  stored_manual_target_temperature_alt_source = "current"
30
34
 
@@ -42,6 +46,8 @@ class _WiserConnectionInfo(object):
42
46
 
43
47
  # Enums
44
48
  class WiserRestActionEnum(enum.Enum):
49
+ """Enumeration of http methods"""
50
+
45
51
  GET = "get"
46
52
  POST = "post"
47
53
  PATCH = "patch"
@@ -65,6 +71,10 @@ class _WiserRestController(object):
65
71
  self._extra_config_file = None
66
72
  self._extra_config: _WiserExtraConfig = None
67
73
 
74
+ def remove_control_characters(self, data: str):
75
+ """Remove control charactwers from string."""
76
+ return re.sub(r"[\x00-\x1f]", "", data)
77
+
68
78
  async def _do_hub_action(
69
79
  self,
70
80
  action: WiserRestActionEnum,
@@ -112,26 +122,34 @@ class _WiserRestController(object):
112
122
  else:
113
123
  content = await response.read()
114
124
  if len(content) > 0:
115
- response = content.decode(
116
- "utf-8", "ignore"
117
- ).encode("utf-8")
118
- return json.loads(response)
125
+ response = content.decode("utf-8", "ignore")
126
+ return json.loads(
127
+ self.remove_control_characters(response),
128
+ )
119
129
  else:
120
130
  return {}
121
131
  return {}
122
132
 
123
133
  except asyncio.TimeoutError as ex:
124
134
  raise WiserHubConnectionError(
125
- f"Connection timeout trying to communicate with Wiser Hub {self._wiser_connection_info.host} for url {url}"
126
- )
135
+ f"Connection timeout trying to communicate with Wiser Hub "
136
+ f"{self._wiser_connection_info.host} for url {url}"
137
+ ) from ex
138
+ except ConnectionResetError as ex:
139
+ raise WiserHubConnectionError(
140
+ f"Connection was reset by the hub during communication "
141
+ f"{self._wiser_connection_info.host} for url {url}. Error is {ex}"
142
+ ) from ex
127
143
  except aiohttp.ClientResponseError as ex:
128
144
  raise WiserHubConnectionError(
129
- f"Response error trying to communicate with Wiser Hub {self._wiser_connection_info.host} for url {url}. Error is {ex}"
130
- )
145
+ f"Response error trying to communicate with Wiser Hub "
146
+ f"{self._wiser_connection_info.host} for url {url}. Error is {ex}"
147
+ ) from ex
131
148
  except aiohttp.ClientConnectorError as ex:
132
149
  raise WiserHubConnectionError(
133
- f"Connection error trying to communicate with Wiser Hub {self._wiser_connection_info.host} for url {url}. Error is {ex}"
134
- )
150
+ f"Connection error trying to communicate with Wiser Hub "
151
+ f"{self._wiser_connection_info.host} for url {url}. Error is {ex}"
152
+ ) from ex
135
153
 
136
154
  def _process_nok_response(
137
155
  self,
@@ -142,19 +160,24 @@ class _WiserRestController(object):
142
160
  ):
143
161
  if response.status == 401:
144
162
  raise WiserHubAuthenticationError(
145
- f"Error authenticating to Wiser Hub {self._wiser_connection_info.host}. Check your secret key"
163
+ f"Error authenticating to Wiser Hub "
164
+ f"{self._wiser_connection_info.host}. Check your secret key"
146
165
  )
147
166
  elif response.status == 404 and raise_for_endpoint_error:
148
167
  raise WiserHubRESTError(
149
- f"Rest endpoint not found on Wiser Hub {self._wiser_connection_info.host} for url {url}"
168
+ f"Rest endpoint not found on Wiser Hub "
169
+ f"{self._wiser_connection_info.host} for url {url}"
150
170
  )
151
171
  elif response.status == 408:
152
172
  raise WiserHubConnectionError(
153
- f"Connection timed out trying to communicate with Wiser Hub {self._wiser_connection_info.host} for url {url}"
173
+ f"Connection timed out trying to communicate with Wiser Hub "
174
+ f"{self._wiser_connection_info.host} for url {url}"
154
175
  )
155
176
  elif raise_for_endpoint_error:
156
177
  raise WiserHubRESTError(
157
- f"Unknown error communicating with Wiser Hub {self._wiser_connection_info.host} for url {url} with data {data}. Error code is: {response.status}"
178
+ f"Unknown error communicating with Wiser Hub "
179
+ f"{self._wiser_connection_info.host} for url {url} with data {data}. "
180
+ f"Error code is: {response.status}"
158
181
  )
159
182
 
160
183
  async def _get_hub_data(
@@ -176,9 +199,10 @@ class _WiserRestController(object):
176
199
  self._extra_config_file, self._hub_name.lower()
177
200
  )
178
201
  await self._extra_config.async_load_config()
179
- except WiserExtraConfigError as ex:
202
+ except WiserExtraConfigError:
180
203
  _LOGGER.error(
181
- "Your config file is corrupted and needs to be fixed to maintain all the functionality of this integration."
204
+ "Your config file is corrupted and needs to be fixed "
205
+ "to maintain all the functionality of this integration."
182
206
  )
183
207
  self._extra_config = None
184
208
 
@@ -196,9 +220,7 @@ class _WiserRestController(object):
196
220
  """
197
221
  url = WISERHUBDOMAIN + url
198
222
  _LOGGER.debug(
199
- "Sending command to url: {} with parameters {}".format(
200
- url, command_data
201
- )
223
+ "Sending command to url: %s with parameters %s", url, command_data
202
224
  )
203
225
 
204
226
  return await self._do_hub_action(method, url, command_data)
@@ -214,17 +236,19 @@ class _WiserRestController(object):
214
236
  """
215
237
  url = WISERHUBSCHEDULES + url
216
238
  _LOGGER.debug(
217
- "Actioning schedule to url: {} with action {} and data {}".format(
218
- url, action.value, schedule_data
219
- )
239
+ "Actioning schedule to url: %s with action %s and data %s",
240
+ url,
241
+ action.value,
242
+ schedule_data,
220
243
  )
244
+
221
245
  return await self._do_hub_action(action, url, schedule_data)
222
246
 
223
247
  async def _send_schedule_command(
224
248
  self,
225
249
  action: str,
226
250
  schedule_data: dict,
227
- id: int = 0,
251
+ schedule_id: int = 0,
228
252
  schedule_type: str = None,
229
253
  ) -> bool:
230
254
  """
@@ -236,7 +260,7 @@ class _WiserRestController(object):
236
260
  if action == "UPDATE":
237
261
  result = await self._do_schedule_action(
238
262
  WiserRestActionEnum.PATCH,
239
- "{}/{}".format(schedule_type, id),
263
+ f"{schedule_type}/{schedule_id}",
240
264
  schedule_data,
241
265
  )
242
266
 
@@ -257,7 +281,7 @@ class _WiserRestController(object):
257
281
  elif action == "DELETE":
258
282
  result = await self._do_schedule_action(
259
283
  WiserRestActionEnum.DELETE,
260
- "{}/{}".format(schedule_type, id),
284
+ f"{schedule_type}/{schedule_id}",
261
285
  schedule_data,
262
286
  )
263
287
  return result
@@ -66,13 +66,11 @@ class WiserAPI(object):
66
66
  host: str,
67
67
  secret: str,
68
68
  port: Optional[int] = 80,
69
- session: Optional[aiohttp.ClientSession] = None,
70
69
  units: Optional[WiserUnitsEnum] = WiserUnitsEnum.metric,
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
 
@@ -243,9 +241,6 @@ class WiserAPI(object):
243
241
 
244
242
  return False
245
243
 
246
- async def close_session(self):
247
- await self._wiser_rest_controller._session.close()
248
-
249
244
  # API properties
250
245
  @property
251
246
  def api_parameters(self):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aioWiserHeatAPI
3
- Version: 1.5.2
3
+ Version: 1.5.3
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.1
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.2
21
+ # Drayton Wiser Hub API Async v1.5.3
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.3
76
+
77
+ * Fixed issue whereby json conversion errors due to control characters in string
78
+
75
79
  ### v1.5.2
76
80
 
77
81
  * Revert to aiohttp and fix errors with v3.9.x that caused move to httpx
File without changes