Skip to content

Add Permanent Outdoor Light support#464

Merged
bdraco merged 10 commits intosblibs:masterfrom
fankai777:feat/POL
Apr 23, 2026
Merged

Add Permanent Outdoor Light support#464
bdraco merged 10 commits intosblibs:masterfrom
fankai777:feat/POL

Conversation

@fankai777
Copy link
Copy Markdown
Contributor

Summary

Add support for the SwitchBot Permanent Outdoor Light (POL) device — an encrypted RGBIC-based outdoor light strip.

Changes

Features

  • Add SwitchbotPermanentOutdoorLight device class with RGBIC effects and RGBICStripLightColorMode-based color_mode property
  • Register PERMANENT_OUTDOOR_LIGHT model enum in SwitchbotModel
  • Add BLE advertisement parser entries for service data 0xd0b7 (both 0x00 and 0x01 prefixes)
  • Export SwitchbotPermanentOutdoorLight in public API

Bug Fixes

  • Add missing RGBICStripLightColorMode.EFFECT (value 7) mapping in _RGBICWW_STRIP_LIGHT_COLOR_MODE_MAP — this also fixes a potential ValueError for existing RGBIC strip lights
  • Add defensive bounds check in process_light for short manufacturer data to avoid IndexError

Tests

  • Add POL to parametrized device_case fixture (covers all existing strip light tests)
  • Add dedicated test_permanent_outdoor_light_color_mode test covering all RGBICStripLightColorMode values
  • 100% code coverage on light_strip.py

fankai777 and others added 2 commits March 16, 2026 15:20
- Add SwitchbotPermanentOutdoorLight device class with RGBIC effects and
  RGBICStripLightColorMode-based color_mode property
- Register POL model enum, adv_parser entries (service data 0xd0b7),
  and public API export
- Fix missing RGBICStripLightColorMode.EFFECT mapping in color mode map
- Add defensive bounds check in process_light for short manufacturer data
- Add unit tests: POL in parametrized device_case fixture and dedicated
  color_mode test covering all RGBICStripLightColorMode values (100% coverage)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
switchbot/__init__.py 100.00% <ø> (ø)
switchbot/adv_parser.py 97.82% <ø> (ø)
switchbot/const/__init__.py 100.00% <100.00%> (ø)
switchbot/devices/light_strip.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

fankai777 and others added 2 commits March 16, 2026 15:31
- Add POL active, passive, and minimum_info adv parser test cases
- Add passive test with short manufacturer data (13 bytes) to cover
  the cw=0 fallback branch in process_light
- 100% coverage on adv_parsers/light_strip.py

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown
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

Adds first-class support for the SwitchBot Permanent Outdoor Light (POL) across the library’s BLE advertisement parsing, device model enum, device implementation, and public exports, with accompanying test coverage and small robustness fixes.

Changes:

  • Introduce SwitchbotPermanentOutdoorLight device class and export it in the public API.
  • Register SwitchbotModel.PERMANENT_OUTDOOR_LIGHT and add BLE adv parser mappings for service data 0xd0b7 (0x00/0x01 prefixes).
  • Fix RGBIC color mode mapping (adds RGBICStripLightColorMode.EFFECT) and harden CW parsing against short manufacturer data; extend/augment tests accordingly.

Reviewed changes

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

Show a summary per file
File Description
switchbot/devices/light_strip.py Adds POL device class; extends RGBIC color-mode mapping to include EFFECT.
switchbot/const/__init__.py Adds PERMANENT_OUTDOOR_LIGHT to SwitchbotModel.
switchbot/adv_parser.py Registers POL service-data signatures (d0b7) and routes parsing via process_light.
switchbot/adv_parsers/light_strip.py Adds bounds check for CW extraction to avoid IndexError on shorter mfr payloads.
switchbot/__init__.py Exports SwitchbotPermanentOutdoorLight in the top-level public API.
tests/__init__.py Adds PERMANENT_OUTDOOR_LIGHT_INFO test fixture data.
tests/test_adv_parser.py Adds POL advertisement parsing test cases (active/passive).
tests/test_strip_light.py Adds POL to strip-light parametrized tests and adds a dedicated color-mode mapping test.
Comments suppressed due to low confidence (1)

switchbot/init.py:123

  • __all__ contains multiple duplicated exports (e.g., "Switchbot", "SwitchbotModel", "SwitchbotPlugMini", "SwitchbotSupportedType"). This is harmless at runtime but makes the public API surface harder to audit and can confuse consumers/tools that inspect __all__. Please deduplicate the list so each symbol appears once.
__all__ = [
    "AirPurifierMode",
    "AirQualityLevel",
    "BulbColorMode",
    "CeilingLightColorMode",
    "ClimateAction",
    "ClimateMode",
    "ColorMode",
    "FanMode",
    "GetSwitchbotDevices",
    "HumidifierAction",
    "HumidifierMode",
    "HumidifierWaterLevel",
    "LockStatus",
    "SmartThermostatRadiatorMode",
    "StripLightColorMode",
    "SwitchBotAdvertisement",
    "Switchbot",
    "Switchbot",
    "SwitchbotAccountConnectionError",
    "SwitchbotAirPurifier",
    "SwitchbotApiError",
    "SwitchbotArtFrame",
    "SwitchbotAuthenticationError",
    "SwitchbotBaseLight",
    "SwitchbotBlindTilt",
    "SwitchbotBulb",
    "SwitchbotCeilingLight",
    "SwitchbotCurtain",
    "SwitchbotDevice",
    "SwitchbotEncryptedDevice",
    "SwitchbotEvaporativeHumidifier",
    "SwitchbotFan",
    "SwitchbotGarageDoorOpener",
    "SwitchbotHumidifier",
    "SwitchbotKeypadVision",
    "SwitchbotLightStrip",
    "SwitchbotLock",
    "SwitchbotMeterProCO2",
    "SwitchbotModel",
    "SwitchbotModel",
    "SwitchbotOperationError",
    "SwitchbotPermanentOutdoorLight",
    "SwitchbotPlugMini",
    "SwitchbotPlugMini",
    "SwitchbotRelaySwitch",
    "SwitchbotRelaySwitch2PM",
    "SwitchbotRgbicLight",
    "SwitchbotRollerShade",
    "SwitchbotSmartThermostatRadiator",
    "SwitchbotStripLight3",
    "SwitchbotSupportedType",
    "SwitchbotSupportedType",
    "SwitchbotVacuum",

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

Comment thread switchbot/devices/light_strip.py
Comment thread switchbot/adv_parser.py Outdated
bdraco and others added 5 commits April 22, 2026 12:46
# Conflicts:
#	tests/test_strip_light.py
# Conflicts:
#	switchbot/adv_parser.py
#	switchbot/const/__init__.py
#	switchbot/devices/light_strip.py
#	tests/test_adv_parser.py
#	tests/test_strip_light.py
POL shares its BLE advertisement layout with the RGBIC family
(color temperature at mfr_data offset 10), matching its
SwitchbotRgbicLight class inheritance. Also revert the defensive
bounds check in process_light since the short-mfr_data case it
protected against is no longer reachable via POL.
@bdraco bdraco merged commit b29eaba into sblibs:master Apr 23, 2026
6 checks passed
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.

5 participants