@@ -1232,6 +1232,11 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any
12321232 f"Update of feature '{ feature } ' is not supported for { self .name } "
12331233 )
12341234
1235+ features , states = await self ._check_for_energy_and_power_features (
1236+ features , states
1237+ )
1238+
1239+ for feature in features :
12351240 match feature :
12361241 case NodeFeature .ENERGY :
12371242 states [feature ] = await self .energy_update ()
@@ -1267,6 +1272,38 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any
12671272
12681273 return states
12691274
1275+ async def _check_for_energy_and_power_features (
1276+ self , features : tuple [NodeFeature ], states : dict [NodeFeature , Any ]
1277+ ) -> tuple [tuple [NodeFeature ], dict [NodeFeature , Any ]]:
1278+ """Check for presence of both NodeFeature.ENERGY and NodeFeature.POWER.
1279+
1280+ If both are present, execute the related functions in a specific order
1281+ to assure a proper response to the hourly pulses-rollovers.
1282+ """
1283+ if NodeFeature .ENERGY in features and NodeFeature .POWER in features :
1284+ states [NodeFeature .POWER ] = await self .power_update ()
1285+ _LOGGER .debug (
1286+ "async_get_state %s - power: %s" ,
1287+ self ._mac_in_str ,
1288+ states [NodeFeature .POWER ],
1289+ )
1290+ states [NodeFeature .ENERGY ] = await self .energy_update ()
1291+ _LOGGER .debug (
1292+ "async_get_state %s - energy: %s" ,
1293+ self ._mac_in_str ,
1294+ states [NodeFeature .ENERGY ],
1295+ )
1296+
1297+ remaining_features : tuple [NodeFeature , ...] = ()
1298+ for feature in features :
1299+ if feature in [NodeFeature .ENERGY , NodeFeature .POWER ]:
1300+ continue
1301+ remaining_features += (feature ,)
1302+
1303+ return remaining_features , states
1304+
1305+ return features , states
1306+
12701307 async def energy_reset_request (self ) -> None :
12711308 """Send an energy-reset to a Node."""
12721309 if self ._node_protocols is None :
0 commit comments