Sort battery-state-card

I want to sort battery capacity in asc order and have following code but it doesn’t work.

type: custom:battery-state-card
title: Batterikapacitet - Aquara  & Philips HUE

filter:
  include:
    - name: "*battery*"
    
sort_by: state
method: asc

color_thresholds:
  - color: red
    value: 10
  - color: "#ff7f7f"
    value: 20
  - color: "#eeee00"
    value: 40
  - color: green
    value: 100
    
entities:
  - entity: sensor.temperature_90_battery
    name: Aquara Ute
  - entity: sensor.temperature_68_battery
    name: Aquara Salong
  - entity: sensor.temperature_74_battery
    name: Aquara Raivo
  - entity: sensor.temperature_71_battery
    name: Aquara Anne
  - entity: sensor.sovrum_battery_level
    name: Aquara Sovrum
  - entity: sensor.switch_ytterdorren_battery_level
    name: HUE Ytterdörr (sw)
  - entity: sensor.switch_entre_battery_level
    name: HUE Entré (sw)
  - entity: sensor.hue_smart_button_1_batteri
    name: HUE Entré (Smart Button)
  - entity: sensor.hue_dimmer_switch_2_batteri
    name: HUE Kök (sw)
  - entity: sensor.switch_diskbank_battery_level
    name: HUE Diskbänk (sw)
  - entity: sensor.switch_hall_arbetsrum_battery_level
    name: HUE Hall Arbetsrum (sw)
  - entity: sensor.hue_dimmer_switch_1_batteri
    name: HUE Badrum (sw)
  - entity: sensor.hue_motion_sensor_1_batteri
    name: HUE Svarta Hyllan (ms)
  - entity: sensor.sovrum_sensor_anne_battery
    name: HUE Sovrum Säng Anne (ms)
  - entity: sensor.sovrum_sensor_raivo_battery
    name: HUE Sovrum Säng Raivo (ms)
  - entity: sensor.hue_smart_button_2_batteri
    name: HUE Sovrum (Smart Button)
  - entity: sensor.humidity_50_battery
    name: Aquara Dator

I have “sort_by_level: asc” and it works, but as i read on github this has changed:

  • Sorting setting has changed. Now it is called sort (previously “sort_by_level”) and it can define multiple levels of sorting.

But definitely not “sort_by: state” . One example on github has:

sort:
  by: "state"

using this: GitHub - thomasloven/lovelace-auto-entities: 🔹Automatically populate the entities-list of lovelace cards

and the this as a card:

type: custom:auto-entities
show_empty: true
card:
  type: entities
  show_header_toggle: false
  state_color: true
filter:
  include:
    - options: {}
      entity_id: sensor.*battery_plus*
  exclude:
    - options: {}
      entity_id: sensor*body*
sort:
  method: state
  numeric: true

i get this:

without even writing all the battery sensors out piece for piece :wink:

Thanks … it works OK now

Noting that also the battery state card (if you really want to use this) has extended select capabilities …e.g. mine:

type: custom:battery-state-card
title: Filtered battery list
sort:
  by: state
  desc: false
tap_action: more-info
filter:
  include:
    - name: entity_id
      value: "*_battery_low"
    - name: entity_id
      value: "*_battery_level"
    - name: attributes.device_class
      value: battery
  exclude:
    - name: state
      value: 100
      operator: ">"
    - name: state
      value: Unknown
    - name: state
      value: Unavailable
    - name: state
      value: None

And donot laugh on the > 100 … I really have one that is odd like that :slight_smile:

there always are more ways to one destination :wink:

1 Like