This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Cross-agent instructions (including the rule for diagnosing
yarn testfailures) live in AGENTS.md. Read that first.
This is a Yarn project. Use yarn commands instead of npm for consistency.
yarn lint/yarn lint:fix— ESLint flat config (eslint.config.mjs); Lit + WC rules on card/html files;e2e/**is ignored.yarn typecheck— productiontsconfig.json(include:src/**/*.tsonly) plus testtsconfig.test.json.yarn pass— format, typecheck, lint, and test in one shot.
If yarn test fails with ERR_MODULE_NOT_FOUND on an @cards/*/@homeassistant-extras/hass/*/etc. import, don't chase path-alias config. It's almost always a TypeScript compile error in the imported file or a transitive import. Run yarn typecheck (or npx tsc -p tsconfig.test.json --noEmit) and fix what it reports.
yarn build- Build the project using Parcel (outputs to dist/)yarn watch- Watch mode for development (rebuilds on changes)yarn format- Format code using Prettieryarn lint- ESLint (TypeScript + Lit + web component best practices)yarn lint:fix- ESLint with auto-fix where safeyarn typecheck-tscagainsttsconfig.jsonandtsconfig.test.jsonyarn pass- format + typecheck + lint + test (run before shipping)yarn update- Update dependencies with npm-check-updates
yarn test- Run unit tests using Mocha with TypeScriptyarn test:coverage- Run tests with NYC coverage reportingyarn test:watch- Run tests in watch mode for developmentyarn test:e2e- Run Playwright end-to-end tests against a live Home Assistant instanceyarn test:e2e:auth- Capture a Playwright storage state for authenticated e2e runs (requires.envwithPLAYWRIGHT_HA_ORIGINandPLAYWRIGHT_HA_STORAGE_STATE)
To run a specific test file:
TS_NODE_PROJECT='./tsconfig.test.json' npx mocha test/path/to/specific.spec.tsThis is a Home Assistant custom card built with LitElement/Lit that displays room summaries with climate data, entity states, and visual indicators.
- Entry Point (
src/index.ts): Registers custom elements and card with Home Assistant - Card Component (
src/cards/card.ts): Main Lit-based card component - Sub-components: Modular Lit components for different UI sections
- Delegates: Business logic handlers for data processing and state management
- Theme System: Comprehensive styling and theming support
- HASS Integration: Home Assistant API and type definitions
src/cards/: Lit-based UI components (main card, sub-components, badges, sliders)src/config/: Configuration parsing, defaults, and schema helperssrc/delegates/: Business logic separated from UI (retrievers, checks, utilities)src/editor/: Visual configuration editor and its row/sub-element editorssrc/html/: HTML template functions for UI renderingsrc/localize/: Localization helpers consumingsrc/translations/src/theme/: Theming system, CSS generation, color managementsrc/translations/: JSON translation bundlessrc/types/: TypeScript type definitions for config, sensors, etc.src/util/: Generic utility helpers shared across layers
The project uses path aliases defined in tsconfig.json:
@cards/*→./src/cards/*@config/*→./src/config/*@delegates/*→./src/delegates/*@editor/*→./src/editor/*@homeassistant-extras/hass/*→ shared package (vendored HA frontend helpers, types, mixins, etc.)@html/*→./src/html/*@localize/*→./src/localize/*@theme/*→./src/theme/*@type/*→./src/types/*@util/*→./src/util/*@test/*→./test/*@/*→./src/*
The card registers multiple custom elements (see src/index.ts):
room-summary-card- Main card componentroom-summary-card-editor- Visual configuration editorsensor-collection,entity-collection,entity-slider,room-state-icon,room-badge- Sub-componentsroom-summary-entity-detail-editor,room-summary-entities-row-editor,room-summary-states-row-editor,room-summary-thresholds-row-editor,room-summary-badge-row-editor,room-summary-sub-element-editor- Editor row/sub-element components
Additional @customElement-decorated components are registered inline under src/cards/components/ (e.g. area-statistics, problem-entity-row, problem-entity-list, problem-dialog, horizontal-slider, room-sensor-label, room-entity-label, room-badge-label).
- Configuration: Card receives config from Home Assistant dashboard
- Delegates: Process config and fetch/calculate required data
- State Management: Components update based on HASS state changes
- Rendering: Lit components render UI with calculated data and theme styles
- Sensor Averaging: Delegates calculate averages by device class (temperature, humidity)
- Entity Discovery: Automatic area-based entity discovery with manual overrides
- Theme Integration: Multi-theme support (Default HA, UI Minimalist, iOS themes)
- Climate Thresholds: Configurable thresholds with visual indicators
- Background Images: Support for area pictures, custom images, and entity-based images
- Framework: Mocha + Chai + Sinon for unit tests
- TypeScript: Tests use separate
tsconfig.test.json - DOM Testing: Uses JSDOM (+
@open-wc/testing,@testing-library/dom) for component testing - Coverage: NYC with Istanbul for coverage reporting
- Setup:
mocha.setup.tsprovides test environment configuration - End-to-end: Playwright tests run against a live Home Assistant instance via
yarn test:e2e; auth state is captured withyarn test:e2e:auth
- Bundler: Parcel 2.x for module bundling
- Target: Single JS file for Home Assistant integration
- TypeScript: Strict mode with experimental decorators for Lit
- Code Quality: Prettier with import sorting plugins
The card integrates deeply with Home Assistant's:
- Area Registry: For automatic entity discovery
- Entity Registry: For entity metadata and relationships
- Device Registry: For device information
- State Management: Real-time state updates via WebSocket
- Action System: Tap/hold actions on entities
- Custom Card Registry: Registration for dashboard usage