Skip to content

Bump PySwitchbot to 2.0.0 #165995

Open
zerzhang wants to merge 3 commits intohome-assistant:devfrom
zerzhang:bump/pyswitchbot-2.0.0
Open

Bump PySwitchbot to 2.0.0 #165995
zerzhang wants to merge 3 commits intohome-assistant:devfrom
zerzhang:bump/pyswitchbot-2.0.0

Conversation

@zerzhang
Copy link
Contributor

@zerzhang zerzhang commented Mar 19, 2026

Breaking change

None for end users. Existing config entries using the old sensor type strings (air_purifier, air_purifier_table) are replaced by region-specific values; affected users will need to reconfigure.

Proposed change

  • Bump PySwitchbot dependency from 1.x to 2.0.0
  • Rename AIR_PURIFIER / AIR_PURIFIER_TABLE model variants to region-specific names introduced in 2.0.0:
    • AIR_PURIFIER → AIR_PURIFIER_JP + AIR_PURIFIER_US
    • AIR_PURIFIER_TABLE → AIR_PURIFIER_TABLE_JP + AIR_PURIFIER_TABLE_US
  • Update SwitchbotOperationError import path from internal submodule to top-level switchbot package (which 2.0.0exports directly)
  • changelog

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.

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 diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Copilot AI review requested due to automatic review settings March 19, 2026 09:54
Copy link

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

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

Hello @zerzhang,

When attempting to inspect the commits of your pull request for CLA signature status among all authors we encountered commit(s) which were not linked to a GitHub account, thus not allowing us to determine their status(es).

The commits that are missing a linked GitHub account are the following:

Unfortunately, we are unable to accept this pull request until this situation is corrected.

Here are your options:

  1. If you had an email address set for the commit that simply wasn't linked to your GitHub account you can link that email now and it will retroactively apply to your commits. The simplest way to do this is to click the link to one of the above commits and look for a blue question mark in a blue circle in the top left. Hovering over that bubble will show you what email address you used. Clicking on that button will take you to your email address settings on GitHub. Just add the email address on that page and you're all set. GitHub has more information about this option in their help center.

  2. If you didn't use an email address at all, it was an invalid email, or it's one you can't link to your GitHub, you will need to change the authorship information of the commit and your global Git settings so this doesn't happen again going forward. GitHub provides some great instructions on how to change your authorship information in their help center.

    • If you only made a single commit you should be able to run
      git commit --amend --author="Author Name <email@address.com>"
      
      (substituting "Author Name" and "email@address.com" for your actual information) to set the authorship information.
    • If you made more than one commit and the commit with the missing authorship information is not the most recent one you have two options:
      1. You can re-create all commits missing authorship information. This is going to be the easiest solution for developers that aren't extremely confident in their Git and command line skills.
      2. You can use this script that GitHub provides to rewrite history. Please note: this should be used only if you are very confident in your abilities and understand its impacts.
    • Whichever method you choose, I will come by to re-check the pull request once you push the fixes to this branch.

We apologize for this inconvenience, especially since it usually bites new contributors to Home Assistant. We hope you understand the need for us to protect ourselves and the great community we all have built legally. The best thing to come out of this is that you only need to fix this once and it benefits the entire Home Assistant and GitHub community.

Thanks, I look forward to checking this PR again soon! ❤️

@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
Copy link

Hey there @Danielhiversen, @RenierM26, @murtas, @Eloston, @dsypniewski, mind taking a look at this pull request as it has been labeled with an integration (switchbot) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of switchbot can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign switchbot Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) on the pull request.

Copy link
Contributor

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

Updates the Switchbot integration to use PySwitchbot 2.0.0, including adopting the new region-specific air purifier model identifiers and adjusting tests accordingly.

Changes:

  • Bump PySwitchbot dependency to 2.0.0 (manifest + generated requirements files).
  • Replace legacy air purifier model identifiers with region-specific variants (*_JP / *_US) in integration constants and platform/class mappings.
  • Update Switchbot fan tests to use the new model strings and import SwitchbotOperationError from the top-level switchbot package.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
