Skip to content

Commit 2b6c368

Browse files
authored
Merge pull request #619 from plugwise/impr_model_id
Improve model_id implementation
2 parents b389524 + d0bebc7 commit 2b6c368

File tree

11 files changed

+225
-203
lines changed

11 files changed

+225
-203
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v1.4.0
4+
5+
- Improve model_id implementation, allow direct access to the gateway `smile_model_id`.
6+
37
## v1.3.1
48

59
- Add missing typing for model_id.

plugwise/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def __init__(
8585
self.smile_legacy = False
8686
self.smile_mac_address: str | None = None
8787
self.smile_model: str = NONE
88+
self.smile_model_id: str | None = None
8889
self.smile_name: str = NONE
8990
self.smile_type: str = NONE
9091
self.smile_version: str = NONE
@@ -145,6 +146,7 @@ async def connect(self) -> bool:
145146
self.smile_hw_version,
146147
self.smile_mac_address,
147148
self.smile_model,
149+
self.smile_model_id,
148150
self.smile_name,
149151
self.smile_type,
150152
self._user,
@@ -190,6 +192,7 @@ async def _smile_detect(self, result: etree, dsmrmain: etree) -> None:
190192
self.smile_hw_version = gateway.find("hardware_version").text
191193
self.smile_hostname = gateway.find("hostname").text
192194
self.smile_mac_address = gateway.find("mac_address").text
195+
self.smile_model_id = gateway.find("vendor_model").text
193196
else:
194197
model = await self._smile_detect_legacy(result, dsmrmain, model)
195198

plugwise/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ class DeviceData(TypedDict, total=False):
518518
mac_address: str
519519
members: list[str]
520520
model: str
521-
model_id: str
521+
model_id: str | None
522522
name: str
523523
vendor: str
524524
zigbee_mac_address: str

plugwise/helper.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ def __init__(self) -> None:
254254
self.smile_hw_version: str | None
255255
self.smile_mac_address: str | None
256256
self.smile_model: str
257+
self.smile_model_id: str | None
257258
self.smile_name: str
258259
self.smile_type: str
259260
self.smile_zigbee_mac_address: str | None
@@ -351,7 +352,7 @@ def _p1_smartmeter_info_finder(self, appl: Munch) -> None:
351352
appl.dev_id = self.gateway_id
352353
appl.location = loc_id
353354
appl.mac = None
354-
appl.model = self._domain_objects.find("./gateway/vendor_model").text
355+
appl.model = None
355356
appl.model_id = None
356357
appl.name = "P1"
357358
appl.pwclass = "smartmeter"
@@ -421,7 +422,7 @@ def _appl_gateway_info(self, appl: Munch, appliance: etree) -> Munch:
421422
appl.hardware = self.smile_hw_version
422423
appl.mac = self.smile_mac_address
423424
appl.model = self.smile_model
424-
appl.model_id = self._domain_objects.find("./gateway/vendor_model").text
425+
appl.model_id = self.smile_model_id
425426
appl.name = self.smile_name
426427
appl.vendor_name = "Plugwise"
427428

plugwise/smile.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def __init__(
6262
smile_hw_version: str | None,
6363
smile_mac_address: str | None,
6464
smile_model: str,
65+
smile_model_id: str | None,
6566
smile_name: str,
6667
smile_type: str,
6768
username: str = DEFAULT_USERNAME,
@@ -93,6 +94,7 @@ def __init__(
9394
self.smile_hw_version = smile_hw_version
9495
self.smile_mac_address = smile_mac_address
9596
self.smile_model = smile_model
97+
self.smile_model_id = smile_model_id
9698
self.smile_name = smile_name
9799
self.smile_type = smile_type
98100

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "plugwise"
7-
version = "1.3.1"
7+
version = "1.4.0"
88
license = {file = "LICENSE"}
99
description = "Plugwise Smile (Adam/Anna/P1) and Stretch module for Python 3."
1010
readme = "README.md"

0 commit comments

Comments
 (0)