Skip to content

fix(helpers): align helper params, check success, and enable redeploy#63

Open
dimakis wants to merge 1 commit intomainfrom
fix/align-helper-params
Open

fix(helpers): align helper params, check success, and enable redeploy#63
dimakis wants to merge 1 commit intomainfrom
fix/align-helper-params

Conversation

@dimakis
Copy link
Owner

@dimakis dimakis commented Mar 9, 2026

Summary

  • Root cause fix: HA's REST config storage endpoints (/api/config/{domain}/config/{id}) return 404 for helper creation. The base HTTP client silently swallowed 404 responses, causing create_* methods to falsely report success.
  • WebSocket migration: All 8 create_* methods and delete_helper in HelperMixin now use the HA WebSocket API ({domain}/create, {domain}/delete, {domain}/list), matching the same transport HA's own frontend uses.
  • Protocol key collision fix: Passing id=input_id (a string slug) in WS params overwrote the integer message sequence id, causing HA to reject with "Message incorrectly formatted". Now stripped as a safety net in _execute, and create_* methods no longer pass id — HA auto-generates the slug from the name field.
  • Silent failure fix: _deploy_helper now checks result.get("success") before marking proposals as deployed.
  • Redeployment support: Added force flag to deploy endpoint, DEPLOYED→DEPLOYED state transition, and Redeploy button in the proposal detail UI.
  • UI cleanup: Restructured the deployed-proposal footer with icon-only secondary actions and a wrapping status row.

Test plan

  • All existing unit tests updated to mock ws_command instead of _request
  • New test verifying HA-generated slug is used over caller's input_id
  • New test verifying WS protocol keys (id, type) are not overwritten by params
  • Delete tests cover WS list+delete two-step flow and not-found case
  • make ci-local passes (3322 tests, lint, mypy, bandit)
  • Manual verification: create a helper via proposal deploy and confirm it appears in HA

@dimakis dimakis force-pushed the fix/align-helper-params branch from eb78c84 to d401ed0 Compare March 9, 2026 22:56
@dimakis dimakis changed the title fix(helpers): align create_input_number params with HA field names fix(helpers): align helper params with HA and check creation success Mar 9, 2026
@github-actions github-actions bot added the size/m label Mar 9, 2026
@dimakis dimakis force-pushed the fix/align-helper-params branch from d401ed0 to 4467b40 Compare March 9, 2026 22:58
@dimakis dimakis changed the title fix(helpers): align helper params with HA and check creation success fix(helpers): align helper params with HA, check success, and add redeploy UI Mar 9, 2026
@dimakis dimakis force-pushed the fix/align-helper-params branch from 4467b40 to d1fc3c9 Compare March 9, 2026 23:02
@dimakis dimakis changed the title fix(helpers): align helper params with HA, check success, and add redeploy UI fix(helpers): align helper params, check success, and enable redeploy Mar 9, 2026
@dimakis dimakis force-pushed the fix/align-helper-params branch 2 times, most recently from 88d32a1 to 334e8eb Compare March 9, 2026 23:15
…ures

HA's REST config storage endpoints (/api/config/{domain}/config/{id})
return 404 for helper creation — the correct transport is the WebSocket
API ({domain}/create, {domain}/delete).  The base HTTP client silently
swallowed 404 responses, causing create_* methods to falsely report
success.

Additionally, passing id=input_id in WS params overwrote the protocol
message sequence ID (must be an integer), causing HA to reject with
"Message incorrectly formatted".  HA auto-generates the entity slug
from the name field.

Changes:
- Rewrite all 8 create_* methods in HelperMixin to use ws_command
- Rewrite delete_helper to WS list-then-delete using storage IDs
- Add _ws() convenience wrapper matching DashboardMixin pattern
- Strip WS protocol keys (id, type) from params in _execute safety net
- Use HA-returned slug from create response for entity_id
- Fix _deploy_helper to check result.success before marking deployed
- Allow DEPLOYED->DEPLOYED state transition for forced redeployment
- Add force flag to deploy API client and useDeployProposal hook
- Add Redeploy button with improved footer layout on proposal detail
- Rename min_value/max_value to min/max matching HA field names
- Update all unit tests to mock ws_command instead of _request

Made-with: Cursor
@dimakis dimakis force-pushed the fix/align-helper-params branch from 334e8eb to fc05b70 Compare March 9, 2026 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant