Skip to content

vNext: Find the config entry of a device with config_entry_id - #577

Merged
RobHofmann merged 1 commit into
5.0-devfrom
fix/device-config-entry-id
Nov 14, 2026
Merged

RobHofmann merged 1 commit into
5.0-devfrom
fix/device-config-entry-id

Conversation

@RobHofmann

Copy link
Copy Markdown
Owner

Fixes a deprecation that @p-monteiro found on the Home Assistant dev branch:

Detected that custom integration 'gree_custom' accesses DeviceEntry.config_entries, which is deprecated because a device belongs to a single config entry; use DeviceEntry.config_entry_id instead at custom_components/gree_custom/services.py, line 80

It stops working in Home Assistant 2027.10.

Change

  • async_get_device_from_service_call() in services.py reads the one entry from DeviceEntry.config_entry_id instead of looping over config_entries. The errors stay the same: config_entry_not_found when the entry is missing or belongs to another domain, and entry_not_loaded when it is not loaded.
  • config_entry_id exists in Home Assistant 2026.10 and 2026.11 (checked in homeassistant/helpers/device_registry.py of both tags), so the minimum version of 2026.11 is fine.
  • New tests/config_flow/test_services.py: both services on a loaded entry (and no config_entries warning in the log), a device of an unloaded entry, and an unknown device ID. There were no service tests before.

The other deprecation from the same run, UNDEFINED and UndefinedType, is not touched: its replacement does not exist in 2026.11 yet. That is tracked in #575.

Testing

  • Real unit on Home Assistant 2026.11.1 (my test unit): gree_custom.get_prop_values with Pow, Mod and SetTem returns the values, with zero tracebacks. 2026.11.1 does not log this warning, so the real unit only proves that the service still works.
  • pytest: 390 passed, the 3 new tests included. ruff: check and format pass.

DeviceEntry.config_entries is deprecated, because a device belongs to one
config entry, and it stops working in Home Assistant 2027.10. The services
now read DeviceEntry.config_entry_id, which exists in 2026.10 and later.

New tests call both services on a loaded entry, on an unloaded entry and
with an unknown device.

@p-monteiro p-monteiro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good.

@RobHofmann
RobHofmann merged commit 6bbfd36 into 5.0-dev Nov 14, 2026
4 checks passed
@RobHofmann
RobHofmann deleted the fix/device-config-entry-id branch November 14, 2026 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants