Skip to content

Fix YAML import and handle optional configuration values - #461

Merged
RobHofmann merged 1 commit into
RobHofmann:masterfrom
r0nmlt:fix-yaml-import
Sep 16, 2026
Merged

RobHofmann merged 1 commit into
RobHofmann:masterfrom
r0nmlt:fix-yaml-import

Conversation

@r0nmlt

@r0nmlt r0nmlt commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes YAML-based configuration imports.

The integration currently declares a YAML configuration schema and documents YAML configuration in the README, however async_step_import() forwards directly to async_step_user(), causing imported entries to stop at the manual configuration step instead of creating config entries automatically.

Additionally, test_connection() expects optional fields such as encryption_key and uid to be present, resulting in:

KeyError: 'encryption_key'

when using the documented YAML configuration examples.

Changes

  • Process YAML imports directly in async_step_import()
  • Populate defaults for optional configuration values before connection testing
  • Validate connectivity before creating entries
  • Preserve unique ID handling to prevent duplicate entries
  • Create config entries automatically from YAML definitions

Tested

Tested successfully on Home Assistant 2026.6.1 with multiple Gree units defined through YAML configuration.

The following configuration imports correctly and creates config entries automatically:

gree:
  - name: "Living Room"
    host: "192.168.1.101"
    mac: "20-FA-BB-12-34-56"
    encryption_version: 1

@RobHofmann RobHofmann added the to test This issue needs testing label Sep 16, 2026

@RobHofmann RobHofmann left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested against a real device on a dev instance: the YAML import creates the config entry automatically, test_connection runs first and succeeds, and the YAML mode lists carry through into the entry data. On a second restart the flow aborts on the already-configured unique ID without a further connection attempt, so no duplicate entry and no wasted network round trip per device.

Merging. Two small follow-ups, neither blocking: cannot_connect has no string under config.abort (only under config.error), and the setdefault calls for port and encryption_version are redundant since the YAML schema already defaults both.

@RobHofmann
RobHofmann merged commit 90cc50d into RobHofmann:master Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

to test This issue needs testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants