$ show mmakaay/esphome-xiaomi_bslamp2
This repository provides ESPHome components for integrating the Xiaomi Mijia Bedside Lamp 2 with Home Assistant. It enables full control of the lamp's RGBWW LEDs, front panel touch interface (buttons and slider), and illumination through custom ESPHome components. The firmware replaces the original Xiaomi firmware to eliminate cloud dependencies and enable local-only control. The architecture follows ESPHome's component model with hardware abstraction layers (HAL) for light control and front panel I2C communication. Key features include individually controllable front panel LEDs, light presets with group support, disco mode for immediate updates, night light calibration, and smooth color transitions with hardware-aware handling of low-brightness limitations. The design emphasizes separation of concerns, with distinct modules for color handling, state management, and event processing. Notable technical implementations include a Chain of Responsibility pattern for handling different light modes (off, night, RGB, white), a flexible preset system with group-based activation, and specialized transition handling that avoids attempting smooth color changes at very low brightness levels where the hardware cannot perform them reliably. The firmware maintains compatibility with modern ESPHome versions through active maintenance and timely adaptation to API changes.
The LLM identified 1 files worth highlighting for reuse:
Implements a flexible preset system for controlling light states with support for grouped presets and activation via next/previous or specific group/preset selection. Demonstrates the preset/configuration pattern where named configurations encapsulate device state. The system is reusable due to its clear separation between preset definition and activation logic, minimal dependencies (primarily on a controllable light interface), and well-encapsulated design that could be adapted to control any device with configurable states.