Skip to content

Commit 2b78d8d

Browse files
authored
Merge pull request #395 from plugwise/test_updated_2
Testing update 2
2 parents 57e1206 + f1ef088 commit 2b78d8d

18 files changed

+3705
-12
lines changed

CHANGELOG.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Changelog
22

3-
## Ongoing
3+
## v0.32.3 Improve quality by extended testing, bugfix
44

55
- Testing: make it possible to emulate binary_sensors, climates, numbers, sensors, switches, etc., updating.
6-
- Fix a bug which prevents the updating of the available-state of zigbee devices.
7-
- Modify the added P1 Plugwise notification so that it does not impact the device-availability
6+
- Add extra updated-testcases for each platform.
7+
- Fix a bug which prevents the updating of the available-state of zigbee devices (correct data-collection at updating).
8+
- Optimize first-time data-collection at initialization.
9+
- Modify the added P1 Plugwise notification so that it does not impact the device-availability.
810

911
## v0.32.2 Continuous improvements, bugfix
1012

plugwise/__init__.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
MIN_SETPOINT,
2626
MODULES,
2727
NOTIFICATIONS,
28+
REQUIRE_APPLIANCES,
2829
RULES,
2930
SMILES,
3031
STATUS,
@@ -474,13 +475,12 @@ async def _smile_detect(self, result: etree, dsmrmain: etree) -> None:
474475

475476
async def _full_update_device(self) -> None:
476477
"""Perform a first fetch of all XML data, needed for initialization."""
478+
await self._update_domain_objects()
477479
self._locations = await self._request(LOCATIONS)
478480
self._modules = await self._request(MODULES)
479-
480-
# P1 legacy has no appliances and nothing of interest in domain_objects
481+
# P1 legacy has no appliances
481482
if not (self.smile_type == "power" and self._smile_legacy):
482483
self._appliances = await self._request(APPLIANCES)
483-
await self._update_domain_objects()
484484

