diff --git a/tests/components/shelly/test_climate.py b/tests/components/shelly/test_climate.py index c6646bf5d8f5..b9763d43f477 100644 --- a/tests/components/shelly/test_climate.py +++ b/tests/components/shelly/test_climate.py @@ -34,7 +34,10 @@ from homeassistant.components.climate import ( HVACMode, ) from homeassistant.components.humidifier import ATTR_HUMIDITY -from homeassistant.components.shelly.climate import PRESET_FROST_PROTECTION +from homeassistant.components.shelly.climate import ( + PRESET_FROST_PROTECTION, + ShellyClimateExtraStoredData, +) from homeassistant.components.shelly.const import ( DOMAIN, MODEL_LINKEDGO_ST802_THERMOSTAT, @@ -318,6 +321,10 @@ async def test_block_restored_climate( monkeypatch.delattr(mock_block_device.blocks[EMETER_BLOCK_ID], "targetTemp") entry = await init_integration(hass, 1, sleep_period=1000, skip_setup=True) device = register_device(device_registry, entry) + # Non-climate entities of the entry are skipped when restoring + register_entity( + hass, SWITCH_DOMAIN, "test_switch", "relay_0", entry, device_id=device.id + ) entity_id = register_entity( hass, CLIMATE_DOMAIN, @@ -606,6 +613,22 @@ async def test_block_restored_climate_temperature_unit( assert saved[entity_id]["last_target_temp"] == expected_heat_target +def test_extra_stored_data_without_last_target_temp() -> None: + """Test extra stored data without the last target temperature is rejected.""" + assert ( + ShellyClimateExtraStoredData.from_dict( + { + "native_current_temperature": 18.0, + "native_target_temperature": 20.0, + "native_target_temperature_high": None, + "native_target_temperature_low": None, + "native_temperature_unit": UnitOfTemperature.CELSIUS, + } + ) + is None + ) + + async def test_block_restored_climate_no_last_state( hass: HomeAssistant, mock_block_device: Mock,