homeassistant/components/switchbot/manifest.json Bumps integration requirement to PySwitchbot 2.0.0.
requirements_all.txt Updates pinned PySwitchbot version used by the project.
requirements_test_all.txt Updates pinned PySwitchbot version for test environment.
homeassistant/components/switchbot/const.py Renames supported air purifier models to new region-specific identifiers and updates model mappings.
homeassistant/components/switchbot/__init__.py Updates platform/class routing for the new air purifier model identifiers.
tests/components/switchbot/test_fan.py Updates tests to use new model strings and adjusts SwitchbotOperationError import.

You can also share your feedback on Copilot code review. Take the survey.

"loggers": ["switchbot"],
"quality_scale": "gold",
"requirements": ["PySwitchbot==1.1.0"]
"requirements": ["PySwitchbot==2.0.0"]
Comment on lines +50 to +53
AIR_PURIFIER_JP = "air_purifier_jp"
AIR_PURIFIER_US = "air_purifier_us"
AIR_PURIFIER_TABLE_JP = "air_purifier_table_jp"
AIR_PURIFIER_TABLE_US = "air_purifier_table_us"
@zerzhang zerzhang force-pushed the bump/pyswitchbot-2.0.0 branch from d5f3b4b to 2a976dc Compare March 19, 2026 09:59
Copy link

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

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

Hello @zerzhang,

When attempting to inspect the commits of your pull request for CLA signature status among all authors we encountered commit(s) which were not linked to a GitHub account, thus not allowing us to determine their status(es).

The commits that are missing a linked GitHub account are the following:

Unfortunately, we are unable to accept this pull request until this situation is corrected.

Here are your options:

  1. If you had an email address set for the commit that simply wasn't linked to your GitHub account you can link that email now and it will retroactively apply to your commits. The simplest way to do this is to click the link to one of the above commits and look for a blue question mark in a blue circle in the top left. Hovering over that bubble will show you what email address you used. Clicking on that button will take you to your email address settings on GitHub. Just add the email address on that page and you're all set. GitHub has more information about this option in their help center.

  2. If you didn't use an email address at all, it was an invalid email, or it's one you can't link to your GitHub, you will need to change the authorship information of the commit and your global Git settings so this doesn't happen again going forward. GitHub provides some great instructions on how to change your authorship information in their help center.

    • If you only made a single commit you should be able to run
      git commit --amend --author="Author Name <email@address.com>"
      
      (substituting "Author Name" and "email@address.com" for your actual information) to set the authorship information.
    • If you made more than one commit and the commit with the missing authorship information is not the most recent one you have two options:
      1. You can re-create all commits missing authorship information. This is going to be the easiest solution for developers that aren't extremely confident in their Git and command line skills.
      2. You can use this script that GitHub provides to rewrite history. Please note: this should be used only if you are very confident in your abilities and understand its impacts.
    • Whichever method you choose, I will come by to re-check the pull request once you push the fixes to this branch.

We apologize for this inconvenience, especially since it usually bites new contributors to Home Assistant. We hope you understand the need for us to protect ourselves and the great community we all have built legally. The best thing to come out of this is that you only need to fix this once and it benefits the entire Home Assistant and GitHub community.

Thanks, I look forward to checking this PR again soon! ❤️

Copilot AI review requested due to automatic review settings March 19, 2026 10:11
Copy link

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

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

Hello @zerzhang,

When attempting to inspect the commits of your pull request for CLA signature status among all authors we encountered commit(s) which were not linked to a GitHub account, thus not allowing us to determine their status(es).

The commits that are missing a linked GitHub account are the following:

Unfortunately, we are unable to accept this pull request until this situation is corrected.

