Skip to content

Fix negative currency display on sensor card#30359

Merged
bramkragten merged 3 commits intodevfrom
fix-30335
Mar 27, 2026
Merged

Fix negative currency display on sensor card#30359
bramkragten merged 3 commits intodevfrom
fix-30335

Conversation

@MindFreeze
Copy link
Copy Markdown
Member

@MindFreeze MindFreeze commented Mar 26, 2026

Proposed change

Fix negative currency values not displaying properly on entity/sensor cards (e.g., showing just - instead of -$12.00).

Intl.NumberFormat.formatToParts() emits minusSign/plusSign as separate parts that weren't mapped in the type conversion, so they were silently dropped. This PR:

  1. Maps minusSign/plusSign as "value" parts in computeStateDisplay, preserving native Intl formatting order in the joined output.
  2. Fixes entity cards and ha-attribute-value to collect all "value" parts (not just the first), so the sign and digits are combined for display.
  3. Uses the last value part index for unit ordering, so the currency symbol position is correct.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

To help with the load of incoming pull requests:

@MindFreeze MindFreeze marked this pull request as ready for review March 26, 2026 15:15
@MindFreeze MindFreeze marked this pull request as draft March 27, 2026 08:50
Collect all value parts when extracting the display value, and use the
last value part index for unit ordering, so negative currency like
-$12.00 renders correctly on entity cards and attribute values.
@MindFreeze MindFreeze added this to the 2026.4 milestone Mar 27, 2026
@MindFreeze MindFreeze marked this pull request as ready for review March 27, 2026 10:15
@bramkragten bramkragten merged commit d8a3939 into dev Mar 27, 2026
12 checks passed
@bramkragten bramkragten deleted the fix-30335 branch March 27, 2026 11:30
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.

Issue with displaying negative currency values in the sensor card

2 participants