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

Add climate fan modes for Airzone Cloud Aidoo devices #103574

Merged
merged 11 commits into from
Mar 25, 2024

Conversation

Noltari
Copy link
Contributor

@Noltari Noltari commented Nov 7, 2023

Proposed change

Add climate fan modes for Airzone Cloud Aidoo devices.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
homeassistant/components/airzone_cloud/climate.py Outdated Show resolved Hide resolved
homeassistant/components/airzone_cloud/climate.py Outdated Show resolved Hide resolved
homeassistant/components/airzone_cloud/climate.py Outdated Show resolved Hide resolved
@home-assistant home-assistant bot marked this pull request as draft December 31, 2023 12:56
@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
@Noltari Noltari marked this pull request as ready for review December 31, 2023 17:57
homeassistant/components/airzone_cloud/climate.py Outdated Show resolved Hide resolved
homeassistant/components/airzone_cloud/climate.py Outdated Show resolved Hide resolved
homeassistant/components/airzone_cloud/climate.py Outdated Show resolved Hide resolved
@home-assistant home-assistant bot marked this pull request as draft January 25, 2024 15:33
@jesusvila
Copy link

I'm interested in this function. How can I test it?

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
@Noltari Noltari marked this pull request as ready for review February 21, 2024 17:12
Copy link

@jesusvila jesusvila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this integration and it works perfectly. Aidoo Airzone + Fujitsu ducted air conditioner. The four speeds of the indoor unit are displayed correctly

Copy link

@BronRZ BronRZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have verified that everything works correctly in my AC with Airzone, I use an LG AC and the operation is perfect, as if it were the official app.

@bdraco bdraco self-requested a review March 1, 2024 17:55
Copy link
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a couple of small issues / unclarities

Comment on lines 342 to 344
fan_speeds[1] = FAN_LOW
fan_speeds[int(round((max_speed + 1) / 2, 0))] = FAN_MEDIUM
fan_speeds[max_speed] = FAN_HIGH
Copy link
Contributor

@emontnemery emontnemery Mar 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we want the list to be:

[
        FAN_AUTO,
        FAN_LOW,
        "40%",
        FAN_MEDIUM,
        "80%",
        FAN_HIGH,
    ]

Instead of:

[
        FAN_AUTO,
        "20%",
        "40%",
        "60%",
        "80%",
        "100%",
    ]

If there's a good reason, it wouldn't hurt to explain it in a comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because only the default speeds are exposed via Homekit/Alexa, and this is the only way of having N speeds and also getting the default ones exposed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 0f4566f

Copy link
Contributor

@emontnemery emontnemery Mar 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only the default speeds are exposed via Homekit/Alexa

The Alexa integration does not support fan speeds for climate entities.

For homekit there is such a limitation though

if fan_modes and PRE_DEFINED_FAN_MODES.intersection(fan_modes):
self.ordered_fan_speeds = [
speed for speed in ORDERED_FAN_SPEEDS if speed in fan_modes
]
self.fan_chars.append(CHAR_ROTATION_SPEED)

I'd like a second opinion on this design, integrations should not have to solve limitations in voice assistant integrations.

gree adds additional fan modes with a list like this, but maybe it doesn't work here if there can be many fan speeds:

FAN_MODES = {
    FanSpeed.Auto: FAN_AUTO,
    FanSpeed.Low: FAN_LOW,
    FanSpeed.MediumLow: FAN_MEDIUM_LOW,
    FanSpeed.Medium: FAN_MEDIUM,
    FanSpeed.MediumHigh: FAN_MEDIUM_HIGH,
    FanSpeed.High: FAN_HIGH,
}

Copy link
Contributor Author

@Noltari Noltari Mar 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like a second opinion on this design, integrations should not have to solve limitations in voice assistant integrations.

@emontnemery this was already proposed by @bdraco during the same review for the local Airzone integration, see #92840
The Airzone local integration code:

def _set_fan_speeds(self) -> None:
self._attr_supported_features |= ClimateEntityFeature.FAN_MODE
speeds = self.get_airzone_value(AZD_SPEEDS)
max_speed = max(speeds)
if _speeds := FAN_SPEED_MAPS.get(max_speed):
self._speeds = _speeds
else:
for speed in speeds:
if speed == 0:
self._speeds[speed] = FAN_AUTO
else:
self._speeds[speed] = f"{int(round((speed * 100) / max_speed, 0))}%"
self._speeds[1] = FAN_LOW
self._speeds[int(round((max_speed + 1) / 2, 0))] = FAN_MEDIUM
self._speeds[max_speed] = FAN_HIGH
self._speeds_reverse = {v: k for k, v in self._speeds.items()}
self._attr_fan_modes = list(self._speeds_reverse)

gree adds additional fan modes with a list like this, but maybe it doesn't work here if there can be many fan speeds

According to Airzone there can be up to 8 speeds (+ Auto).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Alexa integration does not support fan speeds for climate entities.

You're right, comment fixed in 681967f

Copy link
Contributor

@emontnemery emontnemery Mar 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was already proposed by @bdraco during the same review for the local Airzone integration

That's not a good proposal though, other integrations should not have to implement workarounds because of limitations in homekit, please change to a consistent naming both in this PR and in the airzone integration.

Maybe the climate integration could make use of some clarification of the fan modes, or splitting between an ordered list of fan speed and fan modes (such as auto), that'd need an architecture discussion though.

Copy link
Contributor Author

@Noltari Noltari Mar 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not a good proposal though, other integrations should not have to implement workarounds because of limitations in homekit, please change to a consistent naming both in this PR and in the airzone integration.

Done in 438c5b6.
I don't think that doing it for the local integration is a good idea since it will break the compatibility for existing users...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, maybe you're right that the breaking change is not worth it.
We should maybe add a comment in the local integration saying we don't want that pattern in other integrations though?

homeassistant/components/airzone_cloud/climate.py Outdated Show resolved Hide resolved
@home-assistant home-assistant bot marked this pull request as draft March 5, 2024 14:10
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
@Noltari Noltari marked this pull request as ready for review March 5, 2024 18:55
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Instead of mixing "low", "medium" and "high" with percentages, let's use only
percentages if there are more speeds.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Copy link
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @Noltari 👍

@emontnemery emontnemery merged commit 33d9947 into home-assistant:dev Mar 25, 2024
21 checks passed
@Noltari Noltari deleted the airzone-cloud-climate-speeds branch March 25, 2024 13:45
@github-actions github-actions bot locked and limited conversation to collaborators Mar 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants