Skip to content

Commit 9629ca7

Browse files
authored
Merge pull request #297 from plugwise/spikes
Fix spikes in Energy graphs
2 parents 342b1af + cccab0b commit 9629ca7

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## ONGOING
44

5+
- Fix for [#291](https://github.com/plugwise/plugwise_usb-beta/issues/291) via PR [297](https://github.com/plugwise/python-plugwise-usb/pull/297)
56
- PR [295](https://github.com/plugwise/python-plugwise-usb/pull/295): Streamline of loading function, to allow nodes to load even if temporarily offline, especially for SED nodes.
67

78
## v0.44.8

plugwise_usb/nodes/circle.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,11 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any
12311231
f"Update of feature '{feature}' is not supported for {self.name}"
12321232
)
12331233

1234+
features, states = await self._check_for_energy_and_power_features(
1235+
features, states
1236+
)
1237+
1238+
for feature in features:
12341239
match feature:
12351240
case NodeFeature.ENERGY:
12361241
states[feature] = await self.energy_update()
@@ -1266,6 +1271,33 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any
12661271

12671272
return states
12681273

1274+
async def _check_for_energy_and_power_features(
1275+
self, features: tuple[NodeFeature], states: dict[NodeFeature, Any]
1276+
) -> tuple[tuple[NodeFeature], dict[NodeFeature, Any]]:
1277+
"""Check for presence of both NodeFeature.ENERGY and NodeFeature.POWER.
1278+
1279+
If both are present, execute the related functions in a specific order
1280+
to assure a proper response to the hourly pulses-rollovers.
1281+
"""
1282+
if {NodeFeature.ENERGY, NodeFeature.POWER} <= set(features):
1283+
states[NodeFeature.POWER] = await self.power_update()
1284+
_LOGGER.debug(
1285+
"async_get_state %s - power: %s",
1286+
self._mac_in_str,
1287+
states[NodeFeature.POWER],
1288+
)
1289+
states[NodeFeature.ENERGY] = await self.energy_update()
1290+
_LOGGER.debug(
1291+
"async_get_state %s - energy: %s",
1292+
self._mac_in_str,
1293+
states[NodeFeature.ENERGY],
1294+
)
1295+
return tuple(
1296+
set(features).difference({NodeFeature.ENERGY, NodeFeature.POWER})
1297+
), states
1298+
1299+
return features, states
1300+
12691301
async def energy_reset_request(self) -> None:
12701302
"""Send an energy-reset to a Node."""
12711303
if self._node_protocols is None:

0 commit comments

Comments
 (0)