This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
EspHoMaTriXv2 is an ESPHome custom component for an 8×32 RGB LED matrix display (e.g., Ulanzi TC001 pixel clock). It integrates with Home Assistant via service calls and supports 27+ display modes (clock, date, icons, animations, progress bars, graphs, fire effects, etc.).
No unit tests exist. Validation is done by building ESPHome firmware from the test configurations in tests/.
# Build a specific test configuration
esphome build tests/esp32-idf.yaml
# Build and flash to device
esphome run tests/esp32-idf.yaml
# Build all test configs (mirrors CI)
for f in tests/*.yaml; do
[[ "$f" == *"secrets"* ]] && continue
esphome build "$f" || exit 1
doneTest YAML files: esp32-arduino.yaml, esp32-idf.yaml, esp32-idf-features.yaml, esp32-idf-noapi.yaml, esp8266-arduino.yaml.
All component code lives in components/ehmtxv2/:
__init__.py— ESPHome Python config module: schema validation, code generation, icon downloading/processing at compile time. Defines allCONF_*constants and registers automation triggers.EHMTX.h— Main class header. Defines theshow_modeenum (27 modes), constants (MAXQUEUE=24,POLLINGINTERVAL=250ms), all trigger classes, and theEHMTXclass (extendsPollingComponent, optionallyCustomAPIDevicewhenUSE_APIis defined).EHMTX.cpp— Core implementation: display rendering, color effects, brightness, night mode, icon/text drawing, all public service methods.EHMTX_queue.cpp— Queue management: screen lifecycle, fire animation plugin (black body radiation spectrum), screen transitions, blend effects.EHMTX_icons.cpp—EHMTX_Iconclass extendingesphome::Animation; handles pingpong frame direction.
EHMTXis aPollingComponent;update()fires every 250ms and drives the display tick.- Screen queue holds up to 24
EHMTX_queueentries, each with a mode, icon, text, lifetime, and screen_time. - Compile-time icon processing:
__init__.pydownloads URLs, resizes images to 8×8 or 8×32, and encodes them as RGB565 arrays baked into firmware. - API availability is conditional:
#ifdef USE_APIwraps all Home Assistant service registrations.
- Add
CONF_*constant and schema entry in__init__.py(cv.Optionalwith default). - Add member variable to
EHMTXclass inEHMTX.h, initialize in constructor. - Implement logic in the appropriate
.cppfile. - Add public service method if Home Assistant-callable.
- Update
README.mdfor any user-facing changes.
CalVer format: YYYY.MM.D (e.g., 2026.4.1). Version string is defined in EHMTX.h:
static const char *const EHMTX_VERSION = "2026.4.1";Update this when making breaking changes or significant new features.
C++ (2-space indent, 120-char line limit):
- Classes:
PascalCase— Methods/variables:snake_case— Member variables: trailing underscore (brightness_) — Constants/enums:UPPER_SNAKE_CASE - ESPHome types:
uint8_t/uint16_t,Color,esphome::display::BaseFont* - Logging:
ESP_LOGD/I/W/E(TAG, ...)withstatic const char *const TAG = "EHMTXv2";
Python (__init__.py, 4-space indent, 88-char line limit):
cv.for config validation,cg.for code generation- Config values via
config[CONF_KEY] - Register triggers with
automation.build_automation()