mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Change generic thermostat to control heating on mode change Off -> Auto (#10601)
* Change generic thermostat to control heating on mode change Off -> Auto * Fix typo
This commit is contained in:
parent
3dbae5ca5b
commit
79ca93f892
@ -163,6 +163,7 @@ class GenericThermostat(ClimateDevice):
|
|||||||
"""Set operation mode."""
|
"""Set operation mode."""
|
||||||
if operation_mode == STATE_AUTO:
|
if operation_mode == STATE_AUTO:
|
||||||
self._enabled = True
|
self._enabled = True
|
||||||
|
self._async_control_heating()
|
||||||
elif operation_mode == STATE_OFF:
|
elif operation_mode == STATE_OFF:
|
||||||
self._enabled = False
|
self._enabled = False
|
||||||
if self._is_device_active:
|
if self._is_device_active:
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
"""The tests for the generic_thermostat."""
|
"""The tests for the generic_thermostat."""
|
||||||
import asyncio
|
import asyncio
|
||||||
import datetime
|
import datetime
|
||||||
import pytz
|
|
||||||
import unittest
|
import unittest
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
import pytz
|
||||||
|
|
||||||
import homeassistant.core as ha
|
import homeassistant.core as ha
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
@ -54,13 +54,16 @@ class TestSetupClimateGenericThermostat(unittest.TestCase):
|
|||||||
'climate': config})
|
'climate': config})
|
||||||
|
|
||||||
def test_valid_conf(self):
|
def test_valid_conf(self):
|
||||||
"""Test set up genreic_thermostat with valid config values."""
|
"""Test set up generic_thermostat with valid config values."""
|
||||||
self.assertTrue(setup_component(self.hass, 'climate',
|
self.assertTrue(
|
||||||
{'climate': {
|
setup_component(self.hass, 'climate',
|
||||||
'platform': 'generic_thermostat',
|
{'climate': {
|
||||||
'name': 'test',
|
'platform': 'generic_thermostat',
|
||||||
'heater': ENT_SWITCH,
|
'name': 'test',
|
||||||
'target_sensor': ENT_SENSOR}}))
|
'heater': ENT_SWITCH,
|
||||||
|
'target_sensor': ENT_SENSOR
|
||||||
|
}})
|
||||||
|
)
|
||||||
|
|
||||||
def test_setup_with_sensor(self):
|
def test_setup_with_sensor(self):
|
||||||
"""Test set up heat_control with sensor to trigger update at init."""
|
"""Test set up heat_control with sensor to trigger update at init."""
|
||||||
@ -243,6 +246,31 @@ class TestClimateGenericThermostat(unittest.TestCase):
|
|||||||
self.hass.block_till_done()
|
self.hass.block_till_done()
|
||||||
self.assertEqual(0, len(self.calls))
|
self.assertEqual(0, len(self.calls))
|
||||||
|
|
||||||
|
@mock.patch('logging.Logger.error')
|
||||||
|
def test_invalid_operating_mode(self, log_mock):
|
||||||
|
"""Test error handling for invalid operation mode."""
|
||||||
|
climate.set_operation_mode(self.hass, 'invalid mode')
|
||||||
|
self.hass.block_till_done()
|
||||||
|
self.assertEqual(log_mock.call_count, 1)
|
||||||
|
|
||||||
|
def test_operating_mode_auto(self):
|
||||||
|
"""Test change mode from OFF to AUTO.
|
||||||
|
|
||||||
|
Switch turns on when temp below setpoint and mode changes.
|
||||||
|
"""
|
||||||
|
climate.set_operation_mode(self.hass, STATE_OFF)
|
||||||
|
climate.set_temperature(self.hass, 30)
|
||||||
|
self._setup_sensor(25)
|
||||||
|
self.hass.block_till_done()
|
||||||
|
self._setup_switch(False)
|
||||||
|
climate.set_operation_mode(self.hass, climate.STATE_AUTO)
|
||||||
|
self.hass.block_till_done()
|
||||||
|
self.assertEqual(1, len(self.calls))
|
||||||
|
call = self.calls[0]
|
||||||
|
self.assertEqual('switch', call.domain)
|
||||||
|
self.assertEqual(SERVICE_TURN_ON, call.service)
|
||||||
|
self.assertEqual(ENT_SWITCH, call.data['entity_id'])
|
||||||
|
|
||||||
def _setup_sensor(self, temp, unit=TEMP_CELSIUS):
|
def _setup_sensor(self, temp, unit=TEMP_CELSIUS):
|
||||||
"""Setup the test sensor."""
|
"""Setup the test sensor."""
|
||||||
self.hass.states.set(ENT_SENSOR, temp, {
|
self.hass.states.set(ENT_SENSOR, temp, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user