Skip to content

Clean up stream resources in Teslemetry config entry unloading#970

Closed
Bre77 wants to merge 1 commit intodevfrom
claude/teslemetry-quality-check-XVT6D
Closed

Clean up stream resources in Teslemetry config entry unloading#970
Bre77 wants to merge 1 commit intodevfrom
claude/teslemetry-quality-check-XVT6D

Conversation

@Bre77
Copy link
Copy Markdown
Owner

@Bre77 Bre77 commented Jan 30, 2026

Proposed change

This PR addresses the config-entry-unloading quality scale item for the Teslemetry integration.

The async_unload_entry function now properly cleans up resources when the config entry is unloaded:

  • Calls remove_listener() for each vehicle to unsubscribe from TeslemetryStream events
  • Closes the TeslemetryStream WebSocket connection via stream.close()

Previously, the function only unloaded platforms without cleaning up the stream connection and listeners, which could lead to resource leaks.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

To help with the load of incoming pull requests:

@Bre77 Bre77 closed this Jan 31, 2026
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