Skip to content

Add new features to air purifiers#451

Open
zerzhang wants to merge 18 commits intosblibs:masterfrom
zerzhang:feature/air_purifier_new
Open

Add new features to air purifiers#451
zerzhang wants to merge 18 commits intosblibs:masterfrom
zerzhang:feature/air_purifier_new

Conversation

@zerzhang
Copy link
Collaborator

@zerzhang zerzhang commented Feb 28, 2026

Breaking changes

remove the models

    AIR_PURIFIER = "Air Purifier"
    AIR_PURIFIER_TABLE = "Air Purifier Table"

add models

    AIR_PURIFIER_US = "Air Purifier US"
    AIR_PURIFIER_JP = "Air Purifier JP"
    AIR_PURIFIER_TABLE_US = "Air Purifier Table US"
    AIR_PURIFIER_TABLE_JP = "Air Purifier Table JP"

Support new features

  • set fan speed
  • open/close child lock
  • open light sensitive
  • turn on/off led
  • set led rgb
  • set led brightness
  • get pm25 value for us model
  • open/close wireless charging for air purifier table

@zerzhang zerzhang force-pushed the feature/air_purifier_new branch from 838716c to 1be66e8 Compare February 28, 2026 09:44
@codecov
Copy link

codecov bot commented Feb 28, 2026

Codecov Report

❌ Patch coverage is 97.84173% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
switchbot/devices/base_light.py 85.00% 3 Missing ⚠️
Files with missing lines Coverage Δ
switchbot/__init__.py 100.00% <ø> (ø)
switchbot/adv_parser.py 97.81% <ø> (ø)
switchbot/const/__init__.py 100.00% <100.00%> (ø)
switchbot/devices/air_purifier.py 100.00% <100.00%> (ø)
switchbot/devices/device.py 67.95% <100.00%> (+0.60%) ⬆️
switchbot/devices/base_light.py 97.32% <85.00%> (-2.68%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

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

This PR adds new features to SwitchBot air purifiers: fan speed control (set percentage), child lock open/close, light-sensitive mode, LED on/off, LED RGB and brightness control, PM2.5 value (US models only), and wireless charging toggle (table models). It also renames the air purifier models to region-specific variants (AIR_PURIFIER_US, AIR_PURIFIER_JP, AIR_PURIFIER_TABLE_US, AIR_PURIFIER_TABLE_JP) for clarity.

Changes:

  • SwitchbotAirPurifier now extends SwitchbotSequenceBaseLight instead of SwitchbotSequenceDevice, enabling LED control features
  • Air purifier enum models renamed from AIR_PURIFIER/AIR_PURIFIER_TABLE to region-specific variants (*_US, *_JP)
  • New commands added: set percentage, child lock, wireless charging, LED on/off, LED RGB/brightness, light-sensitive mode

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
switchbot/devices/air_purifier.py Core feature additions: new LED commands, percentage, wireless charging, child lock, and updated get_basic_info using 3 commands
switchbot/const/__init__.py Renames air purifier models to region-specific variants; exports AirQualityLevel
switchbot/devices/device.py Adds open/close_child_lock and open/close_wireless_charging base methods; updates API model map
switchbot/devices/base_light.py Refactors _get_basic_info_by_multi_commands to call _send_command directly instead of _get_basic_info
switchbot/adv_parser.py Updates model mappings to region-specific variants
switchbot/__init__.py Exports AirQualityLevel
tests/test_air_purifier.py Updates existing tests and adds new tests for added features
tests/test_lock.py Updates invalid model test to use AIR_PURIFIER_JP
tests/test_adv_parser.py Updates expected model names and enum values
tests/test_bulb.py Updates get_basic_info mock to use _send_command/_check_command_result
tests/test_ceiling_light.py Same mock update as test_bulb.py
tests/test_strip_light.py Same mock update as test_bulb.py

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zerzhang zerzhang force-pushed the feature/air_purifier_new branch from 159f12d to 2f38e30 Compare March 2, 2026 04:15
@zerzhang zerzhang closed this Mar 2, 2026
@zerzhang zerzhang reopened this Mar 2, 2026
@zerzhang
Copy link
Collaborator Author

zerzhang commented Mar 2, 2026

LED on/off status detection has been removed; the current communication protocol does not support it.
HA determines the LED status by whether the command was successfully sent.

@zerzhang zerzhang closed this Mar 5, 2026
@zerzhang zerzhang reopened this Mar 6, 2026
@bdraco
Copy link
Member

bdraco commented Mar 6, 2026

I still have these on my list to followup. I just haven't had any free cycles

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.

3 participants