Skip to content

[DNM] Gree Integration rewrite#373

Draft
p-monteiro wants to merge 84 commits intoRobHofmann:masterfrom
p-monteiro:gree-rewrite
Draft

[DNM] Gree Integration rewrite#373
p-monteiro wants to merge 84 commits intoRobHofmann:masterfrom
p-monteiro:gree-rewrite

Conversation

@p-monteiro
Copy link
Contributor

@p-monteiro p-monteiro commented Sep 23, 2025

[DO NOT MERGE]

️ATTENTION

This PR changes the domain of the integration, so current users will lose their device configs!
The config schema also changed, so verify your YAML if you use it to configure the devices.

This PR introduces a rewrite of this integration. The main goal of this was to better align the integration with the Home Assistant (HA) development workflow with two main changes:

  • Completely separate device API code from HA code
  • Align with code style guidelines (mainly Ruff code formatting and full typing)

Other changes that are present in this PR:

  • Async device communication
  • Use a device coordinator to fetch data from the device
  • Device Features are user-selectable since the Gree API does not provide a reliable method of getting them
  • Improvements to entity creation and config flow with better errors and organization
  • Gree API functions are better structured and clearer to understand the logic, which is also reused when possible
  • Gree API is fully declarative, no string guessing
  • Gree API now provides a GreeDevice object to handle device logic
  • Implement Auto Encryption version
  • Expose entity restore behavior as a configuration
  • Properly allow to reconfigure a config entry (including device connection, useful for when a device changes IP)
  • Support for individual device removal
  • RestoreEntity support in ClimateEntity
  • Exposed all device sensors as entities
  • Allow to set the device temperature units (shown on the device display)
  • Support for diagnostics download in the config entries and the devices

I want full feature parity with the current integration and iron out some bugs before this is ready to merge (if you so wish). Currently missing and wishlist:

  • [Bug] Broken VRF Device Status

As you can see, there are a lot of changes, and I understand if this does not go through as is.
I am creating the PR mainly to gather feedback and track progress since most features are now present in this PR.
Don't treat this PR as blocking. I am tracking new changes and integrating them as they are committed.

Also, since this is a big rewrite, I wonder if we should use it to bump the major version (4?) and possibly change the domain to not replace the official integration (as I saw in the bug reports that it might impose some problems).

- Change config flow to: be multi step and allow setting the device features; allow to reconfigure an entry
- Separate HA and Device API logic: device API is now declarative and handles device behaviour. HA entities expose the device
- Implement a coordinator
- Async device communication
- More error handling
- Move consts around
- Proper error report on config_flow
- Proper translations on config_flow
- Configuration of timeout
- Fetch device info during binding
@p-monteiro
Copy link
Contributor Author

@RobHofmann I was adding the temperature step back, but I'm not sure of its utility.
Is there any device that accepts non-integer ºC/ºF?

@domialex
Copy link
Contributor

@p-monteiro
The temperature step should not be in the configuration entities anyways, it should be in the climate options. That was a mistake on my part.

@p-monteiro
Copy link
Contributor Author

Hi @domialex, that's fine. I'm more interested in the real use case for it. Should it be locked to integers? I don't think any device supports half degrees or even 0.1 steps, as is the lower limit for the current slider...

@p-monteiro
Copy link
Contributor Author

@RobHofmann I don't mind breaking it up, but I'm not sure how much can be separated.

It mainly touches these points:

  • Separates Gree code from HA code, which touches almost every file
  • Changes the Domain
  • Changes the config entry and config flow - a lot!
  • Changes Translations
  • Adds some quality of life features.

Do you have any suggestions on how to go about it?
The good part is that, as is, it's working well on my part.
The bad is that I don't know how to break it without having at least 1 big PR.

@domialex
Copy link
Contributor

It’s essentially a full rewrite, and I don’t have the time to test or review all the changes in detail.
I’m guessing this is a breaking upgrade, meaning every entity and configuration will need to be recreated. If that’s the case, you have to be ready to support the project until the release is stable, because I won't be able to.

@RobHofmann I don't recommend breaking the PR into smaller pieces since this is a rewrite, but I do recommend making a beta release instead and see how it goes. Put the release as a "pre-release", HACS should handle the rest.

@RobHofmann
Copy link
Owner

@domialex Thats fair.

@p-monteiro do you know if this is a breaking release (will entities be recreated or have different names for example)? And I need some insights on feature parity with the current version.

I will do some testing on my side when we clean the above things up.

@p-monteiro
Copy link
Contributor Author

@RobHofmann This is very much a breaking release, because configs cannot be migrated (change in Domain).
Some entities might keep their name after configs are recreated, but I wouldn't count on it.

I didn't know HACS supported pre-preleases; that would be sweet because it's missing testing.

@domialex, I am trying to support it as best as I can, from what I gather in this PR, VRF is an issue, and discovery seems to fail in encryption v1 (?). I need people to test and send logs, because my multisplit is working well, as is. I'd love to make more meaningful logs, but I'm not sure how, because when it fails, it basically gives an exception communicating with the device, probably because a bad request was made. But the device is a bit of a black box.

Regarding feature regressions, I don't think there are any more. Some things might be configured differently during the flow, but the end result should be good.

@ChillingSilence
Copy link

I'm getting the following error:
image

