@@ -237,60 +237,53 @@ def test_flap_valve_enum_value(self, coordinator: EconextCoordinator) -> None:
237237 assert sensor .native_value == "ch"
238238 assert sensor ._attr_options == ["ch" , "dhw" , "unknown" ]
239239
240- def test_active_operating_mode_handles_value_4 (self , coordinator : EconextCoordinator ) -> None :
241- """Test active_operating_mode enum handles value 4 (heating)."""
242- from custom_components .econext .const import ACTIVE_MODE_MAPPING , ACTIVE_MODE_OPTIONS
240+ def _active_mode_sensor (self , coordinator : EconextCoordinator , mode : int , flap : int ):
241+ """Build an active_operating_mode sensor with param 495 and flap valve 83 set."""
242+ from custom_components .econext .const import ACTIVE_MODE_OPTIONS
243+ from custom_components .econext .sensor import EconextActiveOperatingModeSensor
243244
244- coordinator .data ["495" ]["value" ] = 4
245+ coordinator .data ["495" ]["value" ] = mode
246+ coordinator .data ["83" ] = {"value" : flap , "name" : "flapValveStates" , "info" : 23 }
245247
246248 description = EconextSensorEntityDescription (
247249 key = "active_operating_mode" ,
248250 param_id = "495" ,
249251 device_class = SensorDeviceClass .ENUM ,
250252 options = ACTIVE_MODE_OPTIONS ,
251- value_map = ACTIVE_MODE_MAPPING ,
252253 )
254+ return EconextActiveOperatingModeSensor (coordinator , description )
253255
254- sensor = EconextSensor (coordinator , description )
255-
256+ def test_active_operating_mode_winter_heating (self , coordinator : EconextCoordinator ) -> None :
257+ """Value 4 (winter + heating bit), flap on CH -> heating."""
258+ sensor = self ._active_mode_sensor (coordinator , mode = 4 , flap = 0 )
256259 assert sensor .native_value == "heating"
257260 assert "heating" in sensor ._attr_options
258261
259- def test_active_operating_mode_standby (self , coordinator : EconextCoordinator ) -> None :
260- """Test active_operating_mode enum returns standby for value 0."""
261- from custom_components .econext .const import ACTIVE_MODE_MAPPING , ACTIVE_MODE_OPTIONS
262-
263- coordinator .data ["495" ]["value" ] = 0
264-
265- description = EconextSensorEntityDescription (
266- key = "active_operating_mode" ,
267- param_id = "495" ,
268- device_class = SensorDeviceClass .ENUM ,
269- options = ACTIVE_MODE_OPTIONS ,
270- value_map = ACTIVE_MODE_MAPPING ,
271- )
272-
273- sensor = EconextSensor (coordinator , description )
262+ def test_active_operating_mode_winter_idle_standby (self , coordinator : EconextCoordinator ) -> None :
263+ """Value 0 (winter idle, no bits) -> standby."""
264+ sensor = self ._active_mode_sensor (coordinator , mode = 0 , flap = 0 )
265+ assert sensor .native_value == "standby"
274266
267+ def test_active_operating_mode_summer_idle_standby (self , coordinator : EconextCoordinator ) -> None :
268+ """Value 1 (summer season bit only, HP idle) -> standby."""
269+ sensor = self ._active_mode_sensor (coordinator , mode = 1 , flap = 0 )
275270 assert sensor .native_value == "standby"
276271
277272 def test_active_operating_mode_cooling (self , coordinator : EconextCoordinator ) -> None :
278- """Test active_operating_mode enum returns cooling for value 3."""
279- from custom_components .econext .const import ACTIVE_MODE_MAPPING , ACTIVE_MODE_OPTIONS
280-
281- coordinator .data ["495" ]["value" ] = 3
282-
283- description = EconextSensorEntityDescription (
284- key = "active_operating_mode" ,
285- param_id = "495" ,
286- device_class = SensorDeviceClass .ENUM ,
287- options = ACTIVE_MODE_OPTIONS ,
288- value_map = ACTIVE_MODE_MAPPING ,
289- )
273+ """Value 3 (summer + cooling bit) -> cooling."""
274+ sensor = self ._active_mode_sensor (coordinator , mode = 3 , flap = 0 )
275+ assert sensor .native_value == "cooling"
290276
291- sensor = EconextSensor (coordinator , description )
277+ def test_active_operating_mode_dhw (self , coordinator : EconextCoordinator ) -> None :
278+ """Value 5 (heating bit) with flap routed to DHW -> dhw."""
279+ sensor = self ._active_mode_sensor (coordinator , mode = 5 , flap = 3 )
280+ assert sensor .native_value == "dhw"
281+ assert "dhw" in sensor ._attr_options
292282
293- assert sensor .native_value == "cooling"
283+ def test_active_operating_mode_heating_flap_on_ch (self , coordinator : EconextCoordinator ) -> None :
284+ """Heating bit set but flap on CH -> heating, not dhw."""
285+ sensor = self ._active_mode_sensor (coordinator , mode = 5 , flap = 0 )
286+ assert sensor .native_value == "heating"
294287
295288 def test_enum_sensor_unmapped_value_returns_unknown (self , coordinator : EconextCoordinator ) -> None :
296289 """Test enum sensor returns 'unknown' for unmapped values (e.g., 65336)."""
@@ -410,16 +403,16 @@ def test_decode_current_season_helper(self) -> None:
410403
411404 def test_enum_sensor_unmapped_value_logs_warning (self , coordinator : EconextCoordinator , caplog : pytest .LogCaptureFixture ) -> None :
412405 """Test enum sensor logs a warning with the raw value for unmapped values."""
413- from custom_components .econext .const import ACTIVE_MODE_MAPPING , ACTIVE_MODE_OPTIONS
406+ from custom_components .econext .const import HP_STATUS_WORK_MODE_MAPPING , HP_STATUS_WORK_MODE_OPTIONS
414407
415- coordinator .data ["495" ][ "value" ] = 99
408+ coordinator .data ["1350" ] = { "value" : 99 , "name" : "HPStatusWorkMode" , "info" : 23 }
416409
417410 description = EconextSensorEntityDescription (
418- key = "active_operating_mode " ,
419- param_id = "495 " ,
411+ key = "hp_status_work_mode " ,
412+ param_id = "1350 " ,
420413 device_class = SensorDeviceClass .ENUM ,
421- options = ACTIVE_MODE_OPTIONS ,
422- value_map = ACTIVE_MODE_MAPPING ,
414+ options = HP_STATUS_WORK_MODE_OPTIONS ,
415+ value_map = HP_STATUS_WORK_MODE_MAPPING ,
423416 )
424417
425418 sensor = EconextSensor (coordinator , description )
@@ -429,7 +422,7 @@ def test_enum_sensor_unmapped_value_logs_warning(self, coordinator: EconextCoord
429422
430423 assert result == "unknown"
431424 assert "Unmapped value 99" in caplog .text
432- assert "active_operating_mode " in caplog .text
425+ assert "hp_status_work_mode " in caplog .text
433426
434427
435428class TestSensorEntityCategory :
0 commit comments