fix(panel): coerce numeric settings via type attribute, not property#356
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #350 — saving Settings on the TaskMate panel returns "Message malformé" / "expected int for dictionary value" for
history_days,perfect_week_bonus, andcalendar_projection_days.Root cause
_doSaveSettings()detected number inputs withel.type === "number".ha-textfielddoes not reliably reflect the HTMLtype="number"attribute onto its.typeproperty, so the branch was skipped andel.value(a raw string like"14") was sent. The WS schema usesvol.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 toel.type— this works for both native<input>and HA's<ha-textfield>wrapper. Switches are still detected bytagName === "HA-SWITCH".Test plan