Bugfix temp convert on none temp attribute / unittest for that (#3654)
This commit is contained in:
parent
0219df17f5
commit
41aff96375
2 changed files with 25 additions and 6 deletions
|
@ -58,6 +58,12 @@ ATTR_OPERATION_LIST = "operation_list"
|
|||
ATTR_SWING_MODE = "swing_mode"
|
||||
ATTR_SWING_LIST = "swing_list"
|
||||
|
||||
CONVERTIBLE_ATTRIBUTE = [
|
||||
ATTR_TEMPERATURE,
|
||||
ATTR_TARGET_TEMP_LOW,
|
||||
ATTR_TARGET_TEMP_HIGH,
|
||||
]
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
SET_AWAY_MODE_SCHEMA = vol.Schema({
|
||||
|
@ -239,11 +245,14 @@ def setup(hass, config):
|
|||
for climate in target_climate:
|
||||
kwargs = {}
|
||||
for value, temp in service.data.items():
|
||||
if value in CONVERTIBLE_ATTRIBUTE:
|
||||
kwargs[value] = convert_temperature(
|
||||
temp,
|
||||
hass.config.units.temperature_unit,
|
||||
climate.unit_of_measurement
|
||||
)
|
||||
else:
|
||||
kwargs[value] = temp
|
||||
|
||||
climate.set_temperature(**kwargs)
|
||||
if climate.should_poll:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import unittest
|
||||
|
||||
from homeassistant.util.unit_system import (
|
||||
METRIC_SYSTEM,
|
||||
METRIC_SYSTEM
|
||||
)
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from homeassistant.components import climate
|
||||
|
@ -12,6 +12,7 @@ from tests.common import get_test_home_assistant
|
|||
|
||||
ENTITY_CLIMATE = 'climate.hvac'
|
||||
ENTITY_ECOBEE = 'climate.ecobee'
|
||||
ENTITY_HEATPUMP = 'climate.heatpump'
|
||||
|
||||
|
||||
class TestDemoClimate(unittest.TestCase):
|
||||
|
@ -68,6 +69,15 @@ class TestDemoClimate(unittest.TestCase):
|
|||
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||
self.assertEqual(30.0, state.attributes.get('temperature'))
|
||||
|
||||
def test_set_only_target_temp_with_convert(self):
|
||||
"""Test the setting of the target temperature."""
|
||||
state = self.hass.states.get(ENTITY_HEATPUMP)
|
||||
self.assertEqual(20, state.attributes.get('temperature'))
|
||||
climate.set_temperature(self.hass, 21, ENTITY_HEATPUMP)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_HEATPUMP)
|
||||
self.assertEqual(21.0, state.attributes.get('temperature'))
|
||||
|
||||
def test_set_target_temp_range(self):
|
||||
"""Test the setting of the target temperature with range."""
|
||||
state = self.hass.states.get(ENTITY_ECOBEE)
|
||||
|
|
Loading…
Add table
Reference in a new issue