plugwise 1.4.3__py3-none-any.whl → 1.5.0__py3-none-any.whl

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.
plugwise/__init__.py CHANGED
@@ -5,7 +5,9 @@ Plugwise backend module for Home Assistant Core.
5
5
  from __future__ import annotations
6
6
 
7
7
  from plugwise.constants import (
8
+ DEFAULT_LEGACY_TIMEOUT,
8
9
  DEFAULT_PORT,
10
+ DEFAULT_TIMEOUT,
9
11
  DEFAULT_USERNAME,
10
12
  DOMAIN_OBJECTS,
11
13
  LOGGER,
@@ -31,6 +33,7 @@ from plugwise.smile import SmileAPI
31
33
 
32
34
  import aiohttp
33
35
  from defusedxml import ElementTree as etree
36
+ from packaging.version import Version, parse
34
37
 
35
38
 
36
39
  class Smile(SmileComm):
@@ -42,26 +45,25 @@ class Smile(SmileComm):
42
45
  self,
43
46
  host: str,
44
47
  password: str,
45
- timeout: int,
46
48
  websession: aiohttp.ClientSession,
47
49
  port: int = DEFAULT_PORT,
48
50
  username: str = DEFAULT_USERNAME,
49
51
  ) -> None:
50
52
  """Set the constructor for this class."""
51
- super().__init__(
52
- host,
53
- password,
54
- port,
55
- timeout,
56
- username,
57
- websession,
58
- )
59
-
60
53
  self._host = host
61
- self._passwd = password
54
+ self._password = password
62
55
  self._port = port
63
- self._user = username
56
+ self._timeout = DEFAULT_LEGACY_TIMEOUT
57
+ self._username = username
64
58
  self._websession = websession
59
+ super().__init__(
60
+ self._host,
61
+ self._password,
62
+ self._port,
63
+ self._timeout,
64
+ self._username,
65
+ self._websession,
66
+ )
65
67
 
66
68
  self._cooling_present = False
67
69
  self._elga = False
@@ -75,7 +77,7 @@ class Smile(SmileComm):
75
77
  self._target_smile: str = NONE
76
78
  self.gateway_id: str = NONE
77
79
  self.loc_data: dict[str, ThermoLoc] = {}
78
- self.smile_fw_version: str | None = None
80
+ self.smile_fw_version: Version | None = None
79
81
  self.smile_hostname: str = NONE
80
82
  self.smile_hw_version: str | None = None
81
83
  self.smile_legacy = False
@@ -84,10 +86,10 @@ class Smile(SmileComm):
84
86
  self.smile_model_id: str | None = None
85
87
  self.smile_name: str = NONE
86
88
  self.smile_type: str = NONE
87
- self.smile_version: str = NONE
89
+ self.smile_version: Version | None = None
88
90
  self.smile_zigbee_mac_address: str | None = None
89
91
 
90
- async def connect(self) -> bool:
92
+ async def connect(self) -> Version | None:
91
93
  """Connect to Plugwise device and determine its name, type and version."""
92
94
  result = await self._request(DOMAIN_OBJECTS)
93
95
  # Work-around for Stretch fw 2.7.18
@@ -125,7 +127,7 @@ class Smile(SmileComm):
125
127
 
126
128
  self._smile_api = SmileAPI(
127
129
  self._host,
128
- self._passwd,
130
+ self._password,
129
131
  self._request,
130
132
  self._websession,
131
133
  self._cooling_present,
@@ -146,10 +148,10 @@ class Smile(SmileComm):
146
148
  self.smile_name,
147
149
  self.smile_type,
148
150
  self._port,
149
- self._user,
151
+ self._username,
150
152
  ) if not self.smile_legacy else SmileLegacyAPI(
151
153
  self._host,
152
- self._passwd,
154
+ self._password,
153
155
  self._request,
154
156
  self._websession,
155
157
  self._is_thermostat,
@@ -167,13 +169,13 @@ class Smile(SmileComm):
167
169
  self.smile_type,
168
170
  self.smile_zigbee_mac_address,
169
171
  self._port,
170
- self._user,
172
+ self._username,
171
173
  )
172
174
 
173
175
  # Update all endpoints on first connect
174
176
  await self._smile_api.full_update_device()
175
177
 
