mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 08:17:08 +00:00
Bugfix temp convert on none temp attribute / unittest for that (#3654)
This commit is contained in:
parent
0219df17f5
commit
41aff96375
@ -58,6 +58,12 @@ ATTR_OPERATION_LIST = "operation_list"
|
|||||||
ATTR_SWING_MODE = "swing_mode"
|
ATTR_SWING_MODE = "swing_mode"
|
||||||
ATTR_SWING_LIST = "swing_list"
|
ATTR_SWING_LIST = "swing_list"
|
||||||
|
|
||||||
|
CONVERTIBLE_ATTRIBUTE = [
|
||||||
|
ATTR_TEMPERATURE,
|
||||||
|
ATTR_TARGET_TEMP_LOW,
|
||||||
|
ATTR_TARGET_TEMP_HIGH,
|
||||||
|
]
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
SET_AWAY_MODE_SCHEMA = vol.Schema({
|
SET_AWAY_MODE_SCHEMA = vol.Schema({
|
||||||
@ -239,11 +245,14 @@ def setup(hass, config):
|
|||||||
for climate in target_climate:
|
for climate in target_climate:
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
for value, temp in service.data.items():
|
for value, temp in service.data.items():
|
||||||
kwargs[value] = convert_temperature(
|
if value in CONVERTIBLE_ATTRIBUTE:
|
||||||
temp,
|
kwargs[value] = convert_temperature(
|
||||||
hass.config.units.temperature_unit,
|
temp,
|
||||||
climate.unit_of_measurement
|
hass.config.units.temperature_unit,
|
||||||
)
|
climate.unit_of_measurement
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
kwargs[value] = temp
|
||||||
|
|
||||||
climate.set_temperature(**kwargs)
|
climate.set_temperature(**kwargs)
|
||||||
if climate.should_poll:
|
if climate.should_poll:
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from homeassistant.util.unit_system import (
|
from homeassistant.util.unit_system import (
|
||||||
METRIC_SYSTEM,
|
METRIC_SYSTEM
|
||||||
)
|
)
|
||||||
from homeassistant.bootstrap import setup_component
|
from homeassistant.bootstrap import setup_component
|
||||||
from homeassistant.components import climate
|
from homeassistant.components import climate
|
||||||
@ -12,6 +12,7 @@ from tests.common import get_test_home_assistant
|
|||||||
|
|
||||||
ENTITY_CLIMATE = 'climate.hvac'
|
ENTITY_CLIMATE = 'climate.hvac'
|
||||||
ENTITY_ECOBEE = 'climate.ecobee'
|
ENTITY_ECOBEE = 'climate.ecobee'
|
||||||
|
ENTITY_HEATPUMP = 'climate.heatpump'
|
||||||
|
|
||||||
|
|
||||||
class TestDemoClimate(unittest.TestCase):
|
class TestDemoClimate(unittest.TestCase):
|
||||||
@ -68,6 +69,15 @@ class TestDemoClimate(unittest.TestCase):
|
|||||||
state = self.hass.states.get(ENTITY_CLIMATE)
|
state = self.hass.states.get(ENTITY_CLIMATE)
|
||||||
self.assertEqual(30.0, state.attributes.get('temperature'))
|
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):
|
def test_set_target_temp_range(self):
|
||||||
"""Test the setting of the target temperature with range."""
|
"""Test the setting of the target temperature with range."""
|
||||||
state = self.hass.states.get(ENTITY_ECOBEE)
|
state = self.hass.states.get(ENTITY_ECOBEE)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user