Add support for Candle Warmer Lamp#454
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds a new SwitchBot device model (“Candle Warmer Lamp”) to the library, including BLE advertisement parsing and a dedicated device class so it can be discovered and controlled consistently with other lighting devices.
Changes:
- Add
SwitchbotModel.CANDLE_WARMER_LAMPand new advertisement parser routing for its model identifiers. - Introduce
SwitchbotCandleWarmerLampdevice class with brightness-only color mode. - Extend test fixtures and adv-parser test vectors to cover the new device.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
switchbot/devices/light_strip.py |
Adds SwitchbotCandleWarmerLamp device implementation. |
switchbot/adv_parsers/light_strip.py |
Adds process_candle_warmer_lamp advertisement data parser. |
switchbot/adv_parser.py |
Wires the new model IDs to the new parser. |
switchbot/const/__init__.py |
Adds SwitchbotModel.CANDLE_WARMER_LAMP. |
switchbot/const/light.py |
Adds ColorMode.BRIGHTNESS. |
switchbot/__init__.py |
Exposes SwitchbotCandleWarmerLamp in the package exports. |
tests/__init__.py |
Adds CANDLE_WARMER_LAMP_INFO adv test fixture data. |
tests/test_adv_parser.py |
Adds active/passive/manufacturer-data test cases for the new model. |
tests/test_strip_light.py |
Adds candle warmer lamp initialization test and includes it in shared parametrized tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| class SwitchbotCandleWarmerLamp(SwitchbotEncryptedDevice, SwitchbotLightStrip): | ||
| """Support for Switchbot Candle Warmer Lamp.""" | ||
|
|
||
| _effect_dict = {} | ||
|
|
||
| def __init__( | ||
| self, | ||
| device: BLEDevice, | ||
| key_id: str, | ||
| encryption_key: str, | ||
| interface: int = 0, | ||
| model: SwitchbotModel = SwitchbotModel.CANDLE_WARMER_LAMP, | ||
| **kwargs: Any, | ||
| ) -> None: | ||
| super().__init__(device, key_id, encryption_key, model, interface, **kwargs) |
| _version_info, _data = res | ||
| return { | ||
| "isOn": bool(_data[1] & 0b10000000), | ||
| "brightness": _data[2] & 0b01111111, |
| ColorMode.BRIGHTNESS, | ||
| } | ||
| assert device.brightness == adv_info.data["brightness"] | ||
| # Check that effect list contains expected lowercase effect names |
| COLOR_TEMP = 1 | ||
| RGB = 2 | ||
| EFFECT = 3 | ||
| BRIGHTNESS = 11 |
There was a problem hiding this comment.
I observed other enumeration definitions in the same file, which appear to be related. To avoid potential issues, I assigned a non-existent value to them.
1. Candle Warmer Lamp