Here are your options:

  1. If you had an email address set for the commit that simply wasn't linked to your GitHub account you can link that email now and it will retroactively apply to your commits. The simplest way to do this is to click the link to one of the above commits and look for a blue question mark in a blue circle in the top left. Hovering over that bubble will show you what email address you used. Clicking on that button will take you to your email address settings on GitHub. Just add the email address on that page and you're all set. GitHub has more information about this option in their help center.

  2. If you didn't use an email address at all, it was an invalid email, or it's one you can't link to your GitHub, you will need to change the authorship information of the commit and your global Git settings so this doesn't happen again going forward. GitHub provides some great instructions on how to change your authorship information in their help center.

    • If you only made a single commit you should be able to run
      git commit --amend --author="Author Name <email@address.com>"
      
      (substituting "Author Name" and "email@address.com" for your actual information) to set the authorship information.
    • If you made more than one commit and the commit with the missing authorship information is not the most recent one you have two options:
      1. You can re-create all commits missing authorship information. This is going to be the easiest solution for developers that aren't extremely confident in their Git and command line skills.
      2. You can use this script that GitHub provides to rewrite history. Please note: this should be used only if you are very confident in your abilities and understand its impacts.
    • Whichever method you choose, I will come by to re-check the pull request once you push the fixes to this branch.

We apologize for this inconvenience, especially since it usually bites new contributors to Home Assistant. We hope you understand the need for us to protect ourselves and the great community we all have built legally. The best thing to come out of this is that you only need to fix this once and it benefits the entire Home Assistant and GitHub community.

Thanks, I look forward to checking this PR again soon! ❤️

Copy link
Contributor

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

Updates the Home Assistant SwitchBot integration to use PySwitchbot 2.0.0, aligning model identifiers and error imports with the upstream library changes.

Changes:

  • Bump PySwitchbot from 1.1.0 to 2.0.0 across integration manifest and requirements files.
  • Replace legacy air purifier model identifiers with new region-specific variants (JP/US) throughout the integration and tests.
  • Update SwitchbotOperationError imports to use the top-level switchbot package export.

Reviewed changes

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

Show a summary per file
File Description
homeassistant/components/switchbot/init.py Update platform/class mappings for region-specific air purifier model strings
homeassistant/components/switchbot/const.py Replace air purifier model enums/mappings with JP/US variants
homeassistant/components/switchbot/entity.py Import SwitchbotOperationError from top-level switchbot
homeassistant/components/switchbot/select.py Import SwitchbotOperationError from top-level switchbot
homeassistant/components/switchbot/manifest.json Bump integration requirement to PySwitchbot 2.0.0
requirements_all.txt Bump PySwitchbot to 2.0.0
requirements_test_all.txt Bump PySwitchbot to 2.0.0
tests/components/switchbot/test_fan.py Update air purifier sensor_type strings to JP/US variants; update error import
tests/components/switchbot/test_cover.py Update SwitchbotOperationError import
tests/components/switchbot/test_humidifier.py Update SwitchbotOperationError import
tests/components/switchbot/test_light.py Update SwitchbotOperationError import
tests/components/switchbot/test_lock.py Update SwitchbotOperationError import
tests/components/switchbot/test_switch.py Update SwitchbotOperationError import

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +110 to +113
SupportedModels.AIR_PURIFIER_JP.value: [Platform.FAN, Platform.SENSOR],
SupportedModels.AIR_PURIFIER_US.value: [Platform.FAN, Platform.SENSOR],
SupportedModels.AIR_PURIFIER_TABLE_JP.value: [Platform.FAN, Platform.SENSOR],
SupportedModels.AIR_PURIFIER_TABLE_US.value: [Platform.FAN, Platform.SENSOR],
@zerzhang zerzhang marked this pull request as ready for review March 19, 2026 10:45
@home-assistant home-assistant bot dismissed stale reviews from themself March 19, 2026 10:45

Stale

Copy link

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

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

Hello @zerzhang,

When attempting to inspect the commits of your pull request for CLA signature status among all authors we encountered commit(s) which were not linked to a GitHub account, thus not allowing us to determine their status(es).

The commits that are missing a linked GitHub account are the following:

Unfortunately, we are unable to accept this pull request until this situation is corrected.

