8000 Add SFTP Client by cyr-ius · Pull Request #147300 · home-assistant/core · GitHub
[go: up one dir, main page]

Skip to content

Add SFTP Client #147300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: dev
Choose a base branch
from
Open

Add SFTP Client #147300

wants to merge 21 commits into from

Conversation

cyr-ius
Copy link
Contributor
@cyr-ius cyr-ius commented Jun 22, 2025

Proposed change

SFTP Client allows you to specify an SFTP source to perform Home Assistant backups

Brand for new integration : home-assistant/brands#7312
Documentation: home-assistant/home-assistant.io#39676

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: Welcome SFTP Client home-assistant.io#39676
  • Link to developer documentation pull request:
  • Link to frontend pull request:

Checklist

  • 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.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

@cyr-ius cyr-ius changed the title Sftp client New integration SFTP Client Jun 22, 2025
@cyr-ius cyr-ius changed the title New integration SFTP Client Add SFTP Client Jun 22, 2025
@zweckj
Copy link
Member
zweckj commented Jun 22, 2025

There's already an open PR for SFTP support for backups #135844

@zweckj zweckj marked this pull request as draft June 22, 2025 17:04
@cyr-ius cyr-ius marked this pull request as ready for review June 22, 2025 17:30
@cyr-ius
Copy link
Contributor Author
cyr-ius commented Jun 22, 2025

The CI / Run tests Python 3.13 (9) error test (pull_request) is not related to my code

Copy link
Member
@zweckj zweckj left a comment

Choose a reason for hiding this comment

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

There's already another PR that’s further in the review process, please rather check if it makes sense to join forces

@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant home-assistant bot marked this pull request as draft June 22, 2025 17:38
@cyr-ius cyr-ius marked this pull request as ready for review June 22, 2025 17:46
@home-assistant home-assistant bot requested a review from zweckj June 22, 2025 17:47
@cyr-ius
Copy link
Contributor Author
cyr-ius commented Jun 22, 2025

There's already another PR that’s further in the review process, please rather check if it makes sense to join forces

Damn, I just saw it now.

@frenck frenck requested a review from Copilot July 5, 2025 07:33
Copy link
Contributor
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds a new SFTPClient integration to perform Home Assistant backups over SFTP.

  • Introduces SSH and SFTP connection helpers with error handling and streaming utilities
  • Implements a user-driven config flow and translation strings for configuration and setup errors
  • Provides a BackupAgent implementation for listing, uploading, downloading, and deleting backups, along with comprehensive tests and type checking

Reviewed Changes

Copilot reviewed 20 out of 22 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
homeassistant/components/sftp_client/helpers.py SSH and SFTP connection helpers, path operations, JSON streaming, and error classes
homeassistant/components/sftp_client/config_flow.py Config flow schema, validation (InvalidAuth, CannotConnect), and entry creation
homeassistant/components/sftp_client/backup.py BackupAgent implementation for managing backups over SFTP
homeassistant/components/sftp_client/strings.json Localization strings for UI steps and exception messages
homeassistant/components/sftp_client/manifest.json Integration metadata, dependencies, and quality scale setting
homeassistant/components/sftp_client/quality_scale.yaml Quality scale compliance for Bronze through Platinum levels
tests/components/sftp_client/conftest.py Common fixtures mocking SFTP connections and file streams
tests/components/sftp_client/test_init.py Tests for setup and teardown behavior of the integration
tests/components/sftp_client/test_helpers.py Tests for helper error handling (permission denied path)
tests/components/sftp_client/test_config_flow.py Config flow tests covering success, auth errors, connection errors, and duplicates
tests/components/sftp_client/test_backup.py Tests for backup agent API: list, details, upload, download, delete, and error cases
requirements_all.txt & requirements_test_all.txt Added asyncssh==2.21.0 dependency
mypy.ini Strict typing rules enabled for the new integration
CODEOWNERS & .strict-typing Ownership assignment and strict typing registration for SFTP client
Comments suppressed due to low confidence (1)

tests/components/sftp_client/test_helpers.py:14

  • [nitpick] This test name duplicates test_load_config_entry in test_init.py but tests a permission-denied scenario. Rename it to something like test_permission_denied_on_connect to reflect its purpose.
async def test_load_config_entry(

"""Open SFTP Connection."""
await self.async_ssh_connect()
if self._conn is None:
raise RuntimeError("SHH Connection is failed")
Copy link
Preview
Copilot AI Jul 5, 2025

Choose a reason for hiding this comment

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

The error message has a typo (“SHH”) and awkward phrasing. Consider using something like RuntimeError("SSH connection failed") for clarity.

Suggested change
raise RuntimeError("SHH Connection is failed")
raise RuntimeError("SSH connection failed")

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0