Logger: custom_components.gree_custom.config_flow
Source: custom_components/gree_custom/config_flow.py:686
integration: Gree A/C ([documentation](https://github.com/RobHofmann/HomeAssistant-GreeClimateComponent))
First occurred: 9:38:33 PM (1 occurrence)
Last logged: 9:38:33 PM

Error while binding
Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/api.py", line 364, in fetch_result
    received_json = await udp_request_async(
                    ^^^^^^^^^^^^^^^^^^^^^^^^
        ip_addr, port, json_data, max_connection_attempts, timeout
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 294, in udp_request_async
    raise ValueError(
        f"Failed to communicate with device '{ip_addr}:{port}' after {max_retries} attempts"
    )
ValueError: Failed to communicate with device '192.168.22.120:7000' after 2 attempts

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/api.py", line 598, in gree_get_device_key
    result = await get_result_pack(
             ^^^^^^^^^^^^^^^^^^^^^^
    ...<7 lines>...
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 420, in get_result_pack
    data = await fetch_result(
           ^^^^^^^^^^^^^^^^^^^
    ...<7 lines>...
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 368, in fetch_result
    raise ValueError(f"Error communicating with {ip_addr}: {err}") from err
ValueError: Error communicating with 192.168.22.120: Failed to communicate with device '192.168.22.120:7000' after 2 attempts

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/device.py", line 116, in bind_device
    ) = await gree_get_device_key(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<7 lines>...
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 629, in gree_get_device_key
    raise ValueError("Error getting device encryption key") from error
ValueError: Error getting device encryption key

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/config_flow.py", line 686, in async_step_manual_add
    self._discovered_subdevices = await self._devices[
                                  ^^^^^^^^^^^^^^^^^^^^
        _main_device.mac_address_sub
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ].fetch_sub_devices()
    ^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/device.py", line 175, in fetch_sub_devices
    await self.bind_device()
  File "/config/custom_components/gree_custom/aiogree/device.py", line 127, in bind_device
    raise GreeDeviceNotBoundError("Unable to obtain device key") from e
custom_components.gree_custom.aiogree.device.GreeDeviceNotBoundError: Unable to obtain device key

I ran a git pull to ensure I had the latest, on the gree-rewrite branch, and then restarted HA.
I have confirmed the IP and MAC address, it's on the WiFi responding to pings. First I tried with the auto discovery, then I tried manually entering it.

When I download the logs from Home Assistant rather than just clicking on the error binding, I get:

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
services-up: info: copying legacy longrun home-assistant (no readiness notification)
s6-rc: info: service legacy-services successfully started
2026-03-15 21:25:51.641 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration ac_infinity which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2026-03-15 21:25:51.642 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration gree_custom which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2026-03-15 21:25:51.642 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration intesishome which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2026-03-15 21:25:51.643 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2026-03-15 21:31:01.140 DEBUG (MainThread) [custom_components.gree_custom.config_flow] Found broadcast addresses from HA: ['255.255.255.255']
2026-03-15 21:31:01.140 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Sending broadcast to 255.255.255.255
2026-03-15 21:31:01.141 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Sending broadcast to 192.168.255.255
2026-03-15 21:31:01.142 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Sending broadcast to 10.255.255.255
2026-03-15 21:31:01.142 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Sending broadcast to 172.31.255.255
2026-03-15 21:31:01.143 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Sent broadcast packets, waiting for replies... 
2026-03-15 21:31:06.148 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Got 0 responses in 5 seconds: {}
2026-03-15 21:31:08.706 ERROR (MainThread) [custom_components.ac_infinity.core] Error fetching ac_infinity data: 
2026-03-15 21:38:24.362 INFO (MainThread) [custom_components.gree_custom.aiogree.device] Initialize the GREE Device API for: 58:0d:0d:34:74:fc (192.168.22.120:7000)
2026-03-15 21:38:24.362 DEBUG (MainThread) [custom_components.gree_custom.aiogree.device] Version: None, Key: [omitted]
2026-03-15 21:38:24.362 DEBUG (MainThread) [custom_components.gree_custom.aiogree.device] Trying to get subdevices
2026-03-15 21:38:24.362 INFO (MainThread) [custom_components.gree_custom.aiogree.api] Trying to retrieve device encryption key v1
2026-03-15 21:38:24.363 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Bind Pack: {"mac": "580d0d3474fc", "t": "bind", "uid": 0}
2026-03-15 21:38:24.372 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Payload: {'cid': 'app', 'i': 1, 'pack': 'Fo0NJVLzyhX4Qh3bOqWhT4QPXnuPS0a5W/exMkAoHz3IfE1fYVsWM5kifDBw/LN1', 't': 'pack', 'tcid': '580d0d3474fc', 'uid': 0}
2026-03-15 21:38:24.373 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Fetching data from 192.168.22.120
2026-03-15 21:38:26.374 WARNING (MainThread) [custom_components.gree_custom.aiogree.api] Error communicating with 192.168.22.120. Attempt 1/2 | 
2026-03-15 21:38:28.878 WARNING (MainThread) [custom_components.gree_custom.aiogree.api] Error communicating with 192.168.22.120. Attempt 2/2 | 
2026-03-15 21:38:28.878 ERROR (MainThread) [custom_components.gree_custom.aiogree.api] Error getting device encryption key with version 1:
Error communicating with 192.168.22.120: Failed to communicate with device '192.168.22.120:7000' after 2 attempts
2026-03-15 21:38:28.878 INFO (MainThread) [custom_components.gree_custom.aiogree.api] Trying to retrieve device encryption key v2
2026-03-15 21:38:28.879 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Bind Pack: {"cid": "580d0d3474fc", "mac": "580d0d3474fc", "t": "bind", "uid": 0}
2026-03-15 21:38:28.925 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Payload: {'cid': 'app', 'i': 1, 'pack': 'Jtod3XIt89Dxs8SHPnkRBJt2vIVBwAvmIgk1XvjRhurELj0L3QVtft+hse+GRsWcl72qEoTtZbgS4JbKYrud0qPFjVyn', 't': 'pack', 'tcid': '580d0d3474fc', 'uid': 0, 'tag': 'qKWestnLPk4VGayIhFfpRg=='}
2026-03-15 21:38:28.925 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Fetching data from 192.168.22.120
2026-03-15 21:38:30.926 WARNING (MainThread) [custom_components.gree_custom.aiogree.api] Error communicating with 192.168.22.120. Attempt 1/2 | 
2026-03-15 21:38:33.429 WARNING (MainThread) [custom_components.gree_custom.aiogree.api] Error communicating with 192.168.22.120. Attempt 2/2 | 
2026-03-15 21:38:33.430 ERROR (MainThread) [custom_components.gree_custom.aiogree.api] Error getting device encryption key with version 2:
Error communicating with 192.168.22.120: Failed to communicate with device '192.168.22.120:7000' after 2 attempts
2026-03-15 21:38:33.430 ERROR (MainThread) [custom_components.gree_custom.config_flow] Error while binding
Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/api.py", line 364, in fetch_result
    received_json = await udp_request_async(
                    ^^^^^^^^^^^^^^^^^^^^^^^^
        ip_addr, port, json_data, max_connection_attempts, timeout
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 294, in udp_request_async
    raise ValueError(
        f"Failed to communicate with device '{ip_addr}:{port}' after {max_retries} attempts"
    )
ValueError: Failed to communicate with device '192.168.22.120:7000' after 2 attempts

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/api.py", line 598, in gree_get_device_key
    result = await get_result_pack(
             ^^^^^^^^^^^^^^^^^^^^^^
    ...<7 lines>...
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 420, in get_result_pack
    data = await fetch_result(
           ^^^^^^^^^^^^^^^^^^^
    ...<7 lines>...
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 368, in fetch_result
    raise ValueError(f"Error communicating with {ip_addr}: {err}") from err
ValueError: Error communicating with 192.168.22.120: Failed to communicate with device '192.168.22.120:7000' after 2 attempts

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/device.py", line 116, in bind_device
    ) = await gree_get_device_key(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<7 lines>...
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 629, in gree_get_device_key
    raise ValueError("Error getting device encryption key") from error
ValueError: Error getting device encryption key

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/config_flow.py", line 686, in async_step_manual_add
    self._discovered_subdevices = await self._devices[
                                  ^^^^^^^^^^^^^^^^^^^^
        _main_device.mac_address_sub
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ].fetch_sub_devices()
    ^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/device.py", line 175, in fetch_sub_devices
    await self.bind_device()
  File "/config/custom_components/gree_custom/aiogree/device.py", line 127, in bind_device
    raise GreeDeviceNotBoundError("Unable to obtain device key") from e
custom_components.gree_custom.aiogree.device.GreeDeviceNotBoundError: Unable to obtain device key
2026-03-15 21:38:33.437 DEBUG (MainThread) [custom_components.gree_custom.config_flow] Building main schema with previous values: {'host': '192.168.22.120', 'mac': '58:0d:0d:34:74:fc', 'advanced': {'port': 7000, 'encryption_version': 'Auto-Detect', 'encryption_key': '', 'uid': 0, 'disable_available_check': False, 'max_online_attempts': 5, 'timeout': 10}}

Let me know if I can get further logs

@p-monteiro
Copy link
Contributor Author

p-monteiro commented Mar 15, 2026

@ChillingSilence Thanks for the report, will look into it. Do you know the correct encryption version of your device?

@ChillingSilence
Copy link

Do you know the correct encryption version of your device?

I don't sorry @p-monteiro but if you have a link to how I can extract that info, I've tried the luc10/gree-api-client but I don't believe that tells me the encryption version:
image

I have two of these devices, both showing the same symptoms. Is there a way for me to extract that info from the app?

@p-monteiro
Copy link
Contributor Author

I have two of these devices, both showing the same symptoms. Is there a way for me to extract that info from the app?

Not that I am aware of. You can try manually adding the device using that key and testing both versions.
I'm trying to clean up the logging and logic a bit to better understand these errors in the meantime.
The packets being sent are the same as in the stable version, so I guess there is an issue in the communication.

@ChillingSilence
Copy link

I tried it again after doing a git pull, then restarted HA:

Logger: custom_components.gree_custom.config_flow
Source: custom_components/gree_custom/config_flow.py:686
integration: Gree A/C (documentation)
First occurred: 2:55:50 PM (2 occurrences)
Last logged: 2:56:05 PM

Error while binding
Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/api.py", line 364, in fetch_result
    received_json = await udp_request_async(
                    ^^^^^^^^^^^^^^^^^^^^^^^^
        ip_addr, port, json_data, max_connection_attempts, timeout
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 294, in udp_request_async
    raise ValueError(
        f"Failed to communicate with device '{ip_addr}:{port}' after {max_retries} attempts"
    )
ValueError: Failed to communicate with device '192.168.22.120:7000' after 2 attempts

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/api.py", line 598, in gree_get_device_key
    result = await get_result_pack(
             ^^^^^^^^^^^^^^^^^^^^^^
    ...<7 lines>...
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 420, in get_result_pack
    data = await fetch_result(
           ^^^^^^^^^^^^^^^^^^^
    ...<7 lines>...
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 368, in fetch_result
    raise ValueError(f"Error communicating with {ip_addr}: {err}") from err
ValueError: Error communicating with 192.168.22.120: Failed to communicate with device '192.168.22.120:7000' after 2 attempts

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/device.py", line 116, in bind_device
    ) = await gree_get_device_key(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<7 lines>...
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 629, in gree_get_device_key
    raise ValueError("Error getting device encryption key") from error
ValueError: Error getting device encryption key

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/config_flow.py", line 686, in async_step_manual_add
    self._discovered_subdevices = await self._devices[
                                  ^^^^^^^^^^^^^^^^^^^^
        _main_device.mac_address_sub
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ].fetch_sub_devices()
    ^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/device.py", line 175, in fetch_sub_devices
    await self.bind_device()
  File "/config/custom_components/gree_custom/aiogree/device.py", line 127, in bind_device
    raise GreeDeviceNotBoundError("Unable to obtain device key") from e
custom_components.gree_custom.aiogree.device.GreeDeviceNotBoundError: Unable to obtain device key

I tried initially to autodiscover. That failed, so I used the output from the gree-api-client:

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
services-up: info: copying legacy longrun home-assistant (no readiness notification)
s6-rc: info: service legacy-services successfully started
2026-03-16 14:53:13.806 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration ac_infinity which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2026-03-16 14:53:13.807 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration gree_custom which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2026-03-16 14:53:13.807 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration intesishome which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2026-03-16 14:53:13.807 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2026-03-16 14:55:16.084 DEBUG (MainThread) [custom_components.gree_custom.config_flow] Found broadcast addresses from HA: ['255.255.255.255']
2026-03-16 14:55:16.085 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Sending broadcast to 255.255.255.255
2026-03-16 14:55:16.085 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Sending broadcast to 192.168.255.255
2026-03-16 14:55:16.086 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Sending broadcast to 10.255.255.255
2026-03-16 14:55:16.086 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Sending broadcast to 172.31.255.255
2026-03-16 14:55:16.087 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Sent broadcast packets, waiting for replies...
2026-03-16 14:55:21.092 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Got 0 responses in 5 seconds: {}
2026-03-16 14:55:41.165 INFO (MainThread) [custom_components.gree_custom.aiogree.device] Initialize the GREE Device API for: 580d0d3474fc (192.168.22.120:7000)
2026-03-16 14:55:41.165 DEBUG (MainThread) [custom_components.gree_custom.aiogree.device] Version: None, Key: cJS3J[omitted]
2026-03-16 14:55:41.165 DEBUG (MainThread) [custom_components.gree_custom.aiogree.device] Trying to get subdevices
2026-03-16 14:55:41.165 INFO (MainThread) [custom_components.gree_custom.aiogree.api] Trying to retrieve device encryption key v1
2026-03-16 14:55:41.167 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Bind Pack: {"mac": "580d0d3474fc", "t": "bind", "uid": 0}
2026-03-16 14:55:41.173 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Payload: {'cid': 'app', 'i': 1, 'pack': 'Fo0NJVLzyhX4Qh3bOqWhT4QPXnuPS0a5W/exMkAoHz3IfE1fYVsWM5kifDBw/LN1', 't': 'pack', 'tcid': '580d0d3474fc', 'uid': 0}
2026-03-16 14:55:41.173 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Fetching data from 192.168.22.120
2026-03-16 14:55:43.175 WARNING (MainThread) [custom_components.gree_custom.aiogree.api] Error communicating with 192.168.22.120. Attempt 1/2 |
2026-03-16 14:55:45.679 WARNING (MainThread) [custom_components.gree_custom.aiogree.api] Error communicating with 192.168.22.120. Attempt 2/2 |
2026-03-16 14:55:45.680 ERROR (MainThread) [custom_components.gree_custom.aiogree.api] Error getting device encryption key with version 1:
Error communicating with 192.168.22.120: Failed to communicate with device '192.168.22.120:7000' after 2 attempts
2026-03-16 14:55:45.680 INFO (MainThread) [custom_components.gree_custom.aiogree.api] Trying to retrieve device encryption key v2
2026-03-16 14:55:45.680 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Bind Pack: {"cid": "580d0d3474fc", "mac": "580d0d3474fc", "t": "bind", "uid": 0}
2026-03-16 14:55:45.694 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Payload: {'cid': 'app', 'i': 1, 'pack': 'Jtod3XIt89Dxs8SHPnkRBJt2vIVBwAvmIgk1XvjRhurELj0L3QVtft+hse+GRsWcl72qEoTtZbgS4JbKYrud0qPFjVyn', 't': 'pack', 'tcid': '580d0d3474fc', 'uid': 0, 'tag': 'qKWestnLPk4VGayIhFfpRg=='}
2026-03-16 14:55:45.694 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Fetching data from 192.168.22.120
2026-03-16 14:55:47.697 WARNING (MainThread) [custom_components.gree_custom.aiogree.api] Error communicating with 192.168.22.120. Attempt 1/2 |
2026-03-16 14:55:50.200 WARNING (MainThread) [custom_components.gree_custom.aiogree.api] Error communicating with 192.168.22.120. Attempt 2/2 |
2026-03-16 14:55:50.201 ERROR (MainThread) [custom_components.gree_custom.aiogree.api] Error getting device encryption key with version 2:
Error communicating with 192.168.22.120: Failed to communicate with device '192.168.22.120:7000' after 2 attempts
2026-03-16 14:55:50.201 ERROR (MainThread) [custom_components.gree_custom.config_flow] Error while binding
Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/api.py", line 364, in fetch_result
    received_json = await udp_request_async(
                    ^^^^^^^^^^^^^^^^^^^^^^^^
        ip_addr, port, json_data, max_connection_attempts, timeout
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 294, in udp_request_async
    raise ValueError(
        f"Failed to communicate with device '{ip_addr}:{port}' after {max_retries} attempts"
    )
ValueError: Failed to communicate with device '192.168.22.120:7000' after 2 attempts

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/api.py", line 598, in gree_get_device_key
    result = await get_result_pack(
             ^^^^^^^^^^^^^^^^^^^^^^
    ...<7 lines>...
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 420, in get_result_pack
    data = await fetch_result(
           ^^^^^^^^^^^^^^^^^^^
    ...<7 lines>...
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 368, in fetch_result
    raise ValueError(f"Error communicating with {ip_addr}: {err}") from err
ValueError: Error communicating with 192.168.22.120: Failed to communicate with device '192.168.22.120:7000' after 2 attempts

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/device.py", line 116, in bind_device
    ) = await gree_get_device_key(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<7 lines>...
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 629, in gree_get_device_key
    raise ValueError("Error getting device encryption key") from error
ValueError: Error getting device encryption key

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/config_flow.py", line 686, in async_step_manual_add
    self._discovered_subdevices = await self._devices[
                                  ^^^^^^^^^^^^^^^^^^^^
        _main_device.mac_address_sub
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ].fetch_sub_devices()
    ^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/device.py", line 175, in fetch_sub_devices
    await self.bind_device()
  File "/config/custom_components/gree_custom/aiogree/device.py", line 127, in bind_device
    raise GreeDeviceNotBoundError("Unable to obtain device key") from e
custom_components.gree_custom.aiogree.device.GreeDeviceNotBoundError: Unable to obtain device key
2026-03-16 14:55:50.206 DEBUG (MainThread) [custom_components.gree_custom.config_flow] Building main schema with previous values: {'host': '192.168.22.120', 'mac': '580d0d3474fc', 'advanced': {'port': 7000, 'encryption_version': 'Auto-Detect', 'encryption_key': 'cJS3JDim581t3914', 'uid': 0, 'disable_available_check': False, 'max_online_attempts': 5, 'timeout': 10}}
2026-03-16 14:55:56.078 INFO (MainThread) [custom_components.gree_custom.aiogree.device] Initialize the GREE Device API for: 580d0d3474fc (192.168.22.120:7000)
2026-03-16 14:55:56.078 DEBUG (MainThread) [custom_components.gree_custom.aiogree.device] Version: None, Key: cJS3J[omitted]
2026-03-16 14:55:56.078 DEBUG (MainThread) [custom_components.gree_custom.aiogree.device] Trying to get subdevices
2026-03-16 14:55:56.078 INFO (MainThread) [custom_components.gree_custom.aiogree.api] Trying to retrieve device encryption key v1
2026-03-16 14:55:56.079 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Bind Pack: {"mac": "580d0d3474fc", "t": "bind", "uid": 0}
2026-03-16 14:55:56.079 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Payload: {'cid': 'app', 'i': 1, 'pack': 'Fo0NJVLzyhX4Qh3bOqWhT4QPXnuPS0a5W/exMkAoHz3IfE1fYVsWM5kifDBw/LN1', 't': 'pack', 'tcid': '580d0d3474fc', 'uid': 0}
2026-03-16 14:55:56.079 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Fetching data from 192.168.22.120
2026-03-16 14:55:58.083 WARNING (MainThread) [custom_components.gree_custom.aiogree.api] Error communicating with 192.168.22.120. Attempt 1/2 |
2026-03-16 14:56:00.586 WARNING (MainThread) [custom_components.gree_custom.aiogree.api] Error communicating with 192.168.22.120. Attempt 2/2 |
2026-03-16 14:56:00.587 ERROR (MainThread) [custom_components.gree_custom.aiogree.api] Error getting device encryption key with version 1:
Error communicating with 192.168.22.120: Failed to communicate with device '192.168.22.120:7000' after 2 attempts
2026-03-16 14:56:00.587 INFO (MainThread) [custom_components.gree_custom.aiogree.api] Trying to retrieve device encryption key v2
2026-03-16 14:56:00.587 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Bind Pack: {"cid": "580d0d3474fc", "mac": "580d0d3474fc", "t": "bind", "uid": 0}
2026-03-16 14:56:00.589 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Payload: {'cid': 'app', 'i': 1, 'pack': 'Jtod3XIt89Dxs8SHPnkRBJt2vIVBwAvmIgk1XvjRhurELj0L3QVtft+hse+GRsWcl72qEoTtZbgS4JbKYrud0qPFjVyn', 't': 'pack', 'tcid': '580d0d3474fc', 'uid': 0, 'tag': 'qKWestnLPk4VGayIhFfpRg=='}
2026-03-16 14:56:00.590 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Fetching data from 192.168.22.120
2026-03-16 14:56:02.594 WARNING (MainThread) [custom_components.gree_custom.aiogree.api] Error communicating with 192.168.22.120. Attempt 1/2 |
2026-03-16 14:56:05.099 WARNING (MainThread) [custom_components.gree_custom.aiogree.api] Error communicating with 192.168.22.120. Attempt 2/2 |
2026-03-16 14:56:05.100 ERROR (MainThread) [custom_components.gree_custom.aiogree.api] Error getting device encryption key with version 2:
Error communicating with 192.168.22.120: Failed to communicate with device '192.168.22.120:7000' after 2 attempts
2026-03-16 14:56:05.100 ERROR (MainThread) [custom_components.gree_custom.config_flow] Error while binding
Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/api.py", line 364, in fetch_result
    received_json = await udp_request_async(
                    ^^^^^^^^^^^^^^^^^^^^^^^^
        ip_addr, port, json_data, max_connection_attempts, timeout
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 294, in udp_request_async
    raise ValueError(
        f"Failed to communicate with device '{ip_addr}:{port}' after {max_retries} attempts"
    )
ValueError: Failed to communicate with device '192.168.22.120:7000' after 2 attempts

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/api.py", line 598, in gree_get_device_key
    result = await get_result_pack(
             ^^^^^^^^^^^^^^^^^^^^^^
    ...<7 lines>...
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 420, in get_result_pack
    data = await fetch_result(
           ^^^^^^^^^^^^^^^^^^^
    ...<7 lines>...
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 368, in fetch_result
    raise ValueError(f"Error communicating with {ip_addr}: {err}") from err
ValueError: Error communicating with 192.168.22.120: Failed to communicate with device '192.168.22.120:7000' after 2 attempts

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/device.py", line 116, in bind_device
    ) = await gree_get_device_key(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<7 lines>...
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 629, in gree_get_device_key
    raise ValueError("Error getting device encryption key") from error
ValueError: Error getting device encryption key

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/config_flow.py", line 686, in async_step_manual_add
    self._discovered_subdevices = await self._devices[
                                  ^^^^^^^^^^^^^^^^^^^^
        _main_device.mac_address_sub
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ].fetch_sub_devices()
    ^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/device.py", line 175, in fetch_sub_devices
    await self.bind_device()
  File "/config/custom_components/gree_custom/aiogree/device.py", line 127, in bind_device
    raise GreeDeviceNotBoundError("Unable to obtain device key") from e
custom_components.gree_custom.aiogree.device.GreeDeviceNotBoundError: Unable to obtain device key
2026-03-16 14:56:05.105 DEBUG (MainThread) [custom_components.gree_custom.config_flow] Building main schema with previous values: {'host': '192.168.22.120', 'mac': '580d0d3474fc', 'advanced': {'port': 7000, 'encryption_version': 'Auto-Detect', 'encryption_key': 'cJS3JDim581t3914', 'uid': 0, 'disable_available_check': True, 'max_online_attempts': 5, 'timeout': 10}}

@p-monteiro
Copy link
Contributor Author

p-monteiro commented Mar 16, 2026

@ChillingSilence I suspected it was happening, but you are NOT on the latest commit. Try updating to the latest commit on the correct branch.
Confirm version in HA if it matches this: latest version

If you are on it, check the folders, delete the 2 pycache folders inside the integration and restart HA

Do not error if the key is wrong. If so, try the generic keys first before erroring.
Allows for less parameter repetition in API calls., which also use JSON dict for payloads up until being sent.
Also disallow the list of default broadcast addresses and use only the one provided by HA. Revise this if people report problems.
@ChillingSilence
Copy link

OK progress, just pulled the latest changes, now on commit c827321

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
services-up: info: copying legacy longrun home-assistant (no readiness notification)
s6-rc: info: service legacy-services successfully started
2026-03-18 08:47:21.238 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration ac_infinity which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2026-03-18 08:47:21.239 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration gree_custom which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2026-03-18 08:47:21.239 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration intesishome which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2026-03-18 08:47:21.240 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant2026-03-18 08:48:00.418 DEBUG (MainThread) [custom_components.gree_custom.config_flow] Found broadcast addresses from HA: ['255.255.255.255']
2026-03-18 08:48:00.420 DEBUG (MainThread) [custom_components.gree_custom.aiogree.transport] Sending broadcast to 255.255.255.255:7000
2026-03-18 08:48:00.420 DEBUG (MainThread) [custom_components.gree_custom.aiogree.transport] Waiting 5 seconds for UDP replies...
2026-03-18 08:48:05.421 DEBUG (MainThread) [custom_components.gree_custom.aiogree.transport] Discovery finished. Got 0 responses
2026-03-18 08:48:16.488 INFO (MainThread) [custom_components.gree_custom.aiogree.device] Initialize the GREE Device API for: 580d0d3474fc (192.168.22.120:7000)
2026-03-18 08:48:16.488 DEBUG (MainThread) [custom_components.gree_custom.aiogree.device] Version: None, Key: [omitted]
2026-03-18 08:48:16.488 DEBUG (MainThread) [custom_components.gree_custom.aiogree.device] Trying to get subdevices
2026-03-18 08:48:18.491 WARNING (MainThread) [custom_components.gree_custom.aiogree.transport] Error communicating with 192.168.22.120. Attempt 1/2
2026-03-18 08:48:20.995 WARNING (MainThread) [custom_components.gree_custom.aiogree.transport] Error communicating with 192.168.22.120. Attempt 2/2
2026-03-18 08:48:21.801 ERROR (MainThread) [custom_components.gree_custom.config_flow] Error while binding
Traceback (most recent call last):
  File "/usr/local/lib/python3.14/asyncio/tasks.py", line 488, in wait_for
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.14/site-packages/asyncio_dgram/aio.py", line 124, in recv
    data, addr = await self._recvq.get()
                 ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/queues.py", line 186, in get
    await getter
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 45, in udp_request
    received_data, _ = await asyncio.wait_for(recv_task, self.timeout)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/tasks.py", line 487, in wait_for
    async with timeouts.timeout(timeout):
               ~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/timeouts.py", line 114, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/device.py", line 150, in fetch_device_info
    self._raw_info = await gree_get_device_info(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        self._transport,
        ^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 511, in gree_get_device_info
    data: dict = await get_result_pack(
                 ^^^^^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 173, in get_result_pack
    recv_json = await transport.request_json(json_data)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 83, in request_json
    raw = await self.udp_request(json.dumps(payload).encode("utf-8"))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 77, in udp_request
    raise GreeConnectionError(
        f"Failed to communicate with device '{self.ip_addr}:{self.port}' after {self.max_retries} attempts"
    ) from last_error
custom_components.gree_custom.aiogree.errors.GreeConnectionError: Failed to communicate with device '192.168.22.120:7000' after 2 attempts

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/device.py", line 112, in bind_device
    await self.fetch_device_info()
  File "/config/custom_components/gree_custom/aiogree/device.py", line 155, in fetch_device_info
    raise GreeProtocolError(
        f"Failed fetching device info for {self._ip_addr}"
    ) from e
custom_components.gree_custom.aiogree.errors.GreeProtocolError: Failed fetching device info for 192.168.22.120

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/config_flow.py", line 675, in async_step_manual_add
    self._discovered_subdevices = await self._devices[
                                  ^^^^^^^^^^^^^^^^^^^^
        _main_device.mac_address_sub
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ].fetch_sub_devices()
    ^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/device.py", line 173, in fetch_sub_devices
    await self.bind_device()
  File "/config/custom_components/gree_custom/aiogree/device.py", line 114, in bind_device
    raise GreeBindingError(
        "Could not fetch device info before binding"
    ) from err
custom_components.gree_custom.aiogree.errors.GreeBindingError: Could not fetch device info before binding
2026-03-18 08:48:21.807 DEBUG (MainThread) [custom_components.gree_custom.config_flow] Building main schema with previous values: {'host': '192.168.22.120', 'mac': '580d0d3474fc', 'advanced': {'port': 7000, 'encryption_version': 'Auto-Detect', 'encryption_key': '', 'uid': 0, 'disable_available_check': False, 'max_online_attempts': 5, 'timeout': 10}}
2026-03-18 08:48:38.806 INFO (MainThread) [custom_components.gree_custom.aiogree.device] Initialize the GREE Device API for: 580d0d3474fc (192.168.22.120:7000)
2026-03-18 08:48:38.806 DEBUG (MainThread) [custom_components.gree_custom.aiogree.device] Version: None, Key: cJS3J[omitted]
2026-03-18 08:48:38.807 DEBUG (MainThread) [custom_components.gree_custom.aiogree.device] Trying to get subdevices
2026-03-18 08:48:40.808 WARNING (MainThread) [custom_components.gree_custom.aiogree.transport] Error communicating with 192.168.22.120. Attempt 1/2
2026-03-18 08:48:43.313 WARNING (MainThread) [custom_components.gree_custom.aiogree.transport] Error communicating with 192.168.22.120. Attempt 2/2
2026-03-18 08:48:44.115 ERROR (MainThread) [custom_components.gree_custom.config_flow] Error while binding
Traceback (most recent call last):
  File "/usr/local/lib/python3.14/asyncio/tasks.py", line 488, in wait_for
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.14/site-packages/asyncio_dgram/aio.py", line 124, in recv
    data, addr = await self._recvq.get()
                 ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/queues.py", line 186, in get
    await getter
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 45, in udp_request
    received_data, _ = await asyncio.wait_for(recv_task, self.timeout)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/tasks.py", line 487, in wait_for
    async with timeouts.timeout(timeout):
               ~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/timeouts.py", line 114, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/device.py", line 150, in fetch_device_info
    self._raw_info = await gree_get_device_info(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        self._transport,
        ^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 511, in gree_get_device_info
    data: dict = await get_result_pack(
                 ^^^^^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 173, in get_result_pack
    recv_json = await transport.request_json(json_data)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 83, in request_json
    raw = await self.udp_request(json.dumps(payload).encode("utf-8"))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 77, in udp_request
    raise GreeConnectionError(
        f"Failed to communicate with device '{self.ip_addr}:{self.port}' after {self.max_retries} attempts"
    ) from last_error
custom_components.gree_custom.aiogree.errors.GreeConnectionError: Failed to communicate with device '192.168.22.120:7000' after 2 attempts

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/device.py", line 112, in bind_device
    await self.fetch_device_info()
  File "/config/custom_components/gree_custom/aiogree/device.py", line 155, in fetch_device_info
    raise GreeProtocolError(
        f"Failed fetching device info for {self._ip_addr}"
    ) from e
custom_components.gree_custom.aiogree.errors.GreeProtocolError: Failed fetching device info for 192.168.22.120

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/config_flow.py", line 675, in async_step_manual_add
    self._discovered_subdevices = await self._devices[
                                  ^^^^^^^^^^^^^^^^^^^^
        _main_device.mac_address_sub
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ].fetch_sub_devices()
    ^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/device.py", line 173, in fetch_sub_devices
    await self.bind_device()
  File "/config/custom_components/gree_custom/aiogree/device.py", line 114, in bind_device
    raise GreeBindingError(
        "Could not fetch device info before binding"
    ) from err
custom_components.gree_custom.aiogree.errors.GreeBindingError: Could not fetch device info before binding
2026-03-18 08:48:44.121 DEBUG (MainThread) [custom_components.gree_custom.config_flow] Building main schema with previous values: {'host': '192.168.22.120', 'mac': '580d0d3474fc', 'advanced': {'port': 7000, 'encryption_version': 'Auto-Detect', 'encryption_key': 'cJS3JDim581t3914', 'uid': 0, 'disable_available_check': False, 'max_online_attempts': 5, 'timeout': 10}}

@p-monteiro
Copy link
Contributor Author

@ChillingSilence, Your device doesn't really want to play along with the fetch_device_info() for getting the firmware version, etc.

I allow binding to occur even with an error in fetch info; let's see if the binding fails now.
I also added tests to try fetching with the device key (if it binds successfully) and the generic ones.

Please try again in alpha.81 and provide the log, even if the bind is successful

@ChillingSilence
Copy link

@p-monteiro Hope this helps, using 5e3c35f, tried auto-add, then manually adding with IP+MAC, then manually specifying the encryption key on Auto Encryption Version.

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
services-up: info: copying legacy longrun home-assistant (no readiness notification)
s6-rc: info: service legacy-services successfully started
2026-03-18 15:05:19.951 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration ac_infinity which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2026-03-18 15:05:19.952 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration gree_custom which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2026-03-18 15:05:19.952 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration intesishome which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2026-03-18 15:05:19.953 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2026-03-18 15:07:23.642 DEBUG (MainThread) [custom_components.gree_custom.config_flow] Found broadcast addresses from HA: ['255.255.255.255']
2026-03-18 15:07:23.643 DEBUG (MainThread) [custom_components.gree_custom.aiogree.transport] Sending broadcast to 255.255.255.255:7000
2026-03-18 15:07:23.644 DEBUG (MainThread) [custom_components.gree_custom.aiogree.transport] Waiting 5 seconds for UDP replies... 
2026-03-18 15:07:28.645 DEBUG (MainThread) [custom_components.gree_custom.aiogree.transport] Discovery finished. Got 0 responses
2026-03-18 15:08:04.665 INFO (MainThread) [custom_components.gree_custom.aiogree.device] Initialize the GREE Device API for: 580d0d3474fc (192.168.22.120:7000)
2026-03-18 15:08:04.665 DEBUG (MainThread) [custom_components.gree_custom.aiogree.device] Version: None, Key: [omitted]
2026-03-18 15:08:06.668 WARNING (MainThread) [custom_components.gree_custom.aiogree.transport] Error communicating with 192.168.22.120. Attempt 1/2
2026-03-18 15:08:09.172 WARNING (MainThread) [custom_components.gree_custom.aiogree.transport] Error communicating with 192.168.22.120. Attempt 2/2
2026-03-18 15:08:09.974 ERROR (MainThread) [custom_components.gree_custom.aiogree.device] Could not fetch device info before binding
Traceback (most recent call last):
  File "/usr/local/lib/python3.14/asyncio/tasks.py", line 488, in wait_for
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.14/site-packages/asyncio_dgram/aio.py", line 124, in recv
    data, addr = await self._recvq.get()
                 ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/queues.py", line 186, in get
    await getter
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 45, in udp_request
    received_data, _ = await asyncio.wait_for(recv_task, self.timeout)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/tasks.py", line 487, in wait_for
    async with timeouts.timeout(timeout):
               ~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/timeouts.py", line 114, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/api.py", line 173, in get_result_pack
    recv_json = await transport.request_json(json_data)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 83, in request_json
    raw = await self.udp_request(json.dumps(payload).encode("utf-8"))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 77, in udp_request
    raise GreeConnectionError(
        f"Failed to communicate with device '{self.ip_addr}:{self.port}' after {self.max_retries} attempts"
    ) from last_error
custom_components.gree_custom.aiogree.errors.GreeConnectionError: Failed to communicate with device '192.168.22.120:7000' after 2 attempts

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/device.py", line 165, in fetch_device_info
    self._raw_info = await gree_get_device_info(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        self._transport, cipher or self._cipher
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 514, in gree_get_device_info
    data: dict = await get_result_pack(
                 ^^^^^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 178, in get_result_pack
    raise GreeProtocolError("Error in device response") from err
custom_components.gree_custom.aiogree.errors.GreeProtocolError: Error in device response

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/device.py", line 113, in bind_device
    await self.fetch_device_info()
  File "/config/custom_components/gree_custom/aiogree/device.py", line 170, in fetch_device_info
    raise GreeProtocolError(
        f"Failed fetching device info for {self._ip_addr}"
    ) from e
custom_components.gree_custom.aiogree.errors.GreeProtocolError: Failed fetching device info for 192.168.22.120
2026-03-18 15:08:09.980 INFO (MainThread) [custom_components.gree_custom.aiogree.api] Trying to perform binding. Testing both versions with generic keys
2026-03-18 15:08:09.980 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Requesting bind to device with encryption key v1
2026-03-18 15:08:09.981 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Bind Pack: {'mac': '580d0d3474fc', 't': 'bind', 'uid': 0}
2026-03-18 15:08:09.981 DEBUG (MainThread) [custom_components.gree_custom.aiogree.cipher] Encrypting data (V1): {"mac": "580d0d3474fc", "t": "bind", "uid": 0}
2026-03-18 15:08:09.987 DEBUG (MainThread) [custom_components.gree_custom.aiogree.cipher] Encrypted data (V1): Fo0NJVLzyhX4Qh3bOqWhT4QPXnuPS0a5W/exMkAoHz3IfE1fYVsWM5kifDBw/LN1
2026-03-18 15:08:09.988 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Payload: {'cid': 'app', 'i': 1, 'pack': 'Fo0NJVLzyhX4Qh3bOqWhT4QPXnuPS0a5W/exMkAoHz3IfE1fYVsWM5kifDBw/LN1', 't': 'pack', 'tcid': '580d0d3474fc', 'uid': 0}
2026-03-18 15:08:11.989 WARNING (MainThread) [custom_components.gree_custom.aiogree.transport] Error communicating with 192.168.22.120. Attempt 1/2
2026-03-18 15:08:14.494 WARNING (MainThread) [custom_components.gree_custom.aiogree.transport] Error communicating with 192.168.22.120. Attempt 2/2
2026-03-18 15:08:15.295 ERROR (MainThread) [custom_components.gree_custom.aiogree.api] Error in bind request using encryption key with version 1
Traceback (most recent call last):
  File "/usr/local/lib/python3.14/asyncio/tasks.py", line 488, in wait_for
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.14/site-packages/asyncio_dgram/aio.py", line 124, in recv
    data, addr = await self._recvq.get()
                 ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/queues.py", line 186, in get
    await getter
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 45, in udp_request
    received_data, _ = await asyncio.wait_for(recv_task, self.timeout)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/tasks.py", line 487, in wait_for
    async with timeouts.timeout(timeout):
               ~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/timeouts.py", line 114, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/api.py", line 173, in get_result_pack
    recv_json = await transport.request_json(json_data)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 83, in request_json
    raw = await self.udp_request(json.dumps(payload).encode("utf-8"))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 77, in udp_request
    raise GreeConnectionError(
        f"Failed to communicate with device '{self.ip_addr}:{self.port}' after {self.max_retries} attempts"
    ) from last_error
custom_components.gree_custom.aiogree.errors.GreeConnectionError: Failed to communicate with device '192.168.22.120:7000' after 2 attempts

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/api.py", line 359, in gree_try_bind
    result = await get_result_pack(json_payload, cipher, transport)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 178, in get_result_pack
    raise GreeProtocolError("Error in device response") from err
custom_components.gree_custom.aiogree.errors.GreeProtocolError: Error in device response
2026-03-18 15:08:15.300 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Requesting bind to device with encryption key v2
2026-03-18 15:08:15.300 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Bind Pack: {'cid': '580d0d3474fc', 'mac': '580d0d3474fc', 't': 'bind', 'uid': 0}
2026-03-18 15:08:15.300 DEBUG (MainThread) [custom_components.gree_custom.aiogree.cipher] Encrypting data (V2): {"cid": "580d0d3474fc", "mac": "580d0d3474fc", "t": "bind", "uid": 0}
2026-03-18 15:08:15.312 DEBUG (MainThread) [custom_components.gree_custom.aiogree.cipher] Encrypted data (V2): Jtod3XIt89Dxs8SHPnkRBJt2vIVBwAvmIgk1XvjRhurELj0L3QVtft+hse+GRsWcl72qEoTtZbgS4JbKYrud0qPFjVyn, tag='qKWestnLPk4VGayIhFfpRg=='
2026-03-18 15:08:15.312 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Payload: {'cid': 'app', 'i': 1, 'pack': 'Jtod3XIt89Dxs8SHPnkRBJt2vIVBwAvmIgk1XvjRhurELj0L3QVtft+hse+GRsWcl72qEoTtZbgS4JbKYrud0qPFjVyn', 't': 'pack', 'tcid': '580d0d3474fc', 'uid': 0, 'tag': 'qKWestnLPk4VGayIhFfpRg=='}
2026-03-18 15:08:17.314 WARNING (MainThread) [custom_components.gree_custom.aiogree.transport] Error communicating with 192.168.22.120. Attempt 1/2
2026-03-18 15:08:19.819 WARNING (MainThread) [custom_components.gree_custom.aiogree.transport] Error communicating with 192.168.22.120. Attempt 2/2
2026-03-18 15:08:20.620 ERROR (MainThread) [custom_components.gree_custom.aiogree.api] Error in bind request using encryption key with version 2
Traceback (most recent call last):
  File "/usr/local/lib/python3.14/asyncio/tasks.py", line 488, in wait_for
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.14/site-packages/asyncio_dgram/aio.py", line 124, in recv
    data, addr = await self._recvq.get()
                 ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/queues.py", line 186, in get
    await getter
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 45, in udp_request
    received_data, _ = await asyncio.wait_for(recv_task, self.timeout)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/tasks.py", line 487, in wait_for
    async with timeouts.timeout(timeout):
               ~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/timeouts.py", line 114, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/api.py", line 173, in get_result_pack
    recv_json = await transport.request_json(json_data)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 83, in request_json
    raw = await self.udp_request(json.dumps(payload).encode("utf-8"))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 77, in udp_request
    raise GreeConnectionError(
        f"Failed to communicate with device '{self.ip_addr}:{self.port}' after {self.max_retries} attempts"
    ) from last_error
custom_components.gree_custom.aiogree.errors.GreeConnectionError: Failed to communicate with device '192.168.22.120:7000' after 2 attempts

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/api.py", line 359, in gree_try_bind
    result = await get_result_pack(json_payload, cipher, transport)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 178, in get_result_pack
    raise GreeProtocolError("Error in device response") from err
custom_components.gree_custom.aiogree.errors.GreeProtocolError: Error in device response
2026-03-18 15:08:20.626 ERROR (MainThread) [custom_components.gree_custom.config_flow] Error while binding
Traceback (most recent call last):
  File "/usr/local/lib/python3.14/asyncio/tasks.py", line 488, in wait_for
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.14/site-packages/asyncio_dgram/aio.py", line 124, in recv
    data, addr = await self._recvq.get()
                 ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/queues.py", line 186, in get
    await getter
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 45, in udp_request
    received_data, _ = await asyncio.wait_for(recv_task, self.timeout)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/tasks.py", line 487, in wait_for
    async with timeouts.timeout(timeout):
               ~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/timeouts.py", line 114, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/api.py", line 173, in get_result_pack
    recv_json = await transport.request_json(json_data)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 83, in request_json
    raw = await self.udp_request(json.dumps(payload).encode("utf-8"))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 77, in udp_request
    raise GreeConnectionError(
        f"Failed to communicate with device '{self.ip_addr}:{self.port}' after {self.max_retries} attempts"
    ) from last_error
custom_components.gree_custom.aiogree.errors.GreeConnectionError: Failed to communicate with device '192.168.22.120:7000' after 2 attempts

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/api.py", line 359, in gree_try_bind
    result = await get_result_pack(json_payload, cipher, transport)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 178, in get_result_pack
    raise GreeProtocolError("Error in device response") from err
custom_components.gree_custom.aiogree.errors.GreeProtocolError: Error in device response

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/config_flow.py", line 675, in async_step_manual_add
    self._discovered_subdevices = await self._devices[
                                  ^^^^^^^^^^^^^^^^^^^^
        _main_device.mac_address_sub
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ].bind_device()
    ^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/device.py", line 118, in bind_device
    key, version = await gree_try_bind(
                   ^^^^^^^^^^^^^^^^^^^^
    ...<5 lines>...
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 400, in gree_try_bind
    raise GreeBindingError(
        f"Binding failed: Unable to obtain valid encryption version and key pair for {mac_addr} at {transport.ip_addr}"
    ) from error
custom_components.gree_custom.aiogree.errors.GreeBindingError: Binding failed: Unable to obtain valid encryption version and key pair for 580d0d3474fc at 192.168.22.120
2026-03-18 15:08:20.628 DEBUG (MainThread) [custom_components.gree_custom.config_flow] Building main schema with previous values: {'host': '192.168.22.120', 'mac': '580d0d3474fc', 'advanced': {'port': 7000, 'encryption_version': 'Auto-Detect', 'encryption_key': '', 'uid': 0, 'disable_available_check': False, 'max_online_attempts': 5, 'timeout': 10}}
2026-03-18 15:08:42.549 INFO (MainThread) [custom_components.gree_custom.aiogree.device] Initialize the GREE Device API for: 580d0d3474fc (192.168.22.120:7000)
2026-03-18 15:08:42.549 DEBUG (MainThread) [custom_components.gree_custom.aiogree.device] Version: None, Key: cJS3J[omitted]
2026-03-18 15:08:44.552 WARNING (MainThread) [custom_components.gree_custom.aiogree.transport] Error communicating with 192.168.22.120. Attempt 1/2
2026-03-18 15:08:47.056 WARNING (MainThread) [custom_components.gree_custom.aiogree.transport] Error communicating with 192.168.22.120. Attempt 2/2
2026-03-18 15:08:47.858 ERROR (MainThread) [custom_components.gree_custom.aiogree.device] Could not fetch device info before binding
Traceback (most recent call last):
  File "/usr/local/lib/python3.14/asyncio/tasks.py", line 488, in wait_for
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.14/site-packages/asyncio_dgram/aio.py", line 124, in recv
    data, addr = await self._recvq.get()
                 ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/queues.py", line 186, in get
    await getter
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 45, in udp_request
    received_data, _ = await asyncio.wait_for(recv_task, self.timeout)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/tasks.py", line 487, in wait_for
    async with timeouts.timeout(timeout):
               ~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/timeouts.py", line 114, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/api.py", line 173, in get_result_pack
    recv_json = await transport.request_json(json_data)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 83, in request_json
    raw = await self.udp_request(json.dumps(payload).encode("utf-8"))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 77, in udp_request
    raise GreeConnectionError(
        f"Failed to communicate with device '{self.ip_addr}:{self.port}' after {self.max_retries} attempts"
    ) from last_error
custom_components.gree_custom.aiogree.errors.GreeConnectionError: Failed to communicate with device '192.168.22.120:7000' after 2 attempts

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/device.py", line 165, in fetch_device_info
    self._raw_info = await gree_get_device_info(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        self._transport, cipher or self._cipher
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 514, in gree_get_device_info
    data: dict = await get_result_pack(
                 ^^^^^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 178, in get_result_pack
    raise GreeProtocolError("Error in device response") from err
custom_components.gree_custom.aiogree.errors.GreeProtocolError: Error in device response

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/device.py", line 113, in bind_device
    await self.fetch_device_info()
  File "/config/custom_components/gree_custom/aiogree/device.py", line 170, in fetch_device_info
    raise GreeProtocolError(
        f"Failed fetching device info for {self._ip_addr}"
    ) from e
custom_components.gree_custom.aiogree.errors.GreeProtocolError: Failed fetching device info for 192.168.22.120
2026-03-18 15:08:47.864 INFO (MainThread) [custom_components.gree_custom.aiogree.api] Trying to perform binding. Prefering provided key (cJS3J[redacted])
2026-03-18 15:08:47.864 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Requesting bind to device with encryption key v1
2026-03-18 15:08:47.864 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Bind Pack: {'mac': '580d0d3474fc', 't': 'bind', 'uid': 0}
2026-03-18 15:08:47.864 DEBUG (MainThread) [custom_components.gree_custom.aiogree.cipher] Encrypting data (V1): {"mac": "580d0d3474fc", "t": "bind", "uid": 0}
2026-03-18 15:08:47.864 DEBUG (MainThread) [custom_components.gree_custom.aiogree.cipher] Encrypted data (V1): Fo0NJVLzyhX4Qh3bOqWhT4QPXnuPS0a5W/exMkAoHz3IfE1fYVsWM5kifDBw/LN1
2026-03-18 15:08:47.864 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Payload: {'cid': 'app', 'i': 1, 'pack': 'Fo0NJVLzyhX4Qh3bOqWhT4QPXnuPS0a5W/exMkAoHz3IfE1fYVsWM5kifDBw/LN1', 't': 'pack', 'tcid': '580d0d3474fc', 'uid': 0}
2026-03-18 15:08:49.866 WARNING (MainThread) [custom_components.gree_custom.aiogree.transport] Error communicating with 192.168.22.120. Attempt 1/2
2026-03-18 15:08:52.369 WARNING (MainThread) [custom_components.gree_custom.aiogree.transport] Error communicating with 192.168.22.120. Attempt 2/2
2026-03-18 15:08:53.171 ERROR (MainThread) [custom_components.gree_custom.aiogree.api] Error in bind request using encryption key with version 1
Traceback (most recent call last):
  File "/usr/local/lib/python3.14/asyncio/tasks.py", line 488, in wait_for
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.14/site-packages/asyncio_dgram/aio.py", line 124, in recv
    data, addr = await self._recvq.get()
                 ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/queues.py", line 186, in get
    await getter
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 45, in udp_request
    received_data, _ = await asyncio.wait_for(recv_task, self.timeout)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/tasks.py", line 487, in wait_for
    async with timeouts.timeout(timeout):
               ~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/timeouts.py", line 114, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/api.py", line 173, in get_result_pack
    recv_json = await transport.request_json(json_data)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 83, in request_json
    raw = await self.udp_request(json.dumps(payload).encode("utf-8"))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 77, in udp_request
    raise GreeConnectionError(
        f"Failed to communicate with device '{self.ip_addr}:{self.port}' after {self.max_retries} attempts"
    ) from last_error
custom_components.gree_custom.aiogree.errors.GreeConnectionError: Failed to communicate with device '192.168.22.120:7000' after 2 attempts

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/api.py", line 359, in gree_try_bind
    result = await get_result_pack(json_payload, cipher, transport)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 178, in get_result_pack
    raise GreeProtocolError("Error in device response") from err
custom_components.gree_custom.aiogree.errors.GreeProtocolError: Error in device response
2026-03-18 15:08:53.176 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Requesting bind to device with encryption key v2
2026-03-18 15:08:53.176 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Bind Pack: {'cid': '580d0d3474fc', 'mac': '580d0d3474fc', 't': 'bind', 'uid': 0}
2026-03-18 15:08:53.176 DEBUG (MainThread) [custom_components.gree_custom.aiogree.cipher] Encrypting data (V2): {"cid": "580d0d3474fc", "mac": "580d0d3474fc", "t": "bind", "uid": 0}
2026-03-18 15:08:53.177 DEBUG (MainThread) [custom_components.gree_custom.aiogree.cipher] Encrypted data (V2): Jtod3XIt89Dxs8SHPnkRBJt2vIVBwAvmIgk1XvjRhurELj0L3QVtft+hse+GRsWcl72qEoTtZbgS4JbKYrud0qPFjVyn, tag='qKWestnLPk4VGayIhFfpRg=='
2026-03-18 15:08:53.177 DEBUG (MainThread) [custom_components.gree_custom.aiogree.api] Payload: {'cid': 'app', 'i': 1, 'pack': 'Jtod3XIt89Dxs8SHPnkRBJt2vIVBwAvmIgk1XvjRhurELj0L3QVtft+hse+GRsWcl72qEoTtZbgS4JbKYrud0qPFjVyn', 't': 'pack', 'tcid': '580d0d3474fc', 'uid': 0, 'tag': 'qKWestnLPk4VGayIhFfpRg=='}
2026-03-18 15:08:55.180 WARNING (MainThread) [custom_components.gree_custom.aiogree.transport] Error communicating with 192.168.22.120. Attempt 1/2
2026-03-18 15:08:57.684 WARNING (MainThread) [custom_components.gree_custom.aiogree.transport] Error communicating with 192.168.22.120. Attempt 2/2
2026-03-18 15:08:58.485 ERROR (MainThread) [custom_components.gree_custom.aiogree.api] Error in bind request using encryption key with version 2
Traceback (most recent call last):
  File "/usr/local/lib/python3.14/asyncio/tasks.py", line 488, in wait_for
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.14/site-packages/asyncio_dgram/aio.py", line 124, in recv
    data, addr = await self._recvq.get()
                 ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/queues.py", line 186, in get
    await getter
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 45, in udp_request
    received_data, _ = await asyncio.wait_for(recv_task, self.timeout)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/tasks.py", line 487, in wait_for
    async with timeouts.timeout(timeout):
               ~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/timeouts.py", line 114, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/api.py", line 173, in get_result_pack
    recv_json = await transport.request_json(json_data)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 83, in request_json
    raw = await self.udp_request(json.dumps(payload).encode("utf-8"))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 77, in udp_request
    raise GreeConnectionError(
        f"Failed to communicate with device '{self.ip_addr}:{self.port}' after {self.max_retries} attempts"
    ) from last_error
custom_components.gree_custom.aiogree.errors.GreeConnectionError: Failed to communicate with device '192.168.22.120:7000' after 2 attempts

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/api.py", line 359, in gree_try_bind
    result = await get_result_pack(json_payload, cipher, transport)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 178, in get_result_pack
    raise GreeProtocolError("Error in device response") from err
custom_components.gree_custom.aiogree.errors.GreeProtocolError: Error in device response
2026-03-18 15:08:58.490 ERROR (MainThread) [custom_components.gree_custom.config_flow] Error while binding
Traceback (most recent call last):
  File "/usr/local/lib/python3.14/asyncio/tasks.py", line 488, in wait_for
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.14/site-packages/asyncio_dgram/aio.py", line 124, in recv
    data, addr = await self._recvq.get()
                 ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/queues.py", line 186, in get
    await getter
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 45, in udp_request
    received_data, _ = await asyncio.wait_for(recv_task, self.timeout)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/tasks.py", line 487, in wait_for
    async with timeouts.timeout(timeout):
               ~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/local/lib/python3.14/asyncio/timeouts.py", line 114, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/api.py", line 173, in get_result_pack
    recv_json = await transport.request_json(json_data)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 83, in request_json
    raw = await self.udp_request(json.dumps(payload).encode("utf-8"))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/transport.py", line 77, in udp_request
    raise GreeConnectionError(
        f"Failed to communicate with device '{self.ip_addr}:{self.port}' after {self.max_retries} attempts"
    ) from last_error
custom_components.gree_custom.aiogree.errors.GreeConnectionError: Failed to communicate with device '192.168.22.120:7000' after 2 attempts

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/aiogree/api.py", line 359, in gree_try_bind
    result = await get_result_pack(json_payload, cipher, transport)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 178, in get_result_pack
    raise GreeProtocolError("Error in device response") from err
custom_components.gree_custom.aiogree.errors.GreeProtocolError: Error in device response

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/gree_custom/config_flow.py", line 675, in async_step_manual_add
    self._discovered_subdevices = await self._devices[
                                  ^^^^^^^^^^^^^^^^^^^^
        _main_device.mac_address_sub
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ].bind_device()
    ^^^^^^^^^^^^^^^
  File "/config/custom_components/gree_custom/aiogree/device.py", line 118, in bind_device
    key, version = await gree_try_bind(
                   ^^^^^^^^^^^^^^^^^^^^
    ...<5 lines>...
    )
    ^
  File "/config/custom_components/gree_custom/aiogree/api.py", line 400, in gree_try_bind
    raise GreeBindingError(
        f"Binding failed: Unable to obtain valid encryption version and key pair for {mac_addr} at {transport.ip_addr}"
    ) from error
custom_components.gree_custom.aiogree.errors.GreeBindingError: Binding failed: Unable to obtain valid encryption version and key pair for 580d0d3474fc at 192.168.22.120
2026-03-18 15:08:58.491 DEBUG (MainThread) [custom_components.gree_custom.config_flow] Building main schema with previous values: {'host': '192.168.22.120', 'mac': '580d0d3474fc', 'advanced': {'port': 7000, 'encryption_version': 'Auto-Detect', 'encryption_key': 'cJS3JDim581t3914', 'uid': 0, 'disable_available_check': False, 'max_online_attempts': 5, 'timeout': 10}}

@p-monteiro
Copy link
Contributor Author

p-monteiro commented Mar 18, 2026

That's some really odd behaviour there @ChillingSilence.
There's definitely something wrong with the connection, either on HA, integration, or the host.

Just so we are on the same page:

  • What is the HA setup? Where is it installed? What's the network configuration?
  • Does the device work correctly on the public version of this integration (https://github.com/RobHofmann/HomeAssistant-GreeClimateComponent/tree/master)? If so, what is the encryption version it is using?
  • Is the device responding to pings ping 192.168.22.120 from both inside the HA container (if applicable) and its host
  • If on a Linux Docker host, what's the output of nc -u -zv 192.168.22.120 7000?

@ChillingSilence
Copy link

Home Assistant is an x86_64 HAOS install. The network is a flat 192.168.22.0/24 with an Edgerouter-X giving out DHCP and a Ubiquiti U6-LR. There's no firewall or anything on the LAN, the router is doing NAT only and the WiFi is bridging to the LAN. Other things that use broadcasting are fine, like Chromecast etc

I've just checked now. It seems the device doesn't work on the other public version either.

It responds to pings from within the HA "Terminal & SSH" addon, and also from another workstation on my network.
Netcat shows no output when run either from WSL on the workstation PC or from within HAOS.

It is a relatively new AC purchase / install / unit so I wonder if it's perhaps just a new type? I found this repo originally and this PR seemed to be getting the most love do honestly I started here. Trying the other primary public repo now though and sadly also no joy.

The app shows the following, in case it's helpful:
Screenshot_20260319-101549
Screenshot_20260319-101554

Ran nmap and it showed all TCP ports closed, but it does respond to pings... Confirmed it's the right device too, the arp table matches the DHCP lease which matches the details from luc10/gree-api-client
The details I'm getting returned from the Gree AU server are correct (I'm in New Zealand) and if I try another server (like NA or Russia) the Python script fails, so I'm confident it's being provided the right information back.

@p-monteiro
Copy link
Contributor Author

p-monteiro commented Mar 18, 2026

@ChillingSilence ahh, alright. I was under the assumption it was working in the "master" version, and I was actually losing my head, because nothing is functionally different here. So if that is not the case, we shall move to another kind of troubleshooting.

I'm not sure the device information is very useful for Gree. I have the same model ID and version as you. However, my firmware is in the range v1.XX and yours is at v3.XX

Netcat shows no output, correct? Or does it error?

I think I read somewhere that Gree uses MQTT in some units, so maybe newer firmwares dropped the legacy UDP protocol we are using here. I will dig around.

Can you send the complete model of your indoor unit?

@ChillingSilence
Copy link

Ahh my apologies @p-monteiro I had only just tried it now with the master version so didn't know it wasn't behaving there otherwise. My bad.

Netcat shows now output, correct. No errors, just, nothing.

I have 2x Gree Kingfisher GWH24ATEXF units. I can confirm they work on the WiFi, and I can disconnect my phone to use 4G and still control them... So they're talking somehow. I wonder if I can packet capture from the router 🤔

@p-monteiro
Copy link
Contributor Author

@ChillingSilence, packet capture would be the best way if you actually know how to do it. I'm not good at it.

@ChillingSilence
Copy link

It looks like it's still doing stuff on UDP port 7000? All the five packets are pretty much the same
image
The actual commands afterwards from "the cloud" seem to happen on TCP port 1982.

Is this helpful as a starting point thought @p-monteiro ?
Grateful for your assistance, thanks again 🙏

@p-monteiro
Copy link
Contributor Author

@ChillingSilence It's performing the normal {"t":"scan"} broadcast. What is the device sending back after those?
src: 192.168.22.120 dst: 192.168.22.86

Also, I would prefer not to pollute this PR with this since it is unrelated to it. Open a new issue, and we can continue discussing there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants