24
24
25
25
logger = logging .getLogger (__name__ )
26
26
27
+ s_feature_strs = {Clusters .DeviceEnergyManagement .Bitmaps .Feature .kPowerAdjustment : "kPowerAdjustment" ,
28
+ Clusters .DeviceEnergyManagement .Bitmaps .Feature .kPowerForecastReporting : "kPowerForecastReporting" ,
29
+ Clusters .DeviceEnergyManagement .Bitmaps .Feature .kStateForecastReporting : "kStateForecastReporting" ,
30
+ Clusters .DeviceEnergyManagement .Bitmaps .Feature .kStartTimeAdjustment : "kStartTimeAdjustment" ,
31
+ Clusters .DeviceEnergyManagement .Bitmaps .Feature .kPausable : "kPausable" ,
32
+ Clusters .DeviceEnergyManagement .Bitmaps .Feature .kForecastAdjustment : "kForecastAdjustment" ,
33
+ Clusters .DeviceEnergyManagement .Bitmaps .Feature .kConstraintBasedAdjustment : "kConstraintBasedAdjustment" }
34
+
27
35
28
36
class DEMTestBase :
29
37
@@ -38,6 +46,26 @@ async def check_dem_attribute(self, attribute, expected_value, endpoint: int = N
38
46
asserts .assert_equal (value , expected_value ,
39
47
f"Unexpected '{ attribute } ' value - expected { expected_value } , was { value } " )
40
48
49
+ async def validate_feature_map (self , must_have_features , must_not_have_features ):
50
+ feature_map = await self .read_dem_attribute_expect_success (attribute = "FeatureMap" )
51
+ for must_have_feature in must_have_features :
52
+ asserts .assert_true (feature_map & must_have_feature ,
53
+ f"{ s_feature_strs [must_have_feature ]} must be set but is not. feature_map 0x{ feature_map :x} " )
54
+
55
+ for must_not_have_feature in must_not_have_features :
56
+ asserts .assert_false (feature_map & must_not_have_feature ,
57
+ f"{ s_feature_strs [must_not_have_feature ]} is not allowed to be set. feature_map 0x{ feature_map :x} " )
58
+
59
+ async def validate_pfr_or_sfr_in_feature_map (self ):
60
+ feature_map = await self .read_dem_attribute_expect_success (attribute = "FeatureMap" )
61
+
62
+ illegal_combination = Clusters .DeviceEnergyManagement .Bitmaps .Feature .kPowerForecastReporting | Clusters .DeviceEnergyManagement .Bitmaps .Feature .kStateForecastReporting
63
+ asserts .assert_not_equal (feature_map & illegal_combination , illegal_combination ,
64
+ f"Cannot have kPowerForecastReporting and kStateForecastReporting both set. feature_map 0x{ feature_map :x} " )
65
+
66
+ asserts .assert_not_equal (feature_map & illegal_combination , 0 ,
67
+ f"Must have one of kPowerForecastReporting and kStateForecastReporting set. feature_map 0x{ feature_map :x} " )
68
+
41
69
async def send_power_adjustment_command (self , power : int , duration : int ,
42
70
cause : Clusters .Objects .DeviceEnergyManagement .Enums .CauseEnum ,
43
71
endpoint : int = None , timedRequestTimeoutMs : int = 3000 ,
0 commit comments