WashData is a Home Assistant custom integration that monitors washing machines, dryers, dishwashers, and coffee machines via smart socket power readings. It uses NumPy-powered shape correlation matching to detect cycle programs and estimate completion times.
Repository: /root/ha_washdata
Current Version: 0.4.3
- ONLY NumPy allowed - No SciPy, scikit-learn, or other ML libraries
- No external API calls - All processing must be local
- Verify
manifest.jsonrequirements if adding dependencies
- ALWAYS use
dt_util.now()for timezone-aware datetimes - All time/energy calculations MUST be dt-aware (use timestamps, not sample counts)
- Energy integration:
Σ P * dtwith explicit gap handling
- NO inline strings in Python code for UI text
- All labels/descriptions in
strings.jsonandtranslations/en.json - Translation keys format:
step_name.data.field_nameorstep_name.description
- Use
async_update_entryfor config entry modifications - Implement
async_migrate_entryin__init__.pyfor migrations - Store tunables in
entry.options, identity keys inentry.data - Debug entities gated behind
expose_debug_entitiesoption
- 32KB limit on Home Assistant event data
- ALWAYS exclude
power_data,debug_data,power_tracefrom fired events
- Config entry versioning: VERSION/MINOR_VERSION
- Migration must be deterministic and idempotent
- NEVER drop user data - preserve cycles, labels, corrections
- Add migration tests with old-schema fixtures
WashDataManager (manager.py)
├── CycleDetector (cycle_detector.py)
│ └── State machine: OFF→STARTING→RUNNING↔PAUSED→ENDING→OFF
├── ProfileStore (profile_store.py)
│ └── Multi-stage matching: Fast Reject → Core Similarity → DTW-Lite
└── LearningManager (learning.py)
└── User feedback processing (80/20 weighting)
| File | Responsibility |
|---|---|
manager.py (~104KB) |
Main orchestrator, power events, progress tracking |
profile_store.py (~88KB) |
Storage, compression, NumPy matching |
config_flow.py (~65KB) |
Config wizard, options flow |
cycle_detector.py (~20KB) |
State machine logic |
const.py (~8KB) |
Constants, config keys, defaults |
learning.py (~10KB) |
Feedback/learning system |
Stage 1 - Fast Reject:
- Duration ratio (0.75x - 1.25x)
- Energy delta check (>50% = reject)
Stage 2 - Core Similarity (weighted score):
- MAE (40%) + Correlation (40%) + Peak Power (20%)
- Confidence boost (+20%) if correlation > 0.85
Stage 3 - DTW-Lite (tie-breaker only):
- Sakoe-Chiba band constraint
- Only when margin < ambiguity threshold
# Syntax check
python3 -m py_compile custom_components/ha_washdata/*.py
# Run tests
pytest tests/ -vpython3 devtools/mqtt_mock_socket.py --speedup 720 --default LONG --variability 0.15Copy custom_components/ha_washdata/ to HA, restart.
Priority items (see .dev_notes/ for details):
- Remove deprecated Smart Extension logic
- Remove deprecated constants from
const.py - Per-device defaults: don't leak dicts into Options schema
- Gate predictive end when match is ambiguous
README.md: User guide, installationIMPLEMENTATION.md: Architecture detailsTESTING.md: Test procedures, mock socket guideCHANGELOG.md: Release history.dev_notes/: Development notes and fix tracking.agent/workflows/development.md: Full development workflow
This file provides context for AI development assistants working on WashData.