Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions homeassistant/components/climate/sensibo.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
ATTR_CURRENT_HUMIDITY, ClimateDevice, DOMAIN, PLATFORM_SCHEMA,
SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE,
SUPPORT_FAN_MODE, SUPPORT_SWING_MODE,
SUPPORT_ON_OFF)
SUPPORT_ON_OFF, STATE_HEAT, STATE_COOL, STATE_FAN_ONLY, STATE_DRY,
STATE_AUTO)
from homeassistant.exceptions import PlatformNotReady
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.aiohttp_client import async_get_clientsession
Expand Down Expand Up @@ -57,6 +58,16 @@
'on': SUPPORT_ON_OFF,
}

SENSIBO_TO_HA = {
"cool": STATE_COOL,
"heat": STATE_HEAT,
"fan": STATE_FAN_ONLY,
"auto": STATE_AUTO,
"dry": STATE_DRY
}

HA_TO_SENSIBO = {value: key for key, value in SENSIBO_TO_HA.items()}


async def async_setup_platform(hass, config, async_add_entities,
discovery_info=None):
Expand Down Expand Up @@ -129,9 +140,10 @@ def _do_update(self, data):
self._ac_states = data['acState']
self._status = data['connectionStatus']['isAlive']
capabilities = data['remoteCapabilities']
self._operations = sorted(capabilities['modes'].keys())
self._current_capabilities = capabilities[
'modes'][self.current_operation]
self._operations = [SENSIBO_TO_HA[mode] for mode
in capabilities['modes']]
self._current_capabilities = \
capabilities['modes'][self._ac_states['mode']]
temperature_unit_key = data.get('temperatureUnit') or \
self._ac_states.get('temperatureUnit')
if temperature_unit_key:
Expand Down Expand Up @@ -186,7 +198,7 @@ def target_temperature_step(self):
@property
def current_operation(self):
"""Return current operation ie. heat, cool, idle."""
return self._ac_states['mode']
return SENSIBO_TO_HA.get(self._ac_states['mode'])

@property
def current_humidity(self):
Expand Down Expand Up @@ -293,7 +305,8 @@ async def async_set_operation_mode(self, operation_mode):
"""Set new target operation mode."""
with async_timeout.timeout(TIMEOUT):
await self._client.async_set_ac_state_property(
self._id, 'mode', operation_mode, self._ac_states)
self._id, 'mode', HA_TO_SENSIBO[operation_mode],
self._ac_states)

async def async_set_swing_mode(self, swing_mode):
"""Set new target swing operation."""
Expand Down