Skip to content

fix(websocket): look up the removed device by config entry - #437

Open
enoch85 wants to merge 1 commit into
zachowj:mainfrom
enoch85:fix/device-remove-config-entry-lookup
Open

enoch85 wants to merge 1 commit into
zachowj:mainfrom
enoch85:fix/device-remove-config-entry-lookup

Conversation

@enoch85

@enoch85 enoch85 commented Nov 11, 2026

Copy link
Copy Markdown

Fixes #436.

Summary

nodered/device/remove looked the device up with DeviceRegistry.async_get_device, which Home Assistant deprecated in 2026.9 (home-assistant/core#178465). The existing remove test logs it on Home Assistant 2026.10.4:

Detected that custom integration 'nodered' calls device_registry.async_get_device, which is deprecated because device identifiers and connections are no longer unique across config entries; use async_get_device_by_identifier, async_get_device_by_connection or async_get_devices instead at custom_components/nodered/websocket.py, line 172: [...] This will stop working in Home Assistant 2027.8.0

The handler now calls async_get_device_by_identifier((DOMAIN, node_id), entry.entry_id) for the Node-RED config entry. The integration allows only one entry, and its devices are created for that entry. If no entry exists, nothing is removed and the command still succeeds.

hacs.json still allows Home Assistant 2024.5, and async_get_device_by_identifier was only added in 2026.8 (home-assistant/core#176879). On older versions the handler keeps calling async_get_device.

Testing

  • pytest with the CI flags: 198 passed on Home Assistant 2026.10.4, which is what the ha-latest job installs (pytest-homeassistant-custom-component 0.13.375 pins it). Also 198 passed on 2026.7.4 (pytest-homeassistant-custom-component 0.13.348), which runs the async_get_device fallback.
  • The new test test_websocket_device_remove_does_not_use_deprecated_lookup fails on main because the warning above is logged, and passes with this change.
  • pre-commit run --all-files (ruff check, ruff format, check-json) passed.
  • Not run on 2026.11: pytest-homeassistant-custom-component 0.13.375 does not import with Home Assistant 2026.11.1. The async_get_device_by_identifier signature there is the same as in 2026.8 to 2026.10.

🤖 Generated with Claude Code

nodered/device/remove looked the device up with
DeviceRegistry.async_get_device, which Home Assistant deprecated in
2026.9 and which stops working in 2027.8. Use
async_get_device_by_identifier with the Node-RED config entry instead,
and keep async_get_device on Home Assistant before 2026.8, which does
not have it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

nodered/device/remove uses device_registry.async_get_device, deprecated in HA 2026.9

1 participant