Address late review for whirlpool (#93874)

Address late review
This commit is contained in:
mkmer 2023-05-31 18:21:13 -04:00 committed by GitHub
parent e272e3c721
commit 198608906c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -296,9 +296,9 @@ class WasherDryerTimeClass(RestoreSensor):
) )
if ( if (
isinstance(self._attr_native_value, datetime) self._attr_native_value is None
or isinstance(self._attr_native_value, datetime)
and abs(new_timestamp - self._attr_native_value) > timedelta(seconds=60) and abs(new_timestamp - self._attr_native_value) > timedelta(seconds=60)
or self._attr_native_value is None
): ):
self._attr_native_value = new_timestamp self._attr_native_value = new_timestamp
self._async_write_ha_state() self._async_write_ha_state()

View File

@ -311,10 +311,11 @@ async def test_no_restore_state(
await init_integration(hass) await init_integration(hass)
# restore from cache # restore from cache
state = hass.states.get(entity_id) state = hass.states.get(entity_id)
state.state = "unknown" assert state.state == "unknown"
mock_sensor1_api.get_machine_state.return_value = MachineState.RunningMainCycle
state = await update_sensor_state(hass, entity_id, mock_sensor1_api) state = await update_sensor_state(hass, entity_id, mock_sensor1_api)
state.state = datetime.now().isoformat() assert state.state != "unknown"
async def test_callback( async def test_callback(