diff --git a/homeassistant/components/duco/sensor.py b/homeassistant/components/duco/sensor.py index dcc9d63d6e52..35159ce63e26 100644 --- a/homeassistant/components/duco/sensor.py +++ b/homeassistant/components/duco/sensor.py @@ -95,7 +95,12 @@ SENSOR_DESCRIPTIONS: tuple[DucoSensorEntityDescription, ...] = ( state_class=SensorStateClass.MEASUREMENT, native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION, value_fn=lambda node: node.sensor.co2 if node.sensor else None, - node_types=(NodeType.UCCO2, NodeType.VLVCO2, NodeType.VLVCO2RH), + node_types=( + NodeType.BSCO2, + NodeType.UCCO2, + NodeType.VLVCO2, + NodeType.VLVCO2RH, + ), ), DucoSensorEntityDescription( key="iaq_co2", @@ -104,7 +109,12 @@ SENSOR_DESCRIPTIONS: tuple[DucoSensorEntityDescription, ...] = ( state_class=SensorStateClass.MEASUREMENT, entity_registry_enabled_default=False, value_fn=lambda node: node.sensor.iaq_co2 if node.sensor else None, - node_types=(NodeType.UCCO2, NodeType.VLVCO2, NodeType.VLVCO2RH), + node_types=( + NodeType.BSCO2, + NodeType.UCCO2, + NodeType.VLVCO2, + NodeType.VLVCO2RH, + ), ), DucoSensorEntityDescription( key="humidity", diff --git a/tests/components/duco/fixtures/dynamic_sensor_nodes.json b/tests/components/duco/fixtures/dynamic_sensor_nodes.json index bdad2a06363c..f51afc483b94 100644 --- a/tests/components/duco/fixtures/dynamic_sensor_nodes.json +++ b/tests/components/duco/fixtures/dynamic_sensor_nodes.json @@ -50,5 +50,31 @@ "iaq_rh": null, "temp": 20.5 } + }, + { + "node_id": 202, + "general": { + "node_type": "BSCO2", + "sub_type": 0, + "network_type": "VIRT", + "parent": 1, + "asso": 1, + "name": "New box co2 sensor", + "identify": 0 + }, + "ventilation": { + "state": "AUTO", + "time_state_remain": 0, + "time_state_end": 0, + "mode": "-", + "flow_lvl_tgt": null + }, + "sensor": { + "co2": 421, + "iaq_co2": 100, + "rh": null, + "iaq_rh": null, + "temp": null + } } ] diff --git a/tests/components/duco/test_sensor.py b/tests/components/duco/test_sensor.py index 2617033421c7..55b591c12c99 100644 --- a/tests/components/duco/test_sensor.py +++ b/tests/components/duco/test_sensor.py @@ -140,23 +140,37 @@ async def test_lan_info_failures_keep_node_entities_available( @pytest.mark.parametrize( - ("node_id", "expected_entity_id", "expected_state"), + ( + "node_id", + "expected_entity_id", + "expected_state", + "expected_disabled_entity_id", + ), [ ( 200, "sensor.new_rh_sensor_humidity", "55.0", + "sensor.new_rh_sensor_humidity_air_quality_index", ), ( 201, "sensor.new_valve_carbon_dioxide", "575", + "sensor.new_valve_co2_air_quality_index", + ), + ( + 202, + "sensor.new_box_co2_sensor_carbon_dioxide", + "421", + "sensor.new_box_co2_sensor_co2_air_quality_index", ), ], ) @pytest.mark.usefixtures("init_integration") async def test_new_node_added_dynamically( hass: HomeAssistant, + entity_registry: er.EntityRegistry, mock_duco_client: AsyncMock, mock_sensor_nodes: list[Node], dynamic_sensor_nodes: dict[int, Node], @@ -164,6 +178,7 @@ async def test_new_node_added_dynamically( node_id: int, expected_entity_id: str, expected_state: str, + expected_disabled_entity_id: str, ) -> None: """Test a new node appearing in coordinator data creates entities automatically.""" assert hass.states.get(expected_entity_id) is None @@ -179,6 +194,10 @@ async def test_new_node_added_dynamically( assert state is not None assert state.state == expected_state + entry = entity_registry.async_get(expected_disabled_entity_id) + assert entry is not None + assert entry.disabled_by == er.RegistryEntryDisabler.INTEGRATION + @pytest.mark.usefixtures("init_integration") async def test_deregistered_node_removes_device(