From 62854e4d9cb2c8cc8ab92c0a68a1c235866eeb0e Mon Sep 17 00:00:00 2001 From: Bartlomiej Kobus Date: Tue, 5 May 2026 12:44:51 +0000 Subject: [PATCH 1/5] blebox: add support for inputSensor devices --- homeassistant/components/blebox/binary_sensor.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/homeassistant/components/blebox/binary_sensor.py b/homeassistant/components/blebox/binary_sensor.py index b9032e6e70582f..55e1b17b56c66a 100644 --- a/homeassistant/components/blebox/binary_sensor.py +++ b/homeassistant/components/blebox/binary_sensor.py @@ -18,6 +18,10 @@ key="moisture", device_class=BinarySensorDeviceClass.MOISTURE, ), + BinarySensorEntityDescription( + key="input", + device_class=None, + ), ) From 4c7bc96899a140a40e4decaaac49e7f0c6dc24f2 Mon Sep 17 00:00:00 2001 From: Bartlomiej Kobus Date: Mon, 25 May 2026 11:20:53 +0000 Subject: [PATCH 2/5] Remove redundant device_class=None from input BinarySensorEntityDescription --- homeassistant/components/blebox/binary_sensor.py | 1 - 1 file changed, 1 deletion(-) diff --git a/homeassistant/components/blebox/binary_sensor.py b/homeassistant/components/blebox/binary_sensor.py index 55e1b17b56c66a..795b17fdcd621b 100644 --- a/homeassistant/components/blebox/binary_sensor.py +++ b/homeassistant/components/blebox/binary_sensor.py @@ -20,7 +20,6 @@ ), BinarySensorEntityDescription( key="input", - device_class=None, ), ) From 52cb3ffc51cf152103d7ab587ff57f56e5e5e8f8 Mon Sep 17 00:00:00 2001 From: Bartlomiej Kobus Date: Mon, 25 May 2026 11:32:06 +0000 Subject: [PATCH 3/5] Add test coverage for input binary sensor entity --- tests/components/blebox/test_binary_sensor.py | 70 ++++++++++++++++--- 1 file changed, 61 insertions(+), 9 deletions(-) diff --git a/tests/components/blebox/test_binary_sensor.py b/tests/components/blebox/test_binary_sensor.py index 79da8b41ee4098..0faf0c5b76fd9d 100644 --- a/tests/components/blebox/test_binary_sensor.py +++ b/tests/components/blebox/test_binary_sensor.py @@ -29,20 +29,72 @@ def airsensor_fixture() -> tuple[AsyncMock, str]: return feature, "binary_sensor.my_rain_sensor_windrainsensor_0_rain" +@pytest.fixture(name="inputsensor") +def inputsensor_fixture() -> tuple[AsyncMock, str]: + """Return a default inputSensor fixture.""" + feature: AsyncMock = mock_feature( + "binary_sensors", + blebox_uniapi.binary_sensor.Input, + unique_id="BleBox-inputSensorD-aa11bb22cc33-0.input", + full_name="inputSensorD-0.input", + device_class="input", + ) + product = feature.product + type(product).name = PropertyMock(return_value="My input sensor") + type(product).model = PropertyMock(return_value="inputSensorD") + return feature, "binary_sensor.my_input_sensor_inputsensord_0_input" + + +@pytest.mark.parametrize( + ( + "fixture_name", + "entity_id", + "unique_id", + "expected_name", + "expected_device_class", + "expected_state", + ), + [ + pytest.param( + "rainsensor", + "binary_sensor.my_rain_sensor_windrainsensor_0_rain", + "BleBox-windRainSensor-ea68e74f4f49-0.rain", + "My rain sensor windRainSensor-0.rain", + BinarySensorDeviceClass.MOISTURE, + STATE_ON, + id="moisture", + ), + pytest.param( + "inputsensor", + "binary_sensor.my_input_sensor_inputsensord_0_input", + "BleBox-inputSensorD-aa11bb22cc33-0.input", + "My input sensor inputSensorD-0.input", + None, + STATE_ON, + id="input", + ), + ], +) async def test_init( - rainsensor: AsyncMock, device_registry: dr.DeviceRegistry, hass: HomeAssistant + fixture_name: str, + entity_id: str, + unique_id: str, + expected_name: str, + expected_device_class: BinarySensorDeviceClass | None, + expected_state: str, + device_registry: dr.DeviceRegistry, + hass: HomeAssistant, + request: pytest.FixtureRequest, ) -> None: """Test binary_sensor initialisation.""" - _, entity_id = rainsensor + request.getfixturevalue(fixture_name) entry = await async_setup_entity(hass, entity_id) - assert entry.unique_id == "BleBox-windRainSensor-ea68e74f4f49-0.rain" + assert entry.unique_id == unique_id state = hass.states.get(entity_id) - assert state.name == "My rain sensor windRainSensor-0.rain" - - assert state.attributes[ATTR_DEVICE_CLASS] == BinarySensorDeviceClass.MOISTURE - assert state.state == STATE_ON + assert state.name == expected_name + assert state.attributes.get(ATTR_DEVICE_CLASS) == expected_device_class + assert state.state == expected_state device = device_registry.async_get(entry.device_id) - - assert device.name == "My rain sensor" + assert device is not None From 5d8eab820817844c5fc4879dede1b6ed5eb82389 Mon Sep 17 00:00:00 2001 From: Bartlomiej Kobus Date: Mon, 25 May 2026 11:38:48 +0000 Subject: [PATCH 4/5] derive entity_id from fixture and assert device name --- tests/components/blebox/test_binary_sensor.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/components/blebox/test_binary_sensor.py b/tests/components/blebox/test_binary_sensor.py index 0faf0c5b76fd9d..d421a3e277c779 100644 --- a/tests/components/blebox/test_binary_sensor.py +++ b/tests/components/blebox/test_binary_sensor.py @@ -48,46 +48,46 @@ def inputsensor_fixture() -> tuple[AsyncMock, str]: @pytest.mark.parametrize( ( "fixture_name", - "entity_id", "unique_id", "expected_name", "expected_device_class", "expected_state", + "expected_device_name", ), [ pytest.param( "rainsensor", - "binary_sensor.my_rain_sensor_windrainsensor_0_rain", "BleBox-windRainSensor-ea68e74f4f49-0.rain", "My rain sensor windRainSensor-0.rain", BinarySensorDeviceClass.MOISTURE, STATE_ON, + "My rain sensor", id="moisture", ), pytest.param( "inputsensor", - "binary_sensor.my_input_sensor_inputsensord_0_input", "BleBox-inputSensorD-aa11bb22cc33-0.input", "My input sensor inputSensorD-0.input", None, STATE_ON, + "My input sensor", id="input", ), ], ) async def test_init( fixture_name: str, - entity_id: str, unique_id: str, expected_name: str, expected_device_class: BinarySensorDeviceClass | None, expected_state: str, + expected_device_name: str, device_registry: dr.DeviceRegistry, hass: HomeAssistant, request: pytest.FixtureRequest, ) -> None: """Test binary_sensor initialisation.""" - request.getfixturevalue(fixture_name) + _, entity_id = request.getfixturevalue(fixture_name) entry = await async_setup_entity(hass, entity_id) assert entry.unique_id == unique_id @@ -97,4 +97,4 @@ async def test_init( assert state.state == expected_state device = device_registry.async_get(entry.device_id) - assert device is not None + assert device.name == expected_device_name From 4d1751fcd08acafb2a77097fdd79877b05156d32 Mon Sep 17 00:00:00 2001 From: Bartlomiej Kobus Date: Wed, 27 May 2026 06:41:42 +0000 Subject: [PATCH 5/5] Move hass to be first parameter --- tests/components/blebox/test_binary_sensor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/components/blebox/test_binary_sensor.py b/tests/components/blebox/test_binary_sensor.py index d421a3e277c779..ab427b4acf939f 100644 --- a/tests/components/blebox/test_binary_sensor.py +++ b/tests/components/blebox/test_binary_sensor.py @@ -76,6 +76,7 @@ def inputsensor_fixture() -> tuple[AsyncMock, str]: ], ) async def test_init( + hass: HomeAssistant, fixture_name: str, unique_id: str, expected_name: str, @@ -83,7 +84,6 @@ async def test_init( expected_state: str, expected_device_name: str, device_registry: dr.DeviceRegistry, - hass: HomeAssistant, request: pytest.FixtureRequest, ) -> None: """Test binary_sensor initialisation."""