From 0fba58bb296ee563e7836eaa9b5f7669fccd082f Mon Sep 17 00:00:00 2001 From: Simone Chemelli Date: Sat, 29 Aug 2026 18:39:00 +0200 Subject: [PATCH] Add 100% coverage to binary_sensor in Midea (#180642) --- tests/components/midea/test_binary_sensor.py | 26 ++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/components/midea/test_binary_sensor.py b/tests/components/midea/test_binary_sensor.py index 7d0efb2cc962..f3a9c27f6d40 100644 --- a/tests/components/midea/test_binary_sensor.py +++ b/tests/components/midea/test_binary_sensor.py @@ -115,3 +115,29 @@ async def test_binary_sensor_state_update( state = hass.states.get(entity_entry.entity_id) assert state is not None assert state.state == "on" + + +async def test_binary_sensor_unknown_for_non_bool_value( + hass: HomeAssistant, + mock_config_entry: Callable[[DummyDevice], MockConfigEntry], +) -> None: + """Test binary_sensor is unknown when the device reports a non-bool value.""" + device = DummyDevice( + DeviceType.AC, + attributes={ + ACAttributes.power: True, + ACAttributes.mode: 1, + ACAttributes.target_temperature: 22.0, + ACAttributes.indoor_temperature: 21.0, + ACAttributes.full_dust: None, + }, + ) + config_entry = mock_config_entry(device) + with patch("homeassistant.components.midea._PLATFORMS", [Platform.BINARY_SENSOR]): + await setup_integration(hass, config_entry, device) + + entity_entry = entity_entries(hass, config_entry)[f"{TEST_DEVICE_ID}_full_dust"] + + state = hass.states.get(entity_entry.entity_id) + assert state is not None + assert state.state == "unknown"