mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Fix demo platform support (#12070)
* Fixing demo platform to use support_flags * Fixed tests as well * Moved humidity low / high as always available based on defaults * Updated demo platform to show more combinations
This commit is contained in:
parent
cab6c694c5
commit
3e41422caa
@ -14,23 +14,19 @@ from homeassistant.components.climate import (
|
||||
SUPPORT_ON_OFF)
|
||||
from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT, ATTR_TEMPERATURE
|
||||
|
||||
SUPPORT_FLAGS = (SUPPORT_TARGET_TEMPERATURE | SUPPORT_TARGET_HUMIDITY |
|
||||
SUPPORT_TARGET_HUMIDITY_LOW | SUPPORT_TARGET_HUMIDITY_HIGH |
|
||||
SUPPORT_AWAY_MODE | SUPPORT_HOLD_MODE | SUPPORT_FAN_MODE |
|
||||
SUPPORT_OPERATION_MODE | SUPPORT_AUX_HEAT |
|
||||
SUPPORT_SWING_MODE | SUPPORT_TARGET_TEMPERATURE_HIGH |
|
||||
SUPPORT_TARGET_TEMPERATURE_LOW | SUPPORT_ON_OFF)
|
||||
SUPPORT_FLAGS = SUPPORT_TARGET_HUMIDITY_LOW | SUPPORT_TARGET_HUMIDITY_HIGH
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Set up the Demo climate devices."""
|
||||
add_devices([
|
||||
DemoClimate('HeatPump', 68, TEMP_FAHRENHEIT, None, None, 77,
|
||||
'Auto Low', None, None, 'Auto', 'heat', None, None, None),
|
||||
None, None, None, None, 'heat', None, None,
|
||||
None, True),
|
||||
DemoClimate('Hvac', 21, TEMP_CELSIUS, True, None, 22, 'On High',
|
||||
67, 54, 'Off', 'cool', False, None, None),
|
||||
DemoClimate('Ecobee', None, TEMP_CELSIUS, None, None, 23, 'Auto Low',
|
||||
None, None, 'Auto', 'auto', None, 24, 21)
|
||||
67, 54, 'Off', 'cool', False, None, None, None),
|
||||
DemoClimate('Ecobee', None, TEMP_CELSIUS, None, 'home', 23, 'Auto Low',
|
||||
None, None, 'Auto', 'auto', None, 24, 21, None)
|
||||
])
|
||||
|
||||
|
||||
@ -40,9 +36,37 @@ class DemoClimate(ClimateDevice):
|
||||
def __init__(self, name, target_temperature, unit_of_measurement,
|
||||
away, hold, current_temperature, current_fan_mode,
|
||||
target_humidity, current_humidity, current_swing_mode,
|
||||
current_operation, aux, target_temp_high, target_temp_low):
|
||||
current_operation, aux, target_temp_high, target_temp_low,
|
||||
is_on):
|
||||
"""Initialize the climate device."""
|
||||
self._name = name
|
||||
self._support_flags = SUPPORT_FLAGS
|
||||
if target_temperature is not None:
|
||||
self._support_flags = \
|
||||
self._support_flags | SUPPORT_TARGET_TEMPERATURE
|
||||
if away is not None:
|
||||
self._support_flags = self._support_flags | SUPPORT_AWAY_MODE
|
||||
if hold is not None:
|
||||
self._support_flags = self._support_flags | SUPPORT_HOLD_MODE
|
||||
if current_fan_mode is not None:
|
||||
self._support_flags = self._support_flags | SUPPORT_FAN_MODE
|
||||
if target_humidity is not None:
|
||||
self._support_flags = \
|
||||
self._support_flags | SUPPORT_TARGET_HUMIDITY
|
||||
if current_swing_mode is not None:
|
||||
self._support_flags = self._support_flags | SUPPORT_SWING_MODE
|
||||
if current_operation is not None:
|
||||
self._support_flags = self._support_flags | SUPPORT_OPERATION_MODE
|
||||
if aux is not None:
|
||||
self._support_flags = self._support_flags | SUPPORT_AUX_HEAT
|
||||
if target_temp_high is not None:
|
||||
self._support_flags = \
|
||||
self._support_flags | SUPPORT_TARGET_TEMPERATURE_HIGH
|
||||
if target_temp_low is not None:
|
||||
self._support_flags = \
|
||||
self._support_flags | SUPPORT_TARGET_TEMPERATURE_LOW
|
||||
if is_on is not None:
|
||||
self._support_flags = self._support_flags | SUPPORT_ON_OFF
|
||||
self._target_temperature = target_temperature
|
||||
self._target_humidity = target_humidity
|
||||
self._unit_of_measurement = unit_of_measurement
|
||||
@ -59,12 +83,12 @@ class DemoClimate(ClimateDevice):
|
||||
self._swing_list = ['Auto', '1', '2', '3', 'Off']
|
||||
self._target_temperature_high = target_temp_high
|
||||
self._target_temperature_low = target_temp_low
|
||||
self._on = True
|
||||
self._on = is_on
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Return the list of supported features."""
|
||||
return SUPPORT_FLAGS
|
||||
return self._support_flags
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
|
@ -224,10 +224,10 @@ class TestDemoClimate(unittest.TestCase):
|
||||
|
||||
def test_set_hold_mode_none(self):
|
||||
"""Test setting the hold mode off/false."""
|
||||
climate.set_hold_mode(self.hass, None, ENTITY_ECOBEE)
|
||||
climate.set_hold_mode(self.hass, 'off', ENTITY_ECOBEE)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_ECOBEE)
|
||||
self.assertEqual(None, state.attributes.get('hold_mode'))
|
||||
self.assertEqual('off', state.attributes.get('hold_mode'))
|
||||
|
||||
def test_set_aux_heat_bad_attr(self):
|
||||
"""Test setting the auxiliary heater without required attribute."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user