Here are your options:

  1. If you had an email address set for the commit that simply wasn't linked to your GitHub account you can link that email now and it will retroactively apply to your commits. The simplest way to do this is to click the link to one of the above commits and look for a blue question mark in a blue circle in the top left. Hovering over that bubble will show you what email address you used. Clicking on that button will take you to your email address settings on GitHub. Just add the email address on that page and you're all set. GitHub has more information about this option in their help center.

  2. If you didn't use an email address at all, it was an invalid email, or it's one you can't link to your GitHub, you will need to change the authorship information of the commit and your global Git settings so this doesn't happen again going forward. GitHub provides some great instructions on how to change your authorship information in their help center.

    • If you only made a single commit you should be able to run
      git commit --amend --author="Author Name <email@address.com>"
      
      (substituting "Author Name" and "email@address.com" for your actual information) to set the authorship information.
    • If you made more than one commit and the commit with the missing authorship information is not the most recent one you have two options:
      1. You can re-create all commits missing authorship information. This is going to be the easiest solution for developers that aren't extremely confident in their Git and command line skills.
      2. You can use this script that GitHub provides to rewrite history. Please note: this should be used only if you are very confident in your abilities and understand its impacts.
    • Whichever method you choose, I will come by to re-check the pull request once you push the fixes to this branch.

We apologize for this inconvenience, especially since it usually bites new contributors to Home Assistant. We hope you understand the need for us to protect ourselves and the great community we all have built legally. The best thing to come out of this is that you only need to fix this once and it benefits the entire Home Assistant and GitHub community.

Thanks, I look forward to checking this PR again soon! ❤️

@home-assistant home-assistant bot marked this pull request as draft March 19, 2026 21:30
@joostlek
Copy link
Member

None for end users. Existing config entries using the old sensor type strings (air_purifier, air_purifier_table) are replaced by region-specific values; affected users will need to reconfigure

How can we avoid this? Because we can't just break it for everyone with such device. Can we detect the mode of the device?

@zerzhang
Copy link
Contributor Author

None for end users. Existing config entries using the old sensor type strings (air_purifier, air_purifier_table) are replaced by region-specific values; affected users will need to reconfigure

How can we avoid this? Because we can't just break it for everyone with such device. Can we detect the mode of the device?

Due to changes in device naming conventions, all users are required to re-add their devices after upgrading their HA version. In response to user requests, future Pull Requests will introduce support for functions specific to various device types.

@zerzhang zerzhang marked this pull request as ready for review March 20, 2026 02:11
@zerzhang
Copy link
Contributor Author

This device comes in four variants; the original two types were insufficient in scope and presented functional conflicts.

@joostlek
Copy link
Member

Right, but how do we know what type the user has? We know via the Bluetooth service info right? Can't we migrate this then

@zerzhang
Copy link
Contributor Author

Right, but how do we know what type the user has? We know via the Bluetooth service info right? Can't we migrate this then

Yes, device types are indeed determined based on service data. Previously, I had merged the US and JP types into a single category; however, there are actually slight differences between the two. This update further distinguishes between them to facilitate the integration of future features.

@joostlek
Copy link
Member

So what stops us from redefining the model users have?

@zerzhang
Copy link
Contributor Author

So what stops us from redefining the model users have?

Originally, US and JP were treated as a single type, and TABLE_US and TABLE_JP were treated as a single type.
If we continue to use the previous type, it will be difficult to distinguish between functions later on.

    SupportedModels.AIR_PURIFIER_JP.value: [Platform.FAN, Platform.SENSOR],
    SupportedModels.AIR_PURIFIER_US.value: [Platform.FAN, Platform.SENSOR],
    SupportedModels.AIR_PURIFIER_TABLE_JP.value: [Platform.FAN, Platform.SENSOR],
    SupportedModels.AIR_PURIFIER_TABLE_US.value: [Platform.FAN, Platform.SENSOR],

@joostlek
Copy link
Member

That's not what I mean.

When we set up the device, we can recognize the type of the device the user is using. We don't need to have the user fill this in.

Are we able to have logic that during setup checks if it's a deprecated type, and if it is, check again what type of device it is, and update it directly? This way the user doesn't know anything and we can have this logic before connecting

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.

4 participants