$ show Blackymas/NSPanel_HA_Blueprint
This repository provides a complete custom firmware solution for the Sonoff NSPanel smart home touch panel, tightly integrated with Home Assistant via ESPHome and a Home Assistant Blueprint. The firmware is built on ESPHome, a platform for ESP32-based devices, and uses a Nextion display for the user interface. The architecture is modular: a core set of YAML configuration files defines hardware drivers (Wi-Fi, display, relays, buttons, temperature sensor) and page definitions (home, weather, climate, light, cover, alarm, media player, utilities, etc.). Optional add-on YAML packages extend functionality for cover control, climate thermostat, TFT upload, and Bluetooth proxy. The companion C++ component library (in `components/nspanel_ha_blueprint/`) implements the communication protocol between the ESP32 and the Nextion display, handles page logic, and fires Home Assistant events via the ESPHome API. The Blueprint (`nspanel_blueprint.yaml`) allows users to configure all entities and customizations without writing code. Prebuilt firmware binaries are provided for quick flashing. The project is actively maintained, with a large community and frequent releases, though it has significant duplication across HMI variants and some deprecated add-ons.
The LLM identified 4 files worth highlighting for reuse:
Core header defining the `SystemFlags` and `BlueprintStatusFlags` bitfield structs, the `HardwareSettings` packed bitfield, and the `fire_ha_event()` function. This component demonstrates a clean, compile-time efficient state management pattern for embedded systems. The bitfield approach reduces RAM usage, and the event emitter abstraction decouples touch interactions from the Home Assistant event bus. The file also includes utility macros for conditional logging and version checking. It is self-contained and could be extracted into any ESPHome component needing similar event-driven state tracking.
Implements the main `NSPanel` class which manages the entire lifecycle: boot sequence, page transitions, touch event parsing, and Home Assistant communication. The class uses a clear state machine (boot phases, page IDs) and a robust event loop that processes serial commands from the Nextion display. The `wrapText()` utility (for text fitting on small screens) is a reusable algorithm. The separation of concerns between page handling, hardware abstraction, and event dispatch makes this a strong example of embedded firmware architecture.
Provides text wrapping (`wrapText`) and decimal separator adjustment functions. The wrapping algorithm is optimized for small displays with a fixed width, breaking lines at word boundaries and handling CJK characters. This is a self-contained, portable utility that could be reused in any project requiring text fitting on constrained displays, not tied to the NSPanel hardware.
The core YAML package that includes all base hardware and page definitions. It demonstrates a clean modular include pattern: each component (display, Wi-Fi, buttons, etc.) is a separate YAML file included via `packages`. The `!extend` and `!remove` mechanisms allow add-ons to override specific parts without modifying the core. This pattern is reusable for any ESPHome project that needs to manage configuration complexity across multiple hardware variants.