485485
async def _update_domain_objects(self) -> None:
486486
"""Helper-function for smile.py: full_update_device() and async_update().
@@ -506,19 +506,16 @@ async def _update_domain_objects(self) -> None:
506506

507507
async def async_update(self) -> PlugwiseData:
508508
"""Perform an incremental update for updating the various device states."""
509+
await self._update_domain_objects()
509510
match self._target_smile:
510511
case "smile_v2":
511512
self._modules = await self._request(MODULES)
512513
case "smile_v3" | "smile_v4":
513514
self._locations = await self._request(LOCATIONS)
514-
case "smile_thermo_v1" | "smile_thermo_v3" | "smile_thermo_v4":
515-
self._appliances = await self._request(APPLIANCES)
516-
await self._update_domain_objects()
517515
case "smile_open_therm_v2" | "smile_open_therm_v3":
518516
self._appliances = await self._request(APPLIANCES)
519-
await self._update_domain_objects()
520517
self._modules = await self._request(MODULES)
521-
case "stretch_v2" | "stretch_v3":
518+
case self._target_smile if self._target_smile in REQUIRE_APPLIANCES:
522519
self._appliances = await self._request(APPLIANCES)
523520

524521
self.gw_data["notifications"] = self._notifications

plugwise/constants.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,13 @@
200200
"stretch_v2": SMILE("stretch", "Stretch"),
201201
"stretch_v3": SMILE("stretch", "Stretch"),
202202
}
203+
REQUIRE_APPLIANCES: Final[list[str]] = [
204+
"smile_thermo_v1",
205+
"smile_thermo_v3",
206+
"smile_thermo_v4",
207+
"stretch_v2",
208+
"stretch_v3",
209+
]
203210

204211
# Class, Literal and related tuple-definitions
205212

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 = "0.32.2"
7+
version = "0.32.3"
88
license = {file = "LICENSE"}
99
description = "Plugwise Smile (Adam/Anna/P1) and Stretch module for Python 3."
1010
readme = "README.md"

tests/test_smile.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,22 @@ async def test_connect_smile_p1_v2_2(self):
977977
},
978978
},
979979
}
980+
testdata_updated = {
981+
"199aa40f126840f392983d171374ab0b": {
982+
"sensors": {
983+
"net_electricity_point": -2248,
984+
"electricity_consumed_point": 0,
985+
"net_electricity_cumulative": 1019.101,
986+
"electricity_consumed_peak_cumulative": 1155.295,
987+
"electricity_consumed_off_peak_cumulative": 1642.84,
988+
"electricity_produced_point": 2248,
989+
"electricity_produced_peak_cumulative": 1296.336,
990+
"electricity_produced_off_peak_cumulative": 482.698,
991+
"gas_consumed_cumulative": 585.433,
992+
"gas_consumed_interval": 0,
993+
},
994+
},
995+
}
980996

981997
self.smile_setup = "smile_p1_v2_2"
982998
server, smile, client = await self.connect_wrapper()
@@ -994,6 +1010,11 @@ async def test_connect_smile_p1_v2_2(self):
9941010
assert self.device_items == 26
9951011
assert not self.notifications
9961012

1013+
# Now change some data and change directory reading xml from
1014+
# emulating reading newer dataset after an update_interval
1015+
self.smile_setup = "updated/smile_p1_v2_2"
1016+
await self.device_test(smile, testdata_updated, initialize=False)
1017+
9971018
await smile.close_connection()
9981019
await self.disconnect(server, client)
9991020

@@ -4740,6 +4761,39 @@ async def test_connect_stretch_v31(self):
47404761
"switches": {"relay": True},
47414762
},
47424763
}
4764+
testdata_updated = {
4765+
"aac7b735042c4832ac9ff33aae4f453b": {
4766+
"sensors": {
4767+
"electricity_consumed": 1000.0,
4768+
"electricity_consumed_interval": 20.7,
4769+
"electricity_produced": 0.0,
4770+
},
4771+
"switches": {"relay": True, "lock": True},
4772+
},
4773+
"cfe95cf3de1948c0b8955125bf754614": {
4774+
"sensors": {
4775+
"electricity_consumed": 0.0,
4776+
"electricity_consumed_interval": 0.0,
4777+
"electricity_produced": 0.0,
4778+
},
4779+
"switches": {"relay": False, "lock": False},
4780+
},
4781+
"059e4d03c7a34d278add5c7a4a781d19": {
4782+
"sensors": {
4783+
"electricity_consumed": 0.0,
4784+
"electricity_consumed_interval": 0.0,
4785+
"electricity_produced": 0.0,
4786+
},
4787+
"switches": {"relay": False, "lock": False},
4788+
},
4789+
"d03738edfcc947f7b8f4573571d90d2d": {
4790+
"members": [
4791+
"059e4d03c7a34d278add5c7a4a781d19",
4792+
"cfe95cf3de1948c0b8955125bf754614",
4793+
],
4794+
"switches": {"relay": False},
4795+
},
4796+
}
47434797

47444798
self.smile_setup = "stretch_v31"
47454799
server, smile, client = await self.connect_wrapper(stretch=True)
@@ -4757,6 +4811,11 @@ async def test_connect_stretch_v31(self):
47574811
assert smile.gateway_id == "0000aaaa0000aaaa0000aaaa0000aa00"
47584812
assert self.device_items == 83
47594813

4814+
# Now change some data and change directory reading xml from
4815+
# emulating reading newer dataset after an update_interval
4816+
self.smile_setup = "updated/stretch_v31"
4817+
await self.device_test(smile, testdata_updated, initialize=False)
4818+
47604819
await smile.close_connection()
47614820
await self.disconnect(server, client)
47624821

@@ -5237,6 +5296,25 @@ async def test_connect_p1v4_442_single(self):
52375296
},
52385297
},
52395298
}
5299+
testdata_updated = {
5300+
"ba4de7613517478da82dd9b6abea36af": {
5301+
"sensors": {
5302+
"net_electricity_point": -2248,
5303+
"electricity_consumed_peak_point": 0,
5304+
"electricity_consumed_off_peak_point": 0,
5305+
"electricity_consumed_peak_interval": 0,
5306+
"electricity_consumed_off_peak_interval": 0,
5307+
"electricity_produced_peak_point": 2248,
5308+
"electricity_produced_off_peak_point": 0,
5309+
"electricity_produced_peak_cumulative": 6.543,
5310+
"electricity_produced_off_peak_cumulative": 0.0,
5311+
"electricity_produced_peak_interval": 1345,
5312+
"electricity_produced_off_peak_interval": 0,
5313+
"electricity_phase_one_consumed": 0,
5314+
"electricity_phase_one_produced": 1998,
5315+
},
5316+
},
5317+
}
52405318

52415319
self.smile_setup = "p1v4_442_single"
52425320
server, smile, client = await self.connect_wrapper()
@@ -5255,6 +5333,11 @@ async def test_connect_p1v4_442_single(self):
52555333
assert self.device_items == 31
52565334
assert not self.notifications
52575335

5336+
# Now change some data and change directory reading xml from
5337+
# emulating reading newer dataset after an update_interval
5338+
self.smile_setup = "updated/p1v4_442_single"
5339+
await self.device_test(smile, testdata_updated, initialize=False)
5340+
52585341
await smile.close_connection()
52595342
await self.disconnect(server, client)
52605343

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<appliances>
3+
<appliance id='ba4de7613517478da82dd9b6abea36af'>
4+
<name>Gateway</name>
5+
<description>Container for variables logged about the Gateway in general.</description>
6+
<type>gateway</type>
7+
<created_date>2019-11-19T10:21:26.199+01:00</created_date>
8+
<modified_date>2022-12-24T10:15:43.205+01:00</modified_date>
9+
<deleted_date></deleted_date>
10+
<groups/>
11+
<logs>
12+
<point_log id='400e04683dd94718ada7ff8a8c1d7466'>
13+
<type>signal_strength</type>
14+
<unit>dBm</unit>
15+
<updated_date>2022-12-24T10:15:43.164+01:00</updated_date>
16+
<last_consecutive_log_date>2022-12-24T10:15:43.164+01:00</last_consecutive_log_date>
17+
<interval/>
18+
<signal_strength id='cb6934a63ceb43be9fb69db78f2065d0'/>
19+
<period start_date="2022-12-24T10:15:43.164+01:00" end_date="2022-12-24T10:15:43.164+01:00">
20+
<measurement log_date="2022-12-24T10:15:43.164+01:00">-71.00</measurement>
21+
</period>
22+
</point_log>
23+
<point_log id='4de35aefb34f498caf5cc595fc6df60b'>
24+
<type>link_quality</type>
25+
<unit></unit>
26+
<updated_date>2022-12-24T10:15:43.164+01:00</updated_date>
27+
<last_consecutive_log_date>2022-12-24T10:15:43.164+01:00</last_consecutive_log_date>
28+
<interval/>
29+
<link_quality id='332138ddfe334e4397b9523d67c05a56'/>
30+
<period start_date="2022-12-24T10:15:43.164+01:00" end_date="2022-12-24T10:15:43.164+01:00">
31+
<measurement log_date="2022-12-24T10:15:43.164+01:00">39</measurement>
32+
</period>
33+
</point_log>
34+
<point_log id='7c4e66de4d234a3ab161280d8d7e9ab3'>
35+
<type>wlan_state</type>
36+
<unit></unit>
37+
<updated_date>2022-12-24T10:15:43.165+01:00</updated_date>
38+
<last_consecutive_log_date>2022-12-24T10:15:43.165+01:00</last_consecutive_log_date>
39+
<interval/>
40+
<network_state id='4e078f2fae014cbab9f067ca66e80d55'/>
41+
<period start_date="2022-12-24T10:15:43.165+01:00" end_date="2022-12-24T10:15:43.165+01:00">
42+
<measurement log_date="2022-12-24T10:15:43.165+01:00">up</measurement>
43+
</period>
44+
</point_log>
45+
<point_log id='8032d845eee04dffab189be92589af0c'>
46+
<type>lan_state</type>
47+
<unit></unit>
48+
<updated_date>2022-12-24T10:15:37.058+01:00</updated_date>
49+
<last_consecutive_log_date>2022-12-24T10:15:37.058+01:00</last_consecutive_log_date>
50+
<interval/>
51+
<network_state id='11622002070241b088be817459e6180f'/>
52+
<period start_date="2022-12-24T10:15:37.058+01:00" end_date="2022-12-24T10:15:37.058+01:00">
53+
<measurement log_date="2022-12-24T10:15:37.058+01:00">down</measurement>
54+
</period>
55+
</point_log>
56+
<point_log id='ca05724c5fd14d8b8b07acc71331689b'>
57+
<type>lan_ip_address</type>
58+
<unit></unit>
59+
<updated_date>2022-12-24T10:15:37+01:00</updated_date>
60+
<last_consecutive_log_date>2022-12-24T10:15:37+01:00</last_consecutive_log_date>
61+
<interval/>
62+
<network_address id='f494dafd525a469b8e8da82ce8a34240'/>
63+
<period start_date="2022-12-24T10:15:37+01:00" end_date="2022-12-24T10:15:37+01:00">
64+
<measurement log_date="2022-12-24T10:15:37+01:00">0.0.0.0</measurement>
65+
</period>
66+
</point_log>
67+
<point_log id='d4524db60fee4a13b70c8c29f3b04b92'>
68+
<type>wlan_ip_address</type>
69+
<unit></unit>
70+
<updated_date>2022-12-24T10:15:43+01:00</updated_date>
71+
<last_consecutive_log_date>2022-12-24T10:15:43+01:00</last_consecutive_log_date>
72+
<interval/>
73+
<network_address id='cc36809b562c419686ebcaee95f36c7a'/>
74+
<period start_date="2022-12-24T10:15:43+01:00" end_date="2022-12-24T10:15:43+01:00">
75+
<measurement log_date="2022-12-24T10:15:43+01:00">127.0.0.1</measurement>
76+
</period>
77+
</point_log>
78+
</logs>
79+
<actuator_functionalities/>
80+
</appliance>
81+
</appliances>

0 commit comments

Comments
 (0)