### Set up Python virtual environment and install development dependencies Source: https://github.com/3dg1luk43/ha_washdata/blob/main/CLAUDE.md Creates a virtual environment, activates it, and installs the development requirements. Run these commands in sequence from the repository root. ```bash python3 -m venv .venv source .venv/bin/activate pip install -r requirements-dev.txt ``` -------------------------------- ### Build panel and git hooks commands Source: https://github.com/3dg1luk43/ha_washdata/blob/main/CLAUDE.md Build the panel after editing www/*.js; --check verifies only and returns non-zero if stale. Install tracked git hooks once per clone. ```bash node devtools/build_panel.mjs # REQUIRED after editing www/*.js ``` ```bash node devtools/build_panel.mjs --check # verify only; non-zero if stale ``` ```bash ./devtools/install_hooks.sh # install tracked git hooks (once per clone) ``` -------------------------------- ### Run mock MQTT plug Source: https://github.com/3dg1luk43/ha_washdata/wiki/Testing Start the mock plug with a WashData export file. Open the web UI at http://:8081 and press Start. ```bash python3 devtools/mqtt_mock_socket.py --source path/to/washdata_export.json ``` -------------------------------- ### Record start service call (ha_washdata.record_start) Source: https://github.com/3dg1luk43/ha_washdata/blob/main/README.md Starts recording a wash program from a button or automation. Requires the device_id of the washer. Use this to manually record a program start. ```yaml action: ha_washdata.record_start data: device_id: "washer_device_id" ``` -------------------------------- ### Install dependencies and configure secrets Source: https://github.com/3dg1luk43/ha_washdata/wiki/Testing Install required Python packages and copy the secrets template before running the mock plug. ```bash pip install paho-mqtt nicegui # not in requirements-dev.txt cp devtools/secrets.py.template devtools/priv_secrets.py # set MQTT_HOST, MQTT_PORT, user, password ``` -------------------------------- ### Evaluation scripts (eval.py and related) Source: https://github.com/3dg1luk43/ha_washdata/blob/main/CLAUDE.md Run various evaluation scripts for LOO matcher accuracy, paired deltas, end-gate lag, projected-energy accuracy, on-device total_energy promotion gate, dishwasher plug-pull fast finalize, Status card margin knots, first-ETA timing, mid-cycle switch bypass, min_off_gap bounds, start gates, stored cycle start vs raw onset, replay vs real manager, and apply-all loop per device. Each has specific options and outputs. ```bash python3 devtools/eval.py run --mode fast # LOO matcher accuracy on the SHIPPED path (audit F1) ``` ```bash python3 devtools/eval.py compare BASE.json NEW.json # paired deltas, McNemar, guarded metrics ``` ```bash python3 devtools/end_gate_eval.py --loo # ENDING fallback-gate lag/early-end/split (item 329); add --all-formats (diagnostics dumps + user-Contributed, item 465) and --shipped-watchdog; --jobs N (default cpu-1, max 8; rows identical to --jobs 1) ``` ```bash python3 devtools/energy_projection_eval.py # projected-energy accuracy, LOO (audit PROGRESS-04) ``` ```bash python3 devtools/ml_energy_gate_eval.py # on-device total_energy promotion gate vs naive and incumbent (audit ML-12) ``` ```bash python3 devtools/terminal_drop_plugpull_eval.py # dishwasher plug-pull fast finalize, LOO (audit ML-08); --rule off|ungated|guarded ``` ```bash python3 devtools/margin_display_fit.py # fits the Status card's "~N% sure" knots from an eval.py run (MATCH-DECIDE-15) ``` ```bash python3 devtools/eta_eval.py --all-formats # first-ETA timing + ETA error by elapsed fraction, LOO (item 475) ``` ```bash python3 devtools/decisive_margin_eval.py --loo # mid-cycle switch bypass, runner-up exposure; --switching: commit/switch accuracy ``` ```bash python3 devtools/end_gate_eval.py --loo --all-formats --check devtools/end_gate_baseline.json # exit 1 on an end-gate regression ``` ```bash python3 devtools/min_off_gap_eval.py # min_off_gap split/merge bounds (replays UNMATCHED) ``` ```bash python3 devtools/start_gate_eval.py # start gates on a raw idle+cycle history (missed/late/phantom) ``` ```bash python3 devtools/lead_in_eval.py # stored cycle start vs raw onset on the start-gate manifest (#463) ``` ```bash python3 devtools/playground_parity_eval.py --mode replay # replay vs the real manager: ends/programs that differ (F7) ``` ```bash python3 devtools/suggestion_loop_eval.py # apply-all loop per device: fixed point / ladder / oscillation / erased cycles (F10) ``` -------------------------------- ### Clone and set up development environment Source: https://github.com/3dg1luk43/ha_washdata/blob/main/CONTRIBUTING.md Sets up a local development environment for WashData. Requires Python 3.13 and a GitHub fork. Initializes translation tooling submodules, creates a virtual environment, installs dependencies, and installs a pre-commit hook for the panel build. ```bash git clone https://github.com/YOUR_USERNAME/ha_washdata.git cd ha_washdata git submodule update --init --recursive # translation tooling python3 -m venv .venv && source .venv/bin/activate pip install -r requirements-dev.txt ./devtools/install_hooks.sh # pre-commit hook for the panel build ``` -------------------------------- ### Quick start: up, smoke, down Source: https://github.com/3dg1luk43/ha_washdata/blob/main/devtools/testbox/README.md Run the testbox container, the end-to-end smoke test, and stop the container. `./up.sh --fresh` takes about 40 seconds and creates the container, config, owner user, and long-lived token. `./smoke.sh` takes about 12 minutes and runs one full cycle end to end, then the assertions. `./down.sh` stops the container; add `--wipe` to delete config/ too. ```bash cd devtools/testbox ./up.sh --fresh # ~40 s: container, config, owner user, long-lived token ./smoke.sh # ~12 min: one full cycle end to end, then the assertions ./down.sh # stop (add --wipe to delete config/ too) ``` -------------------------------- ### get_setup_status Source: https://github.com/3dg1luk43/ha_washdata/blob/main/docs/WS_API.md Retrieves the setup status for a specific device. ```APIDOC ## get_setup_status ### Description Retrieves the setup status for a specific device. ### Command `ha_washdata/get_setup_status` ### Parameters - **entry_id** (string) - Required - The entry ID of the device. ### Response - **GetSetupStatusResponse** - The response containing the setup status. ``` -------------------------------- ### Test box commands Source: https://github.com/3dg1luk43/ha_washdata/blob/main/CLAUDE.md Run the real-HA container test box. up.sh --fresh starts a fresh container; smoke.sh runs one cycle end-to-end on real HA with 20 checks (~12 min); check_notify_actions.sh tests the notification-ACTION delivery path (~1 min); check_unload_confirm.sh tests the unload confirmation button/service/entity (~3 min); hactl.py drives the integration with a WebSocket command. ```bash cd devtools/testbox && ./up.sh --fresh # real-HA container test box (see its README.md) ``` ```bash cd devtools/testbox && ./smoke.sh # one cycle end-to-end on real HA + 20 checks (~12 min) ``` ```bash cd devtools/testbox && ./check_notify_actions.sh # the notification-ACTION delivery path (~1 min) ``` ```bash cd devtools/testbox && ./check_unload_confirm.sh # unload confirmation button/service/entity (~3 min) ``` ```bash cd devtools/testbox && ./hactl.py ws ha_washdata/get_profiles entry_id= # drive it ``` -------------------------------- ### Install development dependencies Source: https://github.com/3dg1luk43/ha_washdata/blob/main/requirements-dev.txt Commands to create a virtual environment and install the development dependencies listed in requirements-dev.txt. ```bash python3 -m venv .venv && source .venv/bin/activate pip install -r requirements-dev.txt ``` -------------------------------- ### verify.sh usage examples Source: https://github.com/3dg1luk43/ha_washdata/blob/main/devtools/README.md Shows the quick and full verification modes with optional flags like --box, --cores, --dry-run, and --no-cache. The quick mode runs generated files, docs_check, fast suite, and E2E (readable); full adds slow suite, E2E (minified), release_check, end_gate_eval, and eval.py baseline tasks. The --box flag enables the real-HA test box, --cores shares a specified number of cores, --dry-run only prints stages and estimates, and --no-cache forces re-running stages even if inputs are unchanged. ```bash devtools/verify.sh # quick: generated files, docs_check, fast suite, E2E (readable) devtools/verify.sh full # + slow suite, E2E (minified), release_check --skip-tests, # end_gate_eval --check, eval.py baseline-status + run/compare devtools/verify.sh full --box # + the real-HA test box (never by default) devtools/verify.sh full --cores 4 # share 4 cores (default: every usable core) devtools/verify.sh full --dry-run # stages, work estimates, first allocation; runs nothing devtools/verify.sh full --no-cache # also re-run stages whose inputs are unchanged since a pass ``` -------------------------------- ### start_recording Source: https://github.com/3dg1luk43/ha_washdata/blob/main/docs/WS_API.md Starts recording for a specific device. ```APIDOC ## start_recording ### Description Starts recording for a specific device. ### Command `ha_washdata/start_recording` ### Parameters - **entry_id** (string) - Required - The entry ID of the device. ### Response - **SuccessResponse** - Indicates whether the operation was successful. ``` -------------------------------- ### Verify script commands Source: https://github.com/3dg1luk43/ha_washdata/blob/main/CLAUDE.md Run the verify script for quick checks or full pre-push validation. The quick mode runs generated files, docs_check, fast suite, and E2E readable (~3 min on 4 cores). Full mode adds slow suite, E2E min, release_check --skip-tests, end_gate --check, and eval.py gate on one dynamically shared core budget; ~10 min cold on this 4C/8T box, ~6.7 min after a Python-only change. --box adds the real-HA test box (never by default); --no-cache runs every stage regardless of the result cache. ```bash devtools/verify.sh # quick: generated files, docs_check, fast suite, E2E readable (~3 min on 4 cores) ``` ```bash devtools/verify.sh full # pre-push: + slow suite, E2E min, release_check --skip-tests, end_gate --check, eval.py gate on one dynamically shared core budget; ~10 min cold on this 4C/8T box, ~6.7 min after a Python-only change (E2E/end-gate reported `cached` when their inputs are unchanged since a pass) ``` ```bash devtools/verify.sh full --box # + the real-HA test box (never by default; the summary names changed files that need it) ``` ```bash devtools/verify.sh full --no-cache # run every stage regardless of the result cache (use before a release) ``` ```bash devtools/release_check.sh --skip-tests # every release check except the test suites ``` -------------------------------- ### start_playground_cycle_detail Source: https://github.com/3dg1luk43/ha_washdata/blob/main/docs/WS_API.md Starts a playground cycle detail task for an entry. ```APIDOC ## start_playground_cycle_detail ### Description Starts a playground cycle detail task for an entry. ### Parameters - **entry_id** (string) - Required - The entry identifier. - **cycle_id** (string) - Required - The cycle identifier. - **settings_override** (object) - Optional - Settings override. ### Response - **StartTaskResponse** - Task start confirmation. ``` -------------------------------- ### Restart integration after editing Source: https://github.com/3dg1luk43/ha_washdata/blob/main/devtools/testbox/README.md Restart the testbox after editing the integration. Because the integration is bind-mounted, the box always runs the code you are editing; Python is loaded once at startup, so a restart is needed after edits. The command restarts and waits for HA and for WashData to finish setup. ```bash ./hactl.py restart # restart + wait for HA *and* for WashData to finish setup ``` -------------------------------- ### Template sensor for kW to watts (0.5.8 and older) Source: https://github.com/3dg1luk43/ha_washdata/wiki/Smart-Plugs For plugs reporting in kW on WashData 0.5.8 and older, create a template sensor that converts kW to watts. State: `{{ states('sensor.washer_power_kw') | float(0) * 1000 }}`, unit W, device class Power. ```jinja2 {{ states('sensor.washer_power_kw') | float(0) * 1000 }} ``` -------------------------------- ### start_playground_history Source: https://github.com/3dg1luk43/ha_washdata/blob/main/docs/WS_API.md Starts a playground history task for an entry. ```APIDOC ## start_playground_history ### Description Starts a playground history task for an entry. ### Parameters - **entry_id** (string) - Required - The entry identifier. - **cycle_ids** (array) - Optional - List of cycle IDs. - **settings_override** (object) - Optional - Settings override. - **count** (integer) - Optional - Number of cycles to process. ### Response - **StartTaskResponse** - Task start confirmation. ``` -------------------------------- ### Test suite commands Source: https://github.com/3dg1luk43/ha_washdata/blob/main/CLAUDE.md Run the test suite with various options: fast (default), slow, bench, E2E, E2E-min, or all. The fast suite uses pytest-xdist with one worker per core up to 8; --serial runs one process. The slow tier uses --dist loadgroup with one group per suggestion-loop device. E2E runs Playwright on chromium and mobile-chrome; --e2e-min tests the minified build. --all runs everything (~13 min). ```bash ./run_tests.sh # fast suite (default; pytest-xdist, one worker per core up to 8: ~30 s on 4 cores; --serial = one process) ``` ```bash ./run_tests.sh --slow # slow tier on pytest-xdist --dist loadgroup (one group per suggestion-loop device; ~4.5 min on 4 cores) ``` ```bash ./run_tests.sh --bench # none left: work budgets run in the fast suite (tests/test_perf_budgets.py) ``` ```bash ./run_tests.sh --e2e # Playwright E2E (chromium + mobile-chrome, ~2 min) ``` ```bash ./run_tests.sh --e2e-min # same E2E against the minified build (the bytes users download) ``` ```bash ./run_tests.sh --all # everything (~13 min) ``` -------------------------------- ### start_history_import_scan Source: https://github.com/3dg1luk43/ha_washdata/blob/main/docs/WS_API.md Starts a history import scan task. ```APIDOC ## start_history_import_scan ### Description Starts a history import scan task. ### Parameters - **entry_id** (string) - Required - The entry identifier. - **token** (string) - Required - The import session token. ### Response - **StartTaskResponse** - Task start confirmation. ``` -------------------------------- ### MQTT mock socket commands Source: https://github.com/3dg1luk43/ha_washdata/blob/main/CLAUDE.md Mock MQTT plug into a real HA with a web UI on :8081. Use --dry-run with --scenario soak and --mode silent for a dry run. ```bash python3 devtools/mqtt_mock_socket.py --source # mock MQTT plug into a real HA (web UI :8081) ``` ```bash python3 devtools/mqtt_mock_socket.py --dry-run --source --scenario soak --mode silent ``` -------------------------------- ### start_playground_sweep Source: https://github.com/3dg1luk43/ha_washdata/blob/main/docs/WS_API.md Starts a playground sweep task for an entry. ```APIDOC ## start_playground_sweep ### Description Starts a playground sweep task for an entry. ### Parameters - **entry_id** (string) - Required - The entry identifier. - **param** (string) - Required - The parameter to sweep. - **values** (array) - Required - The values to sweep. - **objective** (string) - Required - The objective function. - **cycle_ids** (array) - Optional - List of cycle IDs. - **count** (integer) - Optional - Number of cycles to process. ### Response - **StartTaskResponse** - Task start confirmation. ``` -------------------------------- ### Playwright E2E commands Source: https://github.com/3dg1luk43/ha_washdata/blob/main/CLAUDE.md Run Playwright E2E tests directly from the playwright-tests directory. Use --ui for interactive mode. Specify a test file or run all tests. ```bash cd playwright-tests && npx playwright test # E2E directly ``` ```bash cd playwright-tests && npx playwright test tests/settings.spec.ts ``` ```bash cd playwright-tests && npx playwright test --ui ``` -------------------------------- ### ha_washdata/get_setup_status Source: https://github.com/3dg1luk43/ha_washdata/blob/main/docs/WS_API.md Retrieves the current setup status for a given entry. Returns phase information and possible actions. ```APIDOC ## ha_washdata/get_setup_status ### Description Retrieves the current setup status for a given entry. Returns phase information and possible actions. ### Method WebSocket command ### Endpoint `ha_washdata/get_setup_status` ### Parameters #### Request Parameters - **entry_id** (str) - Required - The entry identifier. ### Response #### Success Response - **phase** (str) - Optional - Current setup phase. - **message_key** (str) - Optional - Key for a localized message. - **message_params** (dict) - Optional - Parameters for the message. - **cta_label_key** (str) - Optional - Key for the call-to-action label. - **cta_action** (str) - Optional - Action for the call-to-action. - **secondary_label_key** (str | null) - Optional - Key for secondary label. - **secondary_action** (str | null) - Optional - Action for secondary button. - **skippable** (bool) - Optional - Whether the step can be skipped. - **dismissible** (bool) - Optional - Whether the step can be dismissed. - **step_key** (str | null) - Optional - Key for the current step. #### Response Example ```json { "phase": "string", "message_key": "string", "message_params": {}, "cta_label_key": "string", "cta_action": "string", "secondary_label_key": "string", "secondary_action": "string", "skippable": true, "dismissible": true, "step_key": "string" } ``` ``` -------------------------------- ### Directly call _async_migrate_func for storage migration testing Source: https://github.com/3dg1luk43/ha_washdata/blob/main/CLAUDE.md Use this to test storage migration steps without file I/O. Call _async_migrate_func(old_version, 1, data) directly on a WashDataStore instance, not through ProfileStore.async_load(). ```python store = WashDataStore(_make_hass(), STORAGE_VERSION, f"{STORAGE_KEY}.test") result = await store._async_migrate_func(12, 1, data) ``` -------------------------------- ### ha_washdata/start_recording Source: https://github.com/3dg1luk43/ha_washdata/blob/main/docs/WS_API.md Starts a recording for the specified entry. Requires the entry ID. ```APIDOC ## ha_washdata/start_recording ### Description Starts a recording for the specified entry. Requires the entry ID. ### Method POST ### Endpoint ha_washdata/start_recording ### Parameters #### Request Body - **entry_id** (str) - Required - The ID of the entry to start recording. ### Response #### Success Response (200) - **success** (bool) - Always present - Indicates whether the operation succeeded. #### Response Example { "success": true } ``` -------------------------------- ### Run Playwright E2E tests Source: https://github.com/3dg1luk43/ha_washdata/wiki/Testing Commands to run E2E tests with readable panel source (port 4567) or minified files (port 4568). The test server and mock WebSocket backend start automatically. --e2e-min refuses to run on a stale minified build; run both before a release. ```bash ./run_tests.sh --e2e # readable panel source (port 4567) ./run_tests.sh --e2e-min # minified *.min.js, the files users download (port 4568) cd playwright-tests npx playwright test # all specs npx playwright test tests/settings.spec.ts npx playwright test --ui # interactive ``` -------------------------------- ### Pytest and syntax check commands Source: https://github.com/3dg1luk43/ha_washdata/blob/main/CLAUDE.md Run specific pytest tests or a syntax check. Use -v for verbose output; specify a test function with ::test_function_name. The compileall command checks syntax in the custom_components and tests directories. ```bash pytest tests/test_cycle_detector.py -v ``` ```bash pytest tests/test_cycle_detector.py::test_function_name -v ``` ```bash python3 -m compileall custom_components/ha_washdata tests/ -q # syntax check ``` -------------------------------- ### ha_washdata/start_playground_cycle_detail Source: https://github.com/3dg1luk43/ha_washdata/blob/main/docs/WS_API.md Starts a playground cycle detail task. Requires an entry ID and cycle ID, with optional settings override. ```APIDOC ## ha_washdata/start_playground_cycle_detail ### Description Starts a playground cycle detail task. Requires an entry ID and cycle ID, with optional settings override. ### Method POST ### Endpoint ha_washdata/start_playground_cycle_detail ### Parameters #### Request Body - **entry_id** (str) - Required - Description not provided. - **cycle_id** (str) - Required - Description not provided. - **settings_override** (dict) - Optional - Description not provided. ### Response #### Success Response (200) - **task_id** (str) - Always present - Description not provided. #### Response Example { "task_id": "string" } ``` -------------------------------- ### ha_washdata/start_playground_history Source: https://github.com/3dg1luk43/ha_washdata/blob/main/docs/WS_API.md Starts a playground history task for a given entry. Returns a StartTaskResponse with the new task_id. ```APIDOC ## ha_washdata/start_playground_history ### Description Starts a playground history task for a given entry. Returns a StartTaskResponse with the new task_id. ### Method WebSocket command ### Endpoint ha_washdata/start_playground_history ### Parameters #### Request Parameters - **entry_id** (str) - Required - The entry ID. - **cycle_ids** (list[str]) - Optional - List of cycle IDs. - **settings_override** (dict) - Optional - Settings overrides. - **count** (int) - Optional - Number of items. ### Response #### Success Response - **task_id** (str) - Always present - The ID of the started task. ``` -------------------------------- ### Release check commands Source: https://github.com/3dg1luk43/ha_washdata/blob/main/CLAUDE.md Run the release preflight that CI runs. --fix regenerates artifacts instead of failing; --full --tag v0.5.6 runs with a specific tag. The docs_check script validates doc anchors, constants, register ids, deep-dive identifiers, and em-dash ratchet against code. ```bash devtools/release_check.sh # release preflight (what CI runs) ``` ```bash devtools/release_check.sh --fix # regenerate artifacts instead of failing ``` ```bash devtools/release_check.sh --full --tag v0.5.6 ``` ```bash python3 devtools/docs_check.py # doc anchors/constants/register ids/deep-dive identifiers/em-dash ratchet vs code ``` -------------------------------- ### Run mqtt_mock_socket.py with various options Source: https://github.com/3dg1luk43/ha_washdata/blob/main/devtools/README.md Commands to run the mock MQTT plug: web UI on :8081, as a systemd service, list scenarios, dry-run, and headless play. Requires paho-mqtt and nicegui; broker from priv_secrets.py. ```bash python3 devtools/mqtt_mock_socket.py # web UI on :8081 ``` ```bash ./run_mock.sh on | off # same, as a systemd service enabled at boot ``` ```bash python3 devtools/mqtt_mock_socket.py --list --source # scenarios, modes, programmes ``` ```bash python3 devtools/mqtt_mock_socket.py --dry-run --source --scenario soak --mode silent ``` ```bash python3 devtools/mqtt_mock_socket.py --headless --source --play random \ --scenario back-to-back --runs 3 --gap-min 20 --exit-after-min 30 ``` -------------------------------- ### Run release_check.sh with various options Source: https://github.com/3dg1luk43/ha_washdata/wiki/Developer-Tools Verifies build artifacts, version consistency, translations, code quality, tests, and hygiene. Exits with the number of failed checks; each failure prints the fixing command. Use --fix to regenerate artifacts, --full for slow and E2E tests, --tag to require version match, --skip-tests to skip test suites. ```bash devtools/release_check.sh # verify only (what CI runs on a tag) devtools/release_check.sh --fix # regenerate the artifacts instead of failing devtools/release_check.sh --full # also the slow suite and both E2E runs devtools/release_check.sh --tag v0.5.8 # also require the tag to match manifest.json devtools/release_check.sh --skip-tests # every check except the test suites ``` -------------------------------- ### Set options to remove start-energy gate artifact Source: https://github.com/3dg1luk43/ha_washdata/blob/main/devtools/testbox/README.md Use this command in the box to remove the start-energy gate artifact caused by time compression. The energy a compressed prelude delivers shrinks by the speedup factor, so setting start_energy_threshold to the default divided by the speedup compensates. ```bash ./hactl.py set-options start_energy_threshold= ``` -------------------------------- ### Run eval.py in fast mode Source: https://github.com/3dg1luk43/ha_washdata/blob/main/devtools/README.md Runs the matching accuracy evaluation in fast mode (8 cycles per device) and writes results to /tmp/new.json. Takes about 1 minute on 8 cores. ```bash python3 devtools/eval.py run --mode fast --out /tmp/new.json ``` -------------------------------- ### Set halved options for standby-band and merge tests Source: https://github.com/3dg1luk43/ha_washdata/blob/main/devtools/testbox/README.md Run this command after smoke.sh to halve all shipped option values, enabling standby-band finalize and gap preservation at 2x speedup. Each must be the shipped value halved. ```bash ./hactl.py set-options off_delay= min_off_gap= sampling_interval= watchdog_interval= profile_match_interval= completion_min_seconds= interrupted_min_seconds= ``` -------------------------------- ### Replay cycle at 2x speedup Source: https://github.com/3dg1luk43/ha_washdata/blob/main/devtools/testbox/README.md Replays a cycle at 2x speedup to test standby-band finalize and gap preservation. Use on a cycle whose tail holds a flat standby above stop_threshold_w. ```bash ./hactl.py replay --cycle N --speedup 2 ``` -------------------------------- ### ha_washdata/start_history_import_scan Source: https://github.com/3dg1luk43/ha_washdata/blob/main/docs/WS_API.md Starts a history import scan for a given entry. Returns a task ID for tracking the scan. ```APIDOC ## ha_washdata/start_history_import_scan ### Description Starts a history import scan for a given entry. Returns a task ID for tracking the scan. ### Method WebSocket command ### Endpoint `ha_washdata/start_history_import_scan` ### Parameters #### Request Parameters - **entry_id** (str) - Required - The entry ID. - **token** (str) - Required - The token. ### Response (`StartTaskResponse`) - **task_id** (str) - Always present - The task ID. ``` -------------------------------- ### hactl.py CLI commands for manual testing Source: https://github.com/3dg1luk43/ha_washdata/blob/main/devtools/testbox/README.md Commands to drive the WashData integration manually via the repo venv. Requires the venv with aiohttp; run with $REPO/.venv/bin/python3 hactl.py or ./hactl.py if venv is active. Covers states, set, WebSocket commands, import/export, replay, notifications, and errors. ```bash ./hactl.py states sensor.test_dishwasher # every WashData entity + value ./hactl.py state sensor.test_dishwasher_state ./hactl.py set sensor.washdata_power 1200 # push a power reading ./hactl.py entry-id # the config entry id ./hactl.py ws ha_washdata/get_profiles entry_id= ./hactl.py ws ha_washdata/get_options entry_id= ./hactl.py set-options off_delay=10 notify_live_chronometer=true ./hactl.py compress-export --speedup 60 ./hactl.py import ./hactl.py replay --cycle 3 --speedup 120 --tail 45 ./hactl.py notifications # what actually reached a platform ./hactl.py errors # ERROR/WARNING/MultipleInvalid lines ``` -------------------------------- ### ha_washdata/rebuild_envelopes Source: https://github.com/3dg1luk43/ha_washdata/blob/main/docs/WS_API.md Starts a task to rebuild envelopes for a given entry. Returns a task ID for tracking the operation. ```APIDOC ## ha_washdata/rebuild_envelopes ### Description Starts a task to rebuild envelopes for a given entry. Returns a task ID for tracking the operation. ### Method WS (WebSocket) ### Endpoint `ha_washdata/rebuild_envelopes` ### Parameters #### Request Parameters - **entry_id** (str) - Required - The entry identifier. ### Response #### Success Response (`StartTaskResponse`) - **task_id** (str) - Always present - The task identifier. #### Response Example ```json { "task_id": "string" } ``` ``` -------------------------------- ### ha_washdata/apply_history_import Source: https://github.com/3dg1luk43/ha_washdata/blob/main/docs/WS_API.md Applies a history import based on a previously started scan. Returns a task ID for tracking the import. ```APIDOC ## ha_washdata/apply_history_import ### Description Applies a history import based on a previously started scan. Returns a task ID for tracking the import. ### Method WebSocket command ### Endpoint `ha_washdata/apply_history_import` ### Parameters #### Request Parameters - **entry_id** (str) - Required - The entry ID. - **scan_task_id** (str) - Required - The scan task ID. - **accept** (list) - Required - List of accepted items. ### Response (`StartTaskResponse`) - **task_id** (str) - Always present - The task ID. ``` -------------------------------- ### List scenarios, modes, and programs Source: https://github.com/3dg1luk43/ha_washdata/wiki/Testing Show available scenarios, reporting modes, and programs for a given export file. ```bash python3 devtools/mqtt_mock_socket.py --list --source # scenarios, modes, programs ``` -------------------------------- ### ha_washdata/history_import_recorder Source: https://github.com/3dg1luk43/ha_washdata/blob/main/docs/WS_API.md Imports history data from a recorder. Requires an entry ID, with optional start date and number of days. ```APIDOC ## ha_washdata/history_import_recorder ### Description Imports history data from a recorder. Requires an entry ID, with optional start date and number of days. ### Method POST ### Endpoint ha_washdata/history_import_recorder ### Parameters #### Request Body - **entry_id** (str) - Required - Description not provided. - **start_date** (str|null) - Optional - Description not provided. - **days** (int) - Optional - Description not provided. ### Response #### Success Response (200) - **token** (str) - Always present - Description not provided. - **rows** (number) - Always present - Description not provided. - **entity_id** (str) - Always present - Description not provided. - **days** (number) - Always present - Description not provided. - **start_date** (str) - Always present - Description not provided. - **truncated** (bool) - Always present - Description not provided. #### Response Example { "token": "string", "rows": 0, "entity_id": "string", "days": 0, "start_date": "string", "truncated": true } ``` -------------------------------- ### Run suggestion analyser on a diagnostics dump Source: https://github.com/3dg1luk43/ha_washdata/wiki/Developer-Tools Offline tool that shows what the shipped suggestion engine would propose for a WashData export or diagnostics dump. Builds the device's real manager from the file's settings, rebuilds program curves, and lists per-setting suggestions with reasons, plus a per-program cycle summary. Requires a diagnostics dump from Settings > Devices & services > WashData, three-dot menu, Download diagnostics. ```bash python3 devtools/analyze_diag.py path/to/export.json ``` ```bash python3 devtools/analyze_diag.py path/to/export.json --json out.json # also write a JSON report ``` ```bash python3 devtools/analyze_diag.py # asks for the file ``` -------------------------------- ### ha_washdata/start_playground_sweep Source: https://github.com/3dg1luk43/ha_washdata/blob/main/docs/WS_API.md Starts a playground sweep task. Requires an entry ID, parameters, values, and an objective, with optional cycle IDs and count. ```APIDOC ## ha_washdata/start_playground_sweep ### Description Starts a playground sweep task. Requires an entry ID, parameters, values, and an objective, with optional cycle IDs and count. ### Method POST ### Endpoint ha_washdata/start_playground_sweep ### Parameters #### Request Body - **entry_id** (str) - Required - Description not provided. - **param** (str) - Required - Description not provided. - **values** (list[float]) - Required - Description not provided. - **objective** (str) - Required - Description not provided. - **cycle_ids** (list[str]) - Optional - Description not provided. - **count** (int) - Optional - Description not provided. ### Response #### Success Response (200) - **task_id** (str) - Always present - Description not provided. #### Response Example { "task_id": "string" } ``` -------------------------------- ### Run eval.py in full mode Source: https://github.com/3dg1luk43/ha_washdata/blob/main/devtools/README.md Runs the evaluation on every scorable fold. Takes about 2 minutes. ```bash python3 devtools/eval.py run --mode full --out /tmp/full.json ``` -------------------------------- ### Automation: Washer done (details) Source: https://github.com/3dg1luk43/ha_washdata/wiki/Notifications-and-Events Trigger on the ha_washdata_cycle_ended event and read trigger.event.data. The condition skips false starts by checking cycle_data.status. Optionally filter by entry_id. ```yaml alias: Washer done (details) triggers: - trigger: event event_type: ha_washdata_cycle_ended event_data: entry_id: 01KR1WGJYHJBTT5MEGS0VRXC4D # optional: only this device conditions: - "{{ trigger.event.data.cycle_data.status != 'interrupted' }}" actions: - action: notify.mobile_app_pixel data: title: "{{ trigger.event.data.device_name }} finished" message: >- {{ trigger.event.data.program }}: {{ (trigger.event.data.duration / 60) | round(0) }} min, {{ (trigger.event.data.cycle_data.energy_wh / 1000) | round(2) }} kWh ``` -------------------------------- ### Automation: Washer done (binary sensor) Source: https://github.com/3dg1luk43/ha_washdata/wiki/Notifications-and-Events Trigger on the binary_sensor._running turning off. The sensor stays on through soaks, pauses, and the end wait, and turns off once at the end. A short false start can also flip it. ```yaml alias: Washer done triggers: - trigger: state entity_id: binary_sensor.washing_machine_running from: "on" to: "off" actions: - action: notify.mobile_app_pixel data: message: "The washing machine is done." ``` -------------------------------- ### Override profile_match_max_duration_ratio config Source: https://github.com/3dg1luk43/ha_washdata/blob/main/devtools/README.md Runs evaluation with a config override for profile_match_max_duration_ratio set to 1.8. ```bash python3 devtools/eval.py run --config-override '{"options": {"profile_match_max_duration_ratio": 1.8}}' ``` -------------------------------- ### Regenerate ML baseline (lab only) Source: https://github.com/3dg1luk43/ha_washdata/wiki/ML-Subsystem Run in the ml_washdata lab to retrain and promote a baseline model. The second command refuses a model whose encode/decode round trip is not deterministic. ```bash cd ml_washdata ./ml.sh experiment # retrain + determinism check python promote_to_integration.py --target ``` -------------------------------- ### Run tests and compile before pushing Source: https://github.com/3dg1luk43/ha_washdata/blob/main/CONTRIBUTING.md Runs the fast test suite and compiles all Python files to catch syntax errors before pushing changes. ```bash ./run_tests.sh # fast suite python3 -m compileall custom_components/ha_washdata tests/ -q ``` -------------------------------- ### Mark slow pytest tests with pytestmark Source: https://github.com/3dg1luk43/ha_washdata/blob/main/CLAUDE.md Use this module-level marker for new pytest tests that replay cycle_data/ traces, fan out over many cycles, or take longer than 1.5 seconds. The pytest-timeout is 60 seconds per fast test and 1800 seconds per slow one. ```python pytestmark = pytest.mark.slow ``` -------------------------------- ### YAML service call for tibber_prices.find_cheapest_block Source: https://github.com/3dg1luk43/ha_washdata/blob/main/CHANGELOG-archive.md Service call to find the cheapest block for a given duration and search scope, using a power profile from a sensor. The response is stored in a variable named 'result'. ```yaml action: tibber_prices.find_cheapest_block data: duration: "02:00:00" search_scope: next_24h power_profile: "{{ state_attr('sensor.washer_cotton_40_c', 'power_profile') }}" response_variable: result ``` -------------------------------- ### Dry-run a scenario with silent mode Source: https://github.com/3dg1luk43/ha_washdata/wiki/Testing Print what a run would publish without connecting to MQTT. ```bash python3 devtools/mqtt_mock_socket.py --dry-run --source --scenario soak --mode silent ``` -------------------------------- ### Manage mock plug as systemd service Source: https://github.com/3dg1luk43/ha_washdata/wiki/Testing Control the mock plug as a systemd service using the provided script. Requires root. ```bash ./run_mock.sh on # install, enable at boot, start ./run_mock.sh off # stop and disable ./run_mock.sh status ./run_mock.sh logs ``` -------------------------------- ### history_import_begin Source: https://github.com/3dg1luk43/ha_washdata/blob/main/docs/WS_API.md Begins a history import for an entry. ```APIDOC ## history_import_begin ### Description Begins a history import for an entry. ### Parameters - **entry_id** (string) - Required - The entry identifier. ### Response - **HistoryImportBeginResponse** - Import session token. ``` -------------------------------- ### Headless run with random play Source: https://github.com/3dg1luk43/ha_washdata/wiki/Testing Run multiple cycles headlessly, skipping the web UI and leaving saved settings untouched. ```bash python3 devtools/mqtt_mock_socket.py --headless --source --play random \ --scenario back-to-back --runs 3 --gap-min 20 --exit-after-min 30 ``` -------------------------------- ### Test box commands Source: https://github.com/3dg1luk43/ha_washdata/wiki/Testing Commands to run the test box in Docker. `smoke.sh` needs an export with at least one stored cycle and its power trace; without `--export` it looks for the maintainer's private files. Time is compressed, so it proves behaviour, not minute accuracy. ```bash cd devtools/testbox ./up.sh --fresh # ~40 s: container, owner user, token ./smoke.sh --export /path/to/washdata_export.json # ~12 min: one full cycle, then the checks ./check_notify_actions.sh # ~1 min: notification action buttons ./check_unload_confirm.sh # ~3 min: unload confirmation ./hactl.py ws ha_washdata/get_profiles entry_id= ./down.sh # stop; --wipe also deletes config/ ``` -------------------------------- ### get_options Source: https://github.com/3dg1luk43/ha_washdata/blob/main/docs/WS_API.md Retrieves the options for a specific device. ```APIDOC ## get_options ### Description Retrieves the options for a specific device. ### Command `ha_washdata/get_options` ### Parameters - **entry_id** (string) - Required - The entry ID of the device. ### Response - **GetOptionsResponse** - The response containing the device options. ``` -------------------------------- ### create_profile Source: https://github.com/3dg1luk43/ha_washdata/blob/main/docs/WS_API.md Creates a new profile for a specific device. ```APIDOC ## create_profile ### Description Creates a new profile for a specific device. ### Command `ha_washdata/create_profile` ### Parameters - **entry_id** (string) - Required - The entry ID of the device. - **name** (string) - Required - The name of the new profile. - **reference_cycle** (string) - Optional - A reference cycle ID. - **manual_duration_min** (number) - Optional - Manual duration in minutes. ### Response - **CreateProfileResponse** - The response containing the created profile. ``` -------------------------------- ### Compare eval results with baseline Source: https://github.com/3dg1luk43/ha_washdata/blob/main/devtools/README.md Compares new results against the baseline file. Exits with code 1 if a regression is detected. ```bash python3 devtools/eval.py compare devtools/eval_baseline.json /tmp/new.json ``` -------------------------------- ### apply_suggestions Source: https://github.com/3dg1luk43/ha_washdata/blob/main/docs/WS_API.md Applies suggestions for a specific device. ```APIDOC ## apply_suggestions ### Description Applies suggestions for a specific device. ### Command `ha_washdata/apply_suggestions` ### Parameters - **entry_id** (string) - Required - The entry ID of the device. - **keys** (array) - Required - The keys of the suggestions to apply. ### Response - **ApplySuggestionsResponse** - The response containing the result of applying suggestions. ``` -------------------------------- ### Syntax check with compileall Source: https://github.com/3dg1luk43/ha_washdata/wiki/Testing Performs a syntax-only check on the integration and tests directories. Use this to catch syntax errors without running the test suite. ```bash python3 -m compileall custom_components/ha_washdata tests/ -q ``` -------------------------------- ### get_panel_config Source: https://github.com/3dg1luk43/ha_washdata/blob/main/docs/WS_API.md Retrieves the current panel configuration. ```APIDOC ## get_panel_config ### Description Retrieves the current panel configuration. ### Parameters None. ### Response - **GetPanelConfigResponse** - The panel configuration. ``` -------------------------------- ### import_config Source: https://github.com/3dg1luk43/ha_washdata/blob/main/docs/WS_API.md Imports a configuration for a specific device. ```APIDOC ## import_config ### Description Imports a configuration for a specific device. ### Command `ha_washdata/import_config` ### Parameters - **entry_id** (string) - Required - The entry ID of the device. - **json_data** (object) - Required - The JSON data to import. ### Response - **ImportConfigResponse** - The response containing the import result. ``` -------------------------------- ### get_suggestions Source: https://github.com/3dg1luk43/ha_washdata/blob/main/docs/WS_API.md Retrieves suggestions for a specific device. ```APIDOC ## get_suggestions ### Description Retrieves suggestions for a specific device. ### Command `ha_washdata/get_suggestions` ### Parameters - **entry_id** (string) - Required - The entry ID of the device. ### Response - **GetSuggestionsResponse** - The response containing the suggestions. ``` -------------------------------- ### Enable debug logging in configuration.yaml Source: https://github.com/3dg1luk43/ha_washdata/wiki/Testing Add this YAML to configuration.yaml and restart Home Assistant to enable debug logging for the ha_washdata custom component. ```yaml logger: default: info logs: custom_components.ha_washdata: debug ``` -------------------------------- ### store_import_cycle Source: https://github.com/3dg1luk43/ha_washdata/blob/main/docs/WS_API.md Imports a cycle from the store. ```APIDOC ## store_import_cycle ### Description Imports a cycle from the store. ### Parameters - **entry_id** (string) - Required - The entry identifier. - **cycle_id** (string) - Required - The cycle identifier. - **target_profile** (string) - Optional - The target profile name. - **new_profile_name** (string) - Optional - The new profile name. ### Response - **StoreImportResponse** - Import confirmation. ``` -------------------------------- ### set_user_prefs Source: https://github.com/3dg1luk43/ha_washdata/blob/main/docs/WS_API.md Sets user preferences. ```APIDOC ## set_user_prefs ### Description Sets user preferences. ### Parameters - **prefs** (object) - Required - User preferences. ### Response - **SuccessResponse** - Indicates success. ``` -------------------------------- ### create_phase Source: https://github.com/3dg1luk43/ha_washdata/blob/main/docs/WS_API.md Creates a new phase in the catalog for a specific device. ```APIDOC ## create_phase ### Description Creates a new phase in the catalog for a specific device. ### Command `ha_washdata/create_phase` ### Parameters - **entry_id** (string) - Required - The entry ID of the device. - **device_type** (string) - Optional - The device type for the phase. - **name** (string) - Required - The name of the phase. - **description** (string) - Optional - A description of the phase. ### Response - **SuccessResponse** - Indicates whether the operation was successful. ``` -------------------------------- ### store_get_catalog_entry Source: https://github.com/3dg1luk43/ha_washdata/blob/main/docs/WS_API.md Retrieves a catalog entry from the store. ```APIDOC ## store_get_catalog_entry ### Description Retrieves a catalog entry from the store. ### Parameters - **entry_id** (string) - Required - The entry identifier. - **brand** (string) - Required - The brand. - **model** (string) - Required - The model. - **appliance_type** (string) - Required - The appliance type. ### Response - **StoreCatalogEntryResponse** - Catalog entry. ```