-
-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Daikin Climate - Better integration with Climate base component #16913
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
Changes from 4 commits
c97dae4
922af63
fe5bb82
4864833
e4f537c
5ed1eb1
8fb9925
5d92aea
6a192ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,15 @@ | |
| 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 = { | ||
| ATTR_OPERATION_MODE: 'mode', | ||
| ATTR_FAN_MODE: 'f_rate', | ||
|
|
@@ -75,9 +84,7 @@ def __init__(self, api): | |
| self._api = api | ||
| self._force_refresh = False | ||
| self._list = { | ||
| ATTR_OPERATION_MODE: list( | ||
| map(str.title, set(HA_STATE_TO_DAIKIN.values())) | ||
| ), | ||
| ATTR_OPERATION_MODE: list(DAIKIN_TO_HA_STATE), | ||
| ATTR_FAN_MODE: list( | ||
| map( | ||
| str.title, | ||
|
|
@@ -136,11 +143,11 @@ def get(self, key): | |
| 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(daikin_attr)[1] | ||
| ).title() | ||
| daikin_mode = re.sub( | ||
| '[^a-z]','',self._api.device.represent(daikin_attr)[1]) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing whitespace after ',' |
||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. blank line contains whitespace |
||
| ha_mode = DAIKIN_TO_HA_STATE.get(daikin_mode) | ||
| value = ha_mode | ||
|
|
||
| if value is None: | ||
| _LOGGER.error("Invalid value requested for key %s", key) | ||
|
|
@@ -167,8 +174,8 @@ def set(self, settings): | |
|
|
||
| daikin_attr = HA_ATTR_TO_DAIKIN.get(attr) | ||
| if daikin_attr is not None: | ||
| if value.title() in self._list[attr]: | ||
| values[daikin_attr] = value.lower() | ||
| if value in self._list[attr]: | ||
|
MartinHjelmare marked this conversation as resolved.
|
||
| values[daikin_attr] = HA_STATE_TO_DAIKIN[value]; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. statement ends with a semicolon |
||
| else: | ||
| _LOGGER.error("Invalid value %s for %s", attr, value) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be:
We want to use the ha states so we use the keys of the
HA_STATE_TO_DAIKINdictionary.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you check my lasts commit? I’m quite sure that I should use the other dictionary in that point. Today I’m not able to test since I’m travelling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use the same dictionary as we do here:
https://github.com/home-assistant/home-assistant/pull/16913/files#diff-f35f4028d7ed0027465e5dea53ef4acdR178
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the modification you suggested, but I'm not able to test it right now. I'm hoping that @mynameisdaniel32 can test it sooner than I can 😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I managed to run a quick test, and it seems to work good. As soon as I can I will run some further tests.