mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Daikin Climate - Better integration with Climate base component (#16913)
* Daikin Climate - Better integration with Climate base component Made some modification in order to better integrate the Daikin AC Component with the base Climate Component. Benefits are: Support localization for Operation Mode Support for Homekit Integration (if the AC is turned On, now the status is updated in Homekit) * Build bug fixing * Bug fixing in Set Operation_Mode functionality Fixed to .title() functionality in matching the Operation_Mode * Fix useless code * Fix hound bug * Bug fixing Change in list of Operation Mode * Trailing white space fix * Compile fixing * Whitespace fix
This commit is contained in:
parent
f2d8f3bcb8
commit
ee5e1fa355
@ -40,6 +40,15 @@ HA_STATE_TO_DAIKIN = {
|
|||||||
STATE_OFF: 'off',
|
STATE_OFF: 'off',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DAIKIN_TO_HA_STATE = {
|
||||||
|
'fan': STATE_FAN_ONLY,
|
||||||
|
'dry': STATE_DRY,
|
||||||
|
'cool': STATE_COOL,
|
||||||
|
'hot': STATE_HEAT,
|
||||||
|
'auto': STATE_AUTO,
|
||||||
|
'off': STATE_OFF,
|
||||||
|
}
|
||||||
|
|
||||||
HA_ATTR_TO_DAIKIN = {
|
HA_ATTR_TO_DAIKIN = {
|
||||||
ATTR_OPERATION_MODE: 'mode',
|
ATTR_OPERATION_MODE: 'mode',
|
||||||
ATTR_FAN_MODE: 'f_rate',
|
ATTR_FAN_MODE: 'f_rate',
|
||||||
@ -75,9 +84,7 @@ class DaikinClimate(ClimateDevice):
|
|||||||
self._api = api
|
self._api = api
|
||||||
self._force_refresh = False
|
self._force_refresh = False
|
||||||
self._list = {
|
self._list = {
|
||||||
ATTR_OPERATION_MODE: list(
|
ATTR_OPERATION_MODE: list(HA_STATE_TO_DAIKIN),
|
||||||
map(str.title, set(HA_STATE_TO_DAIKIN.values()))
|
|
||||||
),
|
|
||||||
ATTR_FAN_MODE: list(
|
ATTR_FAN_MODE: list(
|
||||||
map(
|
map(
|
||||||
str.title,
|
str.title,
|
||||||
@ -136,11 +143,11 @@ class DaikinClimate(ClimateDevice):
|
|||||||
elif key == ATTR_OPERATION_MODE:
|
elif key == ATTR_OPERATION_MODE:
|
||||||
# Daikin can return also internal states auto-1 or auto-7
|
# Daikin can return also internal states auto-1 or auto-7
|
||||||
# and we need to translate them as AUTO
|
# and we need to translate them as AUTO
|
||||||
value = re.sub(
|
daikin_mode = re.sub(
|
||||||
'[^a-z]',
|
'[^a-z]', '',
|
||||||
'',
|
self._api.device.represent(daikin_attr)[1])
|
||||||
self._api.device.represent(daikin_attr)[1]
|
ha_mode = DAIKIN_TO_HA_STATE.get(daikin_mode)
|
||||||
).title()
|
value = ha_mode
|
||||||
|
|
||||||
if value is None:
|
if value is None:
|
||||||
_LOGGER.error("Invalid value requested for key %s", key)
|
_LOGGER.error("Invalid value requested for key %s", key)
|
||||||
@ -167,8 +174,8 @@ class DaikinClimate(ClimateDevice):
|
|||||||
|
|
||||||
daikin_attr = HA_ATTR_TO_DAIKIN.get(attr)
|
daikin_attr = HA_ATTR_TO_DAIKIN.get(attr)
|
||||||
if daikin_attr is not None:
|
if daikin_attr is not None:
|
||||||
if value.title() in self._list[attr]:
|
if value in self._list[attr]:
|
||||||
values[daikin_attr] = value.lower()
|
values[daikin_attr] = HA_STATE_TO_DAIKIN[value]
|
||||||
else:
|
else:
|
||||||
_LOGGER.error("Invalid value %s for %s", attr, value)
|
_LOGGER.error("Invalid value %s for %s", attr, value)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user