Fix BSCO2 sensors not being added in Duco (#173794)

This commit is contained in:
Ronald van der Meer
2026-06-15 08:25:50 +02:00
committed by GitHub
parent 07635debda
commit 39fe1479e2
3 changed files with 58 additions and 3 deletions
+12 -2
View File
@@ -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",
@@ -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
}
}
]
+20 -1
View File
@@ -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(