@@ -1238,6 +1238,11 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any
12381238 f"Update of feature '{ feature } ' is not supported for { self .name } "
12391239 )
12401240
1241+ features , states = await self ._check_for_energy_and_power_features (
1242+ features , states
1243+ )
1244+
1245+ for feature in features :
12411246 match feature :
12421247 case NodeFeature .ENERGY :
12431248 states [feature ] = await self .energy_update ()
@@ -1273,6 +1278,38 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any
12731278
12741279 return states
12751280
1281+ async def _check_for_energy_and_power_features (
1282+ self , features : tuple [NodeFeature ], states : dict [NodeFeature , Any ]
1283+ ) -> tuple [tuple [NodeFeature ], dict [NodeFeature , Any ]]:
1284+ """Check for presence of both NodeFeature.ENERGY and NodeFeature.POWER.
1285+
1286+ If both are present, execute the related functions in a specific order
1287+ to assure a proper response to the hourly pulses-rollovers.
1288+ """
1289+ if NodeFeature .ENERGY in features and NodeFeature .POWER in features :
1290+ states [NodeFeature .POWER ] = await self .power_update ()
1291+ _LOGGER .debug (
1292+ "async_get_state %s - power: %s" ,
1293+ self ._mac_in_str ,
1294+ states [NodeFeature .POWER ],
1295+ )
1296+ states [NodeFeature .ENERGY ] = await self .energy_update ()
1297+ _LOGGER .debug (
1298+ "async_get_state %s - energy: %s" ,
1299+ self ._mac_in_str ,
1300+ states [NodeFeature .ENERGY ],
1301+ )
1302+
1303+ remaining_features : tuple [NodeFeature , ...] = ()
1304+ for feature in features :
1305+ if feature in [NodeFeature .ENERGY , NodeFeature .POWER ]:
1306+ continue
1307+ remaining_features += (feature ,)
1308+
1309+ return remaining_features , states
1310+
1311+ return features , states
1312+
12761313 async def energy_reset_request (self ) -> None :
12771314 """Send an energy-reset to a Node."""
12781315 if self ._node_protocols is None :
0 commit comments