diff --git a/README.md b/README.md index 0c106cf..882428b 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). @@ -58,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: - - name: "First AC" - host: "192.168.1.101" - mac: "20-FA-BB-12-34-56" - encryption_version: 2 - ``` +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 diff --git a/custom_components/gree_custom/aiogree/api.py b/custom_components/gree_custom/aiogree/api.py index 04c6de8..1de54d6 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 2b3ca0e..c547d4b 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 205af6a..e6a894c 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 9fadd62..163a705 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 3a01925..3d5c0ac 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" }