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
23 changes: 17 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,28 @@ While reconfiguring, devices not selected will be removed from the entry.

### Manual - YAML Configuration

See [`manual-configuration.yaml`](manual-configuration.yaml) for a complete configuration example with all available options and detailed comments.
You can set the integration up in `configuration.yaml` instead of the UI.

Basic example:
Minimal example with one local device:
```yaml
gree_custom:
- host: "192.168.1.100"
mac: "20-FA-BB-12-34-56"
devices:
- device_name: "Gree AC"
- devices:
"20-FA-BB-12-34-56":
connection:
local:
host: "192.168.1.100"
options:
name: "Gree AC"
```

Home Assistant reads the YAML at every start. It creates the config entry when it is missing and updates it when the YAML changed. An unchanged YAML causes no reload. A device you remove from the YAML is removed from the config entry, so do not change a YAML managed entry in the UI: the next restart puts the YAML values back.

Every item in the list is one config entry. An item with a `cloud` block is the entry for that Gree account, and the one item without a `cloud` block is the entry for all local-only devices. A device that is already in another config entry is skipped, with an error in the log and a repair issue.

A `cloud` block logs in to the Gree account only on the first import, and again when you change the email, region or password. Every login ends the other sessions of that account, so the Gree app logs you out at that moment. An unchanged `cloud` block reuses the stored session.

See [`manual-configuration.yaml`](manual-configuration.yaml) for a complete configuration example with all available options and detailed comments.

## Connection Methods and Configuration

The integration supports both the local UDP protocol and the MQTT cloud protocol to communicate with the devices. It also supports enhancing local devices with cloud info during discovery.
Expand Down
38 changes: 38 additions & 0 deletions custom_components/gree_custom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from .aiogree.errors import GreeConnectionError
from .aiogree.transport_mqtt import GreeMqttTransport
from .aiogree.transport_udp import GreeUdpTransport
from .config_schema import CONFIG_SCHEMA as CONFIG_SCHEMA

# Local imports
from .const import (
Expand Down Expand Up @@ -66,6 +67,7 @@
from .services import async_setup_services

ISSUE_DEVICE_CONNECTION_FAILED = "device_connection_failed"
ISSUE_YAML_IMPORT_FAILED = "yaml_import_failed"
PLATFORMS = [
Platform.BINARY_SENSOR,
Platform.CLIMATE,
Expand Down Expand Up @@ -335,6 +337,42 @@ def delete_device_connection_issue(
)


def _yaml_import_issue_id(item_id: str) -> str:
return f"{ISSUE_YAML_IMPORT_FAILED}_{item_id}"


def create_yaml_import_issue(
hass: HomeAssistant,
item_id: str,
reason: str,
) -> None:
"""Create a YAML import issue."""
ir.async_create_issue(
hass,
DOMAIN,
_yaml_import_issue_id(item_id),
is_fixable=False,
severity=ir.IssueSeverity.ERROR,
translation_key=ISSUE_YAML_IMPORT_FAILED,
translation_placeholders={
"item": item_id,
"reason": reason,
},
)


def delete_yaml_import_issue(
hass: HomeAssistant,
item_id: str,
) -> None:
"""Delete a YAML import issue."""
ir.async_delete_issue(
hass,
DOMAIN,
_yaml_import_issue_id(item_id),
)


def cleanup_device_connection_issues(
hass: HomeAssistant,
config_entry_id: str,
Expand Down
Loading
Loading