mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Away mode temperature fix for generic thermostat (#17641)
* Resolves /home-assistant/home-assistant#17433 Away mode temperature issue fix for generic_thermostat * Debug messages removed from generic_thermostat.py * Test for repeat away_mode set Test for fix of generic thermostat issue when away_mode was set several times in a row. * Code style fix in generic_thermostat * Remove blank line in the end of generic_thermostat * Fix style
This commit is contained in:
parent
ad3d0c4e99
commit
324587b2db
@ -380,6 +380,8 @@ class GenericThermostat(ClimateDevice):
|
||||
|
||||
async def async_turn_away_mode_on(self):
|
||||
"""Turn away mode on by setting it on away hold indefinitely."""
|
||||
if self._is_away:
|
||||
return
|
||||
self._is_away = True
|
||||
self._saved_target_temp = self._target_temp
|
||||
self._target_temp = self._away_temp
|
||||
@ -388,6 +390,8 @@ class GenericThermostat(ClimateDevice):
|
||||
|
||||
async def async_turn_away_mode_off(self):
|
||||
"""Turn away off."""
|
||||
if not self._is_away:
|
||||
return
|
||||
self._is_away = False
|
||||
self._target_temp = self._saved_target_temp
|
||||
await self._async_control_heating()
|
||||
|
@ -221,6 +221,24 @@ class TestClimateGenericThermostat(unittest.TestCase):
|
||||
state = self.hass.states.get(ENTITY)
|
||||
self.assertEqual(23, state.attributes.get('temperature'))
|
||||
|
||||
def test_set_away_mode_twice_and_restore_prev_temp(self):
|
||||
"""Test the setting away mode twice in a row.
|
||||
|
||||
Verify original temperature is restored.
|
||||
"""
|
||||
common.set_temperature(self.hass, 23)
|
||||
self.hass.block_till_done()
|
||||
common.set_away_mode(self.hass, True)
|
||||
self.hass.block_till_done()
|
||||
common.set_away_mode(self.hass, True)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY)
|
||||
self.assertEqual(16, state.attributes.get('temperature'))
|
||||
common.set_away_mode(self.hass, False)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY)
|
||||
self.assertEqual(23, state.attributes.get('temperature'))
|
||||
|
||||
def test_sensor_bad_value(self):
|
||||
"""Test sensor that have None as state."""
|
||||
state = self.hass.states.get(ENTITY)
|
||||
|
Loading…
x
Reference in New Issue
Block a user