diff --git a/tests/components/bsblan/conftest.py b/tests/components/bsblan/conftest.py index c0aa40adbf2c21..331d7881a53f97 100644 --- a/tests/components/bsblan/conftest.py +++ b/tests/components/bsblan/conftest.py @@ -56,6 +56,14 @@ def mock_bsblan(request: pytest.FixtureRequest) -> Generator[MagicMock, None, No bsblan.static_values.return_value = StaticState.from_json( load_fixture(request.param, DOMAIN) ) + + # Add a method to update the current_temperature dynamically + def set_current_temperature(value): + state = bsblan.state.return_value + state.current_temperature.value = value + + bsblan.set_current_temperature = set_current_temperature + yield bsblan diff --git a/tests/components/bsblan/test_climate.py b/tests/components/bsblan/test_climate.py index 0c9524413e6a7c..cc738c06d4dd09 100644 --- a/tests/components/bsblan/test_climate.py +++ b/tests/components/bsblan/test_climate.py @@ -24,3 +24,15 @@ async def test_climate_entity( await setup_with_selected_platforms(hass, mock_config_entry, [Platform.CLIMATE]) await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id) + + # Spoof the current_temperature value to "---" + mock_bsblan.set_current_temperature("---") + + # Update the state in Home Assistant + await hass.helpers.entity_component.async_update_entity("climate.bsb_lan") + + # Get the state of the climate entity + state = hass.states.get("climate.bsb_lan") + + # Assert that the current_temperature attribute is None + assert state.attributes["current_temperature"] is None