Skip to content

fix(panel): coerce numeric settings via type attribute, not property#356

Merged
tempus2016 merged 1 commit into
mainfrom
fix/panel-settings-numeric-types
May 11, 2026
Merged

fix(panel): coerce numeric settings via type attribute, not property#356
tempus2016 merged 1 commit into
mainfrom
fix/panel-settings-numeric-types

Conversation

@tempus2016

Copy link
Copy Markdown
Owner

Summary

Fixes #350 — saving Settings on the TaskMate panel returns "Message malformé" / "expected int for dictionary value" for history_days, perfect_week_bonus, and calendar_projection_days.

Root cause

_doSaveSettings() detected number inputs with el.type === "number". ha-textfield does not reliably reflect the HTML type="number" attribute onto its .type property, so the branch was skipped and el.value (a raw string like "14") was sent. The WS schema uses vol.All(int, ...) which rejects strings — hence the malformed-message toast surfaced by HA's voluptuous validator.

Fix

Read the declared type via el.getAttribute("type") first, falling back to el.type — this works for both native <input> and HA's <ha-textfield> wrapper. Switches are still detected by tagName === "HA-SWITCH".

Test plan

  • Open TaskMate panel → Settings
  • Toggle Confirm before skipping, change any numeric field, hit Save settings
  • No error toast; values persist after reload

ha-textfield doesn't reliably reflect type="number" onto el.type, so the
"number" branch in _doSaveSettings was being skipped and values were sent
to the WS schema as strings. The backend uses vol.All(int, ...) which
rejects strings, causing 'expected int for dictionary value' errors when
saving Settings (history_days, perfect_week_bonus, calendar_projection_days).

Read the type via getAttribute() with el.type as a fallback so both native
inputs and ha-textfield wrappers route correctly.

Fixes #350
@tempus2016 tempus2016 merged commit a981201 into main May 11, 2026
1 check passed
@tempus2016 tempus2016 deleted the fix/panel-settings-numeric-types branch May 11, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Config flow error when enabling 'Skip confirmation' for assignee skipping

1 participant