From 8ddd64b17bd294fce7745eb0b08a86050791228e Mon Sep 17 00:00:00 2001 From: Pedro Monteiro Date: Wed, 17 Jun 2026 12:32:14 +0100 Subject: [PATCH 1/3] Fix linting problems --- custom_components/gree_custom/aiogree/api.py | 4 ++-- custom_components/gree_custom/aiogree/cipher.py | 2 +- custom_components/gree_custom/aiogree/device.py | 12 +++++------- custom_components/gree_custom/aiogree/transport.py | 2 +- custom_components/gree_custom/manifest.json | 2 +- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/custom_components/gree_custom/aiogree/api.py b/custom_components/gree_custom/aiogree/api.py index 04c6de83..1de54d6b 100644 --- a/custom_components/gree_custom/aiogree/api.py +++ b/custom_components/gree_custom/aiogree/api.py @@ -515,7 +515,7 @@ async def gree_set_status( async def gree_get_device_info( transport: GreeTransport, cipher: CipherBase | None = None -) -> dict[str, str | None]: +) -> dict[str, str | dict | None]: """Tries to retrive the device info.""" data: dict = await get_result_pack( @@ -526,7 +526,7 @@ async def gree_get_device_info( _LOGGER.debug("Got device info: %s", data) - info: dict[str, str | None] = {} + info: dict[str, str | dict | None] = {} info["raw"] = data info["firmware_version"], info["firmware_code"] = extract_version(data) info["mac"] = data.get("mac", "") diff --git a/custom_components/gree_custom/aiogree/cipher.py b/custom_components/gree_custom/aiogree/cipher.py index 2b3ca0e5..c547d4bd 100644 --- a/custom_components/gree_custom/aiogree/cipher.py +++ b/custom_components/gree_custom/aiogree/cipher.py @@ -141,7 +141,7 @@ def encrypt(self, data: str) -> tuple[str, str]: _LOGGER.debug("Encrypted data (V2): %s, tag='%s'", encoded, tag_encoded) return encoded, tag_encoded - def decrypt(self, data: str, tag: str) -> str: + def decrypt(self, data: str, tag: str | None) -> str: """Decrypt data with V2 and verify the data with the tag.""" _LOGGER.debug("Decrypting data (V2): %s, tag=%s", data, tag) diff --git a/custom_components/gree_custom/aiogree/device.py b/custom_components/gree_custom/aiogree/device.py index 205af6a0..e6a894c1 100755 --- a/custom_components/gree_custom/aiogree/device.py +++ b/custom_components/gree_custom/aiogree/device.py @@ -151,7 +151,7 @@ async def bind_device(self) -> bool: return True - async def fetch_device_info(self, cipher: CipherBase = None): + async def fetch_device_info(self, cipher: CipherBase | None = None): """Updates the device info fields.""" try: self._raw_info = await gree_get_device_info( @@ -321,12 +321,10 @@ def _set_device_status(self, props: dict[GreeProp, int]) -> None: """Sets a new local device status. Use 'update_device_status' to update the device.""" self._new_raw_state.update(props) - def _bool_from_raw_state( - self, prop: GreeProp, default: int | None = 0 - ) -> bool | None: + def _bool_from_raw_state(self, prop: GreeProp, default: int = 0) -> bool: prop_value: int | None = self._get_prop_raw(prop, default) - return None if prop_value is None else bool(prop_value) + return bool(prop_value) def _remove_unsupported_props(self): """Remove unsupported properties from the list to update.""" @@ -512,9 +510,9 @@ def is_bound(self) -> bool: return self._is_bound @property - def has_hvac_error(self) -> bool | None: + def has_hvac_error(self) -> bool: """Return if there is an error with the device.""" - return self._bool_from_raw_state(GreeProp.FAULT, None) + return self._bool_from_raw_state(GreeProp.FAULT) @property def beeper(self) -> bool: diff --git a/custom_components/gree_custom/aiogree/transport.py b/custom_components/gree_custom/aiogree/transport.py index 9fadd629..163a705e 100644 --- a/custom_components/gree_custom/aiogree/transport.py +++ b/custom_components/gree_custom/aiogree/transport.py @@ -29,7 +29,7 @@ async def udp_request( ) -> bytes: """Send a payload data to the device and reads the response.""" - last_error: Exception = None + last_error: Exception | None = None for attempt in range(self.max_retries): stream: asyncio_dgram.DatagramClient | None = None diff --git a/custom_components/gree_custom/manifest.json b/custom_components/gree_custom/manifest.json index 3a019259..3d5c0acc 100755 --- a/custom_components/gree_custom/manifest.json +++ b/custom_components/gree_custom/manifest.json @@ -9,5 +9,5 @@ "iot_class": "local_polling", "issue_tracker": "https://github.com/RobHofmann/HomeAssistant-GreeClimateComponent/issues", "requirements": ["pycryptodome", "asyncio_dgram"], - "version": "4.0.0-alpha.99" + "version": "4.0.0-alpha.100" } From 0232e802ffef18bca43adf85a3da992c5c9000d1 Mon Sep 17 00:00:00 2001 From: Pedro Monteiro Date: Wed, 17 Jun 2026 12:39:19 +0100 Subject: [PATCH 2/3] Fix Readme manual configuration --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0c106cf9..fb6bc7d3 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ This integration connects directly to your HVAC devices via their IP address on > [!NOTE] > This integration only supports the Gree UDP protocol. If you have a newer firmware/device that only communicates using the new MQTT protocol, this integration will not work. +> Use [this](https://github.com/davo22/homeassistant-gree-cloud) for a different feature set and support for Gree Cloud For a comprehensive list of tested devices, see [Supported Devices](supported-devices.md). @@ -60,11 +61,11 @@ See [`manual-configuration.yaml`](manual-configuration.yaml) for a complete conf Basic example: ```yaml - gree: - - name: "First AC" - host: "192.168.1.101" - mac: "20-FA-BB-12-34-56" - encryption_version: 2 + gree_custom: + - host: "192.168.1.101" + mac: "20-FA-BB-12-34-56" + devices: + - device_name: "Gree AC" # Name for the AC unit | str | default = "Gree AC ]" ``` ### Obtaining the Encryption Key From 0c8df044d023c3c189dba6fc33e73bbb2cc3e9ce Mon Sep 17 00:00:00 2001 From: Pedro Monteiro Date: Wed, 17 Jun 2026 12:41:18 +0100 Subject: [PATCH 3/3] Fix indentation in Readme --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index fb6bc7d3..882428bf 100644 --- a/README.md +++ b/README.md @@ -59,14 +59,14 @@ You can also **Reconfigure** a device by changing its options. Saving any change See [`manual-configuration.yaml`](manual-configuration.yaml) for a complete configuration example with all available options and detailed comments. - Basic example: - ```yaml - gree_custom: - - host: "192.168.1.101" - mac: "20-FA-BB-12-34-56" - devices: - - device_name: "Gree AC" # Name for the AC unit | str | default = "Gree AC ]" - ``` +Basic example: +```yaml +gree_custom: + - host: "192.168.1.100" + mac: "20-FA-BB-12-34-56" + devices: + - device_name: "Gree AC" +``` ### Obtaining the Encryption Key