Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore SmartThings A/C on/off services #25259

Merged
merged 3 commits into from Jul 18, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Prev

Support AC HVAC_MODE_OFF

  • Loading branch information...
andrewsayre committed Jul 18, 2019
commit c1391b1ac7d72d6e2c1a3c11d5c1766e7d53e4cf
@@ -323,6 +323,9 @@ def __init__(self, device):

async def async_set_hvac_mode(self, hvac_mode):
"""Set new target operation mode."""
if hvac_mode == HVAC_MODE_OFF:
await self.async_turn_off()
return
await self._device.set_air_conditioner_mode(
STATE_TO_AC_MODE[hvac_mode], set_status=True)
# State is set optimistically in the command above, therefore update
@@ -360,16 +363,16 @@ def __init__(self, device):

async def async_update(self):
"""Update the calculated fields of the AC."""
operations = set()
modes = {HVAC_MODE_OFF}

This comment has been minimized.

Copy link
@balloob

balloob Jul 18, 2019

Member

This is fine as it was already like this, but it has the downside that it makes the order of the controls random, and that order is also used in the UI I think (probably shouldn't).

This comment has been minimized.

Copy link
@andrewsayre

andrewsayre Jul 18, 2019

Author Member

It has the effect of showing it alphabetically, I believe. Yes, I the UI should order them as it intends instead of relying on each platform to return a specific sequence. 👍

for mode in self._device.status.supported_ac_modes:
state = AC_MODE_TO_STATE.get(mode)
if state is not None:
operations.add(state)
modes.add(state)
else:
_LOGGER.debug('Device %s (%s) returned an invalid supported '
'AC mode: %s', self._device.label,
self._device.device_id, mode)
self._hvac_modes = operations
self._hvac_modes = modes

@property
def current_temperature(self):
@@ -245,7 +245,7 @@ def air_conditioner_fixture(device_factory):
SUPPORT_TARGET_TEMPERATURE
assert sorted(state.attributes[ATTR_HVAC_MODES]) == [
HVAC_MODE_COOL, HVAC_MODE_DRY, HVAC_MODE_FAN_ONLY, HVAC_MODE_HEAT,
HVAC_MODE_HEAT_COOL]
HVAC_MODE_HEAT_COOL, HVAC_MODE_OFF]
assert state.attributes[ATTR_FAN_MODE] == 'medium'
assert sorted(state.attributes[ATTR_FAN_MODES]) == \
['auto', 'high', 'low', 'medium', 'turbo']
@@ -277,8 +277,8 @@ def air_conditioner_fixture(device_factory):
assert state.attributes[ATTR_FAN_MODE] == 'auto', entity_id


async def test_set_operation_mode(hass, thermostat, air_conditioner):
"""Test the operation mode is set successfully."""
async def test_set_hvac_mode(hass, thermostat, air_conditioner):
"""Test the hvac mode is set successfully."""
await setup_platform(hass, CLIMATE_DOMAIN,
devices=[thermostat, air_conditioner])
entity_ids = ['climate.thermostat', 'climate.air_conditioner']
@@ -293,6 +293,20 @@ def air_conditioner_fixture(device_factory):
assert state.state == HVAC_MODE_COOL, entity_id


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])
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_OFF},
blocking=True)
state = hass.states.get('climate.air_conditioner')
assert state.state == HVAC_MODE_OFF


async def test_set_temperature_heat_mode(hass, thermostat):
"""Test the temperature is set successfully when in heat mode."""
thermostat.status.thermostat_mode = 'heat'
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.