Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions custom_components/gree_custom/aiogree/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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", "")
Expand Down
2 changes: 1 addition & 1 deletion custom_components/gree_custom/aiogree/cipher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 5 additions & 7 deletions custom_components/gree_custom/aiogree/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/gree_custom/aiogree/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion custom_components/gree_custom/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Loading