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
40 changes: 27 additions & 13 deletions homeassistant/components/climate/daikin.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@

_LOGGER = logging.getLogger(__name__)

SUPPORT_FLAGS = (SUPPORT_TARGET_TEMPERATURE |
SUPPORT_FAN_MODE |
SUPPORT_OPERATION_MODE |
SUPPORT_SWING_MODE)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_HOST): cv.string,
vol.Optional(CONF_NAME, default=None): cv.string,
Expand All @@ -56,6 +51,9 @@
ATTR_OPERATION_MODE: 'mode',
ATTR_FAN_MODE: 'f_rate',
ATTR_SWING_MODE: 'f_dir',
ATTR_INSIDE_TEMPERATURE: 'htemp',
ATTR_OUTSIDE_TEMPERATURE: 'otemp',
ATTR_TARGET_TEMPERATURE: 'stemp'
}


Expand Down Expand Up @@ -101,32 +99,48 @@ def __init__(self, api):
),
}

self._supported_features = SUPPORT_TARGET_TEMPERATURE \
| SUPPORT_OPERATION_MODE

daikin_attr = HA_ATTR_TO_DAIKIN[ATTR_FAN_MODE]
if self._api.device.values.get(daikin_attr) is not None:
self._supported_features |= SUPPORT_FAN_MODE

daikin_attr = HA_ATTR_TO_DAIKIN[ATTR_SWING_MODE]
if self._api.device.values.get(daikin_attr) is not None:
self._supported_features |= SUPPORT_SWING_MODE

def get(self, key):
"""Retrieve device settings from API library cache."""
value = None
cast_to_float = False

if key in [ATTR_TEMPERATURE, ATTR_INSIDE_TEMPERATURE,
ATTR_CURRENT_TEMPERATURE]:
value = self._api.device.values.get('htemp')
key = ATTR_INSIDE_TEMPERATURE

daikin_attr = HA_ATTR_TO_DAIKIN.get(key)

if key == ATTR_INSIDE_TEMPERATURE:
value = self._api.device.values.get(daikin_attr)
cast_to_float = True
if key == ATTR_TARGET_TEMPERATURE:
value = self._api.device.values.get('stemp')
elif key == ATTR_TARGET_TEMPERATURE:
value = self._api.device.values.get(daikin_attr)
cast_to_float = True
elif key == ATTR_OUTSIDE_TEMPERATURE:
value = self._api.device.values.get('otemp')
value = self._api.device.values.get(daikin_attr)
cast_to_float = True
elif key == ATTR_FAN_MODE:
value = self._api.device.represent('f_rate')[1].title()
value = self._api.device.represent(daikin_attr)[1].title()
elif key == ATTR_SWING_MODE:
value = self._api.device.represent('f_dir')[1].title()
value = self._api.device.represent(daikin_attr)[1].title()
elif key == ATTR_OPERATION_MODE:
# Daikin can return also internal states auto-1 or auto-7
# and we need to translate them as AUTO
value = re.sub(
'[^a-z]',
'',
self._api.device.represent('mode')[1]
self._api.device.represent(daikin_attr)[1]
).title()

if value is None:
Expand Down Expand Up @@ -178,7 +192,7 @@ def unique_id(self):
@property
def supported_features(self):
"""Return the list of supported features."""
return SUPPORT_FLAGS
return self._supported_features

@property
def name(self):
Expand Down