176
- return True
178
+ return self.smile_version
177
179
 
178
180
  async def _smile_detect(self, result: etree, dsmrmain: etree) -> None:
179
181
  """Helper-function for connect().
@@ -184,7 +186,7 @@ class Smile(SmileComm):
184
186
  if (gateway := result.find("./gateway")) is not None:
185
187
  if (v_model := gateway.find("vendor_model")) is not None:
186
188
  model = v_model.text
187
- self.smile_fw_version = gateway.find("firmware_version").text
189
+ self.smile_fw_version = parse(gateway.find("firmware_version").text)
188
190
  self.smile_hw_version = gateway.find("hardware_version").text
189
191
  self.smile_hostname = gateway.find("hostname").text
190
192
  self.smile_mac_address = gateway.find("mac_address").text
@@ -200,7 +202,7 @@ class Smile(SmileComm):
200
202
  )
201
203
  raise UnsupportedDeviceError
202
204
 
203
- version_major: str = self.smile_fw_version.split(".", 1)[0]
205
+ version_major= str(self.smile_fw_version.major)
204
206
  self._target_smile = f"{model}_v{version_major}"
205
207
  LOGGER.debug("Plugwise identified as %s", self._target_smile)
206
208
  if self._target_smile not in SMILES:
@@ -211,6 +213,9 @@ class Smile(SmileComm):
211
213
  )
212
214
  raise UnsupportedDeviceError
213
215
 
216
+ if not self.smile_legacy:
217
+ self._timeout = DEFAULT_TIMEOUT
218
+
214
219
  if self._target_smile in ("smile_open_therm_v2", "smile_thermo_v3"):
215
220
  LOGGER.error(
216
221
  "Your Smile identified as %s needs a firmware update as it's firmware is severely outdated",
@@ -267,7 +272,7 @@ class Smile(SmileComm):
267
272
  or network is not None
268
273
  ):
269
274
  system = await self._request(SYSTEM)
270
- self.smile_fw_version = system.find("./gateway/firmware").text
275
+ self.smile_fw_version = parse(system.find("./gateway/firmware").text)
271
276
  return_model = system.find("./gateway/product").text
272
277
  self.smile_hostname = system.find("./gateway/hostname").text
273
278
  # If wlan0 contains data it's active, so eth0 should be checked last
@@ -278,7 +283,7 @@ class Smile(SmileComm):
278
283
  # P1 legacy:
279
284
  elif dsmrmain is not None:
280
285
  status = await self._request(STATUS)
281
- self.smile_fw_version = status.find("./system/version").text
286
+ self.smile_fw_version = parse(status.find("./system/version").text)
282
287
  return_model = status.find("./system/product").text
283
288
  self.smile_hostname = status.find("./network/hostname").text
284
289
  self.smile_mac_address = status.find("./network/mac_address").text
plugwise/helper.py CHANGED
@@ -62,6 +62,7 @@ from dateutil import tz
62
62
  from dateutil.parser import parse
63
63
  from defusedxml import ElementTree as etree
64
64
  from munch import Munch
65
+ from packaging.version import Version
65
66
 
66
67
 
67
68
  class SmileComm:
@@ -99,7 +100,6 @@ class SmileComm:
99
100
 
100
101
  self._auth = BasicAuth(username, password=password)
101
102
  self._endpoint = f"http://{host}:{str(port)}"
102
- self._timeout = timeout
103
103
 
104
104
  async def _request(
105
105
  self,
@@ -250,7 +250,7 @@ class SmileHelper(SmileCommon):
250
250
  self.gw_data: GatewayData = {}
251
251
  self.gw_devices: dict[str, DeviceData] = {}
252
252
  self.loc_data: dict[str, ThermoLoc]
253
- self.smile_fw_version: str | None
253
+ self.smile_fw_version: Version | None
254
254
  self.smile_hw_version: str | None
255
255
  self.smile_mac_address: str | None
256
256
  self.smile_model: str
@@ -425,7 +425,7 @@ class SmileHelper(SmileCommon):
425
425
  def _appl_gateway_info(self, appl: Munch, appliance: etree) -> Munch:
426
426
  """Helper-function for _appliance_info_finder()."""
427
427
  self.gateway_id = appliance.attrib["id"]
428
- appl.firmware = self.smile_fw_version
428
+ appl.firmware = str(self.smile_fw_version)
429
429
  appl.hardware = self.smile_hw_version
430
430
  appl.mac = self.smile_mac_address
431
431
  appl.model = self.smile_model
plugwise/legacy/helper.py CHANGED
@@ -44,6 +44,7 @@ from plugwise.util import (
44
44
  # This way of importing aiohttp is because of patch/mocking in testing (aiohttp timeouts)
45
45
  from defusedxml import ElementTree as etree
46
46
  from munch import Munch
47
+ from packaging.version import Version
47
48
 
48
49
 
49
50
  def etree_to_dict(element: etree) -> dict[str, str]:
@@ -81,7 +82,7 @@ class SmileLegacyHelper(SmileCommon):
81
82
  self.gw_data: GatewayData = {}
82
83
  self.gw_devices: dict[str, DeviceData] = {}
83
84
  self.loc_data: dict[str, ThermoLoc]
84
- self.smile_fw_version: str | None
85
+ self.smile_fw_version: Version | None
85
86
  self.smile_hw_version: str | None
86
87
  self.smile_mac_address: str | None
87
88
  self.smile_model: str
@@ -194,7 +195,7 @@ class SmileLegacyHelper(SmileCommon):
194
195
  self.gw_devices[self.gateway_id] = {"dev_class": "gateway"}
195
196
  self._count += 1
196
197
  for key, value in {
197
- "firmware": self.smile_fw_version,
198
+ "firmware": str(self.smile_fw_version),
198
199
  "location": self._home_location,
199
200
  "mac_address": self.smile_mac_address,
200
201
  "model": self.smile_model,
plugwise/legacy/smile.py CHANGED
@@ -29,6 +29,7 @@ from plugwise.legacy.data import SmileLegacyData
29
29
 
30
30
  import aiohttp
31
31
  from munch import Munch
32
+ from packaging.version import Version
32
33
 
33
34
 
34
35
  class SmileLegacyAPI(SmileLegacyData):
@@ -48,7 +49,7 @@ class SmileLegacyAPI(SmileLegacyData):
48
49
  _stretch_v2: bool,
49
50
  _target_smile: str,
50
51
  loc_data: dict[str, ThermoLoc],
51
- smile_fw_version: str | None,
52
+ smile_fw_version: Version | None,
52
53
  smile_hostname: str,
53
54
  smile_hw_version: str | None,
54
55
  smile_mac_address: str | None,
plugwise/smile.py CHANGED
@@ -35,6 +35,7 @@ from defusedxml import ElementTree as etree
35
35
 
36
36
  # Dict as class
37
37
  from munch import Munch
38
+ from packaging.version import Version
38
39
 
39
40
 
40
41
  class SmileAPI(SmileData):
@@ -57,7 +58,7 @@ class SmileAPI(SmileData):
57
58
  _schedule_old_states: dict[str, dict[str, str]],
58
59
  gateway_id: str,
59
60
  loc_data: dict[str, ThermoLoc],
60
- smile_fw_version: str | None,
61
+ smile_fw_version: Version | None,
61
62
  smile_hostname: str | None,
62
63
  smile_hw_version: str | None,
63
64
  smile_mac_address: str | None,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: plugwise
3
- Version: 1.4.3
3
+ Version: 1.5.0
4
4
  Summary: Plugwise Smile (Adam/Anna/P1) and Stretch module for Python 3.
5
5
  Home-page: https://github.com/plugwise/python-plugwise
6
6
  Author: Plugwise device owners
@@ -0,0 +1,17 @@
1
+ plugwise/__init__.py,sha256=_AYvIt5rOBksqxp5Lrr7iv11i3mXXJpEQ6Q40pqtOPk,17147
2
+ plugwise/common.py,sha256=WltDqYlW5D3KqIcm5U_gVY4izLZSk_Uk-MEJl6RDNbs,12592
3
+ plugwise/constants.py,sha256=kVNrr4zeKFMiGBogVLZ6B925FHAIgy1PY2BBxaT1vkk,16742
4
+ plugwise/data.py,sha256=I4w3ABqmcj_uSnfxTWPYQH8WP6HaywVMx1aQ-feBdU0,10734
5
+ plugwise/exceptions.py,sha256=Ce-tO9uNsMB-8FP6VAxBvsHNJ-NIM9F0onUZOdZI4Ys,1110
6
+ plugwise/helper.py,sha256=Q3xaU4FoKnb9w8cOFPSNTuphjfsw2ltOE5alXd_AyGw,44433
7
+ plugwise/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ plugwise/smile.py,sha256=BALKDMY730C-vHCnOadnaM9ezv0iIEnu-V-BsHJRewY,18729
9
+ plugwise/util.py,sha256=u2qQt6ubQW1ioiDIIzOMnyydxQH5_48_Tbw_vEgCpyg,8161
10
+ plugwise/legacy/data.py,sha256=DsHR9xgiFDg_Vh_6ZpOskw8ZhNQ3CmwjstI3yiH6MEk,3048
11
+ plugwise/legacy/helper.py,sha256=HI9EvtTWfzKH5nX4G-YtLpn9Qvi50OLMRRIaN5v7rqU,18358
12
+ plugwise/legacy/smile.py,sha256=E_Zc1muzylyRMeYYbP4QhGBUQf_KaUUnbPAuIhH8WxY,11208
13
+ plugwise-1.5.0.dist-info/LICENSE,sha256=mL22BjmXtg_wnoDnnaqps5_Bg_VGj_yHueX5lsKwbCc,1144
14
+ plugwise-1.5.0.dist-info/METADATA,sha256=DsAzAxSnQ3WnaixtWgn3C_TvRth72I_nTbyniwx6ocQ,9097
15
+ plugwise-1.5.0.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
16
+ plugwise-1.5.0.dist-info/top_level.txt,sha256=MYOmktMFf8ZmX6_OE1y9MoCZFfY-L8DA0F2tA2IvE4s,9
17
+ plugwise-1.5.0.dist-info/RECORD,,
@@ -1,17 +0,0 @@
1
- plugwise/__init__.py,sha256=tv6B4s9TQAsmKhqiXpyGuszjfcP7wNRx_EFoorBevwA,16848
2
- plugwise/common.py,sha256=WltDqYlW5D3KqIcm5U_gVY4izLZSk_Uk-MEJl6RDNbs,12592
3
- plugwise/constants.py,sha256=kVNrr4zeKFMiGBogVLZ6B925FHAIgy1PY2BBxaT1vkk,16742
4
- plugwise/data.py,sha256=I4w3ABqmcj_uSnfxTWPYQH8WP6HaywVMx1aQ-feBdU0,10734
5
- plugwise/exceptions.py,sha256=Ce-tO9uNsMB-8FP6VAxBvsHNJ-NIM9F0onUZOdZI4Ys,1110
6
- plugwise/helper.py,sha256=uOmxYr4ic1F8nYLHb1c1dC7-WphM82VT9vMLQet3CU8,44418
7
- plugwise/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- plugwise/smile.py,sha256=x0BrEUMcW0oBAwgdr0qUvesoGvlHojgV96OxD2HdXd0,18687
9
- plugwise/util.py,sha256=u2qQt6ubQW1ioiDIIzOMnyydxQH5_48_Tbw_vEgCpyg,8161
10
- plugwise/legacy/data.py,sha256=DsHR9xgiFDg_Vh_6ZpOskw8ZhNQ3CmwjstI3yiH6MEk,3048
11
- plugwise/legacy/helper.py,sha256=DjdyU5kwXg4N5ZU9H65w7MSUY6SADcaAy_OziyFKDis,18311
12
- plugwise/legacy/smile.py,sha256=Rg4MX5hbCddrG03BWiCxzRWmAq4-_31Li45T6w79z8U,11166
13
- plugwise-1.4.3.dist-info/LICENSE,sha256=mL22BjmXtg_wnoDnnaqps5_Bg_VGj_yHueX5lsKwbCc,1144
14
- plugwise-1.4.3.dist-info/METADATA,sha256=hznYuWl93GPYl2H5UQcFv-fGquL7YnAd3l0LwxqflGw,9097
15
- plugwise-1.4.3.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
16
- plugwise-1.4.3.dist-info/top_level.txt,sha256=MYOmktMFf8ZmX6_OE1y9MoCZFfY-L8DA0F2tA2IvE4s,9
17
- plugwise-1.4.3.dist-info/RECORD,,