mirror of
https://github.com/home-assistant/core.git
synced 2026-05-04 03:51:12 +02:00
Turn on device before setting mode (#25314)
This commit is contained in:
committed by
Paulus Schoutsen
parent
fd2d6c8a74
commit
752d0deb97
@@ -293,6 +293,23 @@ async def test_set_hvac_mode(hass, thermostat, air_conditioner):
|
||||
assert state.state == HVAC_MODE_COOL, entity_id
|
||||
|
||||
|
||||
async def test_ac_set_hvac_mode_from_off(hass, air_conditioner):
|
||||
"""Test setting HVAC mode when the unit is off."""
|
||||
air_conditioner.status.update_attribute_value(
|
||||
Attribute.air_conditioner_mode, 'heat')
|
||||
air_conditioner.status.update_attribute_value(Attribute.switch, 'off')
|
||||
await setup_platform(hass, CLIMATE_DOMAIN, devices=[air_conditioner])
|
||||
state = hass.states.get('climate.air_conditioner')
|
||||
assert state.state == HVAC_MODE_OFF
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN, SERVICE_SET_HVAC_MODE, {
|
||||
ATTR_ENTITY_ID: 'climate.air_conditioner',
|
||||
ATTR_HVAC_MODE: HVAC_MODE_HEAT_COOL},
|
||||
blocking=True)
|
||||
state = hass.states.get('climate.air_conditioner')
|
||||
assert state.state == HVAC_MODE_HEAT_COOL
|
||||
|
||||
|
||||
async def test_ac_set_hvac_mode_off(hass, air_conditioner):
|
||||
"""Test the AC HVAC mode can be turned off set successfully."""
|
||||
await setup_platform(hass, CLIMATE_DOMAIN, devices=[air_conditioner])
|
||||
@@ -376,6 +393,39 @@ async def test_set_temperature_ac_with_mode(hass, air_conditioner):
|
||||
assert state.state == HVAC_MODE_COOL
|
||||
|
||||
|
||||
async def test_set_temperature_ac_with_mode_from_off(hass, air_conditioner):
|
||||
"""Test the temp and mode is set successfully when the unit is off."""
|
||||
air_conditioner.status.update_attribute_value(
|
||||
Attribute.air_conditioner_mode, 'heat')
|
||||
air_conditioner.status.update_attribute_value(Attribute.switch, 'off')
|
||||
await setup_platform(hass, CLIMATE_DOMAIN, devices=[air_conditioner])
|
||||
assert hass.states.get('climate.air_conditioner').state == HVAC_MODE_OFF
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN, SERVICE_SET_TEMPERATURE, {
|
||||
ATTR_ENTITY_ID: 'climate.air_conditioner',
|
||||
ATTR_TEMPERATURE: 27,
|
||||
ATTR_HVAC_MODE: HVAC_MODE_COOL},
|
||||
blocking=True)
|
||||
state = hass.states.get('climate.air_conditioner')
|
||||
assert state.attributes[ATTR_TEMPERATURE] == 27
|
||||
assert state.state == HVAC_MODE_COOL
|
||||
|
||||
|
||||
async def test_set_temperature_ac_with_mode_to_off(hass, air_conditioner):
|
||||
"""Test the temp and mode is set successfully to turn off the unit."""
|
||||
await setup_platform(hass, CLIMATE_DOMAIN, devices=[air_conditioner])
|
||||
assert hass.states.get('climate.air_conditioner').state != HVAC_MODE_OFF
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN, SERVICE_SET_TEMPERATURE, {
|
||||
ATTR_ENTITY_ID: 'climate.air_conditioner',
|
||||
ATTR_TEMPERATURE: 27,
|
||||
ATTR_HVAC_MODE: HVAC_MODE_OFF},
|
||||
blocking=True)
|
||||
state = hass.states.get('climate.air_conditioner')
|
||||
assert state.attributes[ATTR_TEMPERATURE] == 27
|
||||
assert state.state == HVAC_MODE_OFF
|
||||
|
||||
|
||||
async def test_set_temperature_with_mode(hass, thermostat):
|
||||
"""Test the temperature and mode is set successfully."""
|
||||
await setup_platform(hass, CLIMATE_DOMAIN, devices=[thermostat])
|
||||
|
||||
Reference in New Issue
Block a user