Skip to content

Add device sorting options - #74

Open
AndreRozendaal wants to merge 1 commit into
pacemaker82:mainfrom
AndreRozendaal:main
Open

Add device sorting options#74
AndreRozendaal wants to merge 1 commit into
pacemaker82:mainfrom
AndreRozendaal:main

Conversation

@AndreRozendaal

Copy link
Copy Markdown

Summary

I added an optional device_sort setting for the devices shown in the Compact Power Card.

I wanted to be able to show the highest power consumers on the left side of the card, so they are easier to spot at a glance. While adding that, I also added a few other sorting options that may be useful for other users.

The new setting can order visible devices from left to right by:

  • power descending
  • power ascending
  • name descending
  • name ascending

The default remains none, so existing card behavior should stay unchanged unless sorting is enabled.

Why

When multiple devices are shown, it can be useful to keep them in a predictable order. For example, device_sort: power_desc puts the highest consuming devices first, which makes it easier to quickly see what is using the most power.

Notes

  • Sorting is applied only to visible devices.
  • Device names fall back to the Home Assistant friendly_name when no explicit device name is configured.
  • Power sorting uses numeric values in W, kW, or mW.
  • The visual placement is sorted left-to-right, so the order shown on the card matches the configured sort.
  • The default none option keeps the current behavior.

Testing

I tested this locally in Home Assistant with:

  • device_sort: power_desc
  • device_sort: power_asc
  • device_sort: name_desc
  • device_sort: name_asc

I also validated the JavaScript syntax with:

node --check compact-power-card.js

I don't can check all the cases. Maybe you have some test scripts for that. Or now the impact of the change.

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.

1 participant