battery-state-card: Entities are not showing when sort option is present in the config

Upgraded to latest version 3.1.1 and something broke, my card was showing only 2 entries. Reverting to 3.1.0 all works as expected.

Describe the bug

How to reproduce Upgrade to 3.1.1.

Expected behavior

YAML configuration type: custom:battery-state-card title: Battery levels (<70%) tap_action: more-info secondary_info: ‘{last_changed}’ colors: steps: - ‘#ff0000’ - ‘#ffff00’ - ‘#00ff00’ gradient: true sort: by: state filter: exclude: - name: state value: 70 operator: ‘>’ - name: entity_id value: sensor.front_door_battery - name: entity_id value: binary_sensor.living_room_motion_sensor_1_battery_low include: - name: attributes.device_class value: battery collapse: 6 entities:

  • entity: sensor.xxx_s_iphone_battery_level name: xxx’s phone

please paste here your card config


**Screenshots**
<!-- If applicable, add screenshots to help explain your problem. -->

**Version**
<!-- What is the version of the card? -->
<!-- If regression happened after updating Home assistant please add HA version as well. -->

About this issue

  • Original URL
  • State: closed
  • Created 6 months ago
  • Comments: 38 (13 by maintainers)

Most upvoted comments

Sort seems to be the issue here. Once I removed sort from mine everything showed up again.

I tried… sort: state

I even tried… sort: by: state

In both cases, none of the batteries will display. As soon as I remove sort everything appears again. So, I’m suspecting this is a code defect in the sort code.

Yep, I can confirm that removing sort fixes the issue. I’ll wait for a fix (the next release) before upgrading.

Sort seems to be the issue here. Once I removed sort from mine everything showed up again.

I tried… sort: state

I even tried… sort: by: state

In both cases, none of the batteries will display. As soon as I remove sort everything appears again. So, I’m suspecting this is a code defect in the sort code.

the same here.

remove

sort:
  by: state

for now solve problem, but list isnt sorted 📦 waiting for fix

Found the disable cache, let me try again

On Mon, 8 Jan 2024 at 20:39, Max Chodorowski @.***> wrote:

  1. Where do you get this log from? It doesn’t look like from the developer console in your browser. On the PC you can usually access your browser developer console by pressing F12 (then look for the console tab)
  2. Please make sure that the js file is refreshed in the browser Ctrl+F5. Disabling the browser cache should help as well image.png (view on web) https://github.com/maxwroc/battery-state-card/assets/8268674/1d0882f3-756b-4280-8f16-a9b3993238e0

— Reply to this email directly, view it on GitHub https://github.com/maxwroc/battery-state-card/issues/630#issuecomment-1881785602, or unsubscribe https://github.com/notifications/unsubscribe-auth/AONHCL4RAS5NVF4RXPCNVVDYNRKOHAVCNFSM6AAAAABBNUP2S2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBRG44DKNRQGI . You are receiving this because you authored the thread.Message ID: @.***>

Yes it helps a lot. I was suspecting that this might be the problem but I thought that the code cannot be in such state that this particular line breaks…

I’ll try to figure out how come this state of the card was possible.

Thanks!

I have the same problem. I have both entities and filter to add all the entities I want. Like this.

If I remove the entities part the sort function is working. If I remove the filter part , and only have the entities part, the sort function is also working. If both used together the sort function is not working, and nothing is shown.

entities:
  - entity: vacuum.audun
  - entity: sensor.audun_sin_iphone_battery_level_2
    charging_state:
      entity_id: sensor.audun_sin_iphone_battery_state_2
      state: Charging
  - entity: sensor.edwin_sin_iphone_battery_level
    charging_state:
      entity_id: sensor.edwin_sin_iphone_battery_state
      state: Charging
filter:
  include:
    - name: entity_id
      value: sensor.sensor*_battery*
      state: charging
    - name: entity_id
      value: sensor.*_battery*
      state: charging
    - name: entity_id
      value: sensor.*_batteri*
      state: charging
    - name: entity_id
      value: sensor.battery
      state: charging
  exclude:
    - name: entity_id
      value: sensor.*iphone_battery_state*
    - name: entity_id
      value: sensor.*mobil_battery_state*
    - name: entity_id
      value: sensor.ringeklokke_battery_temperature

Hi Max, It’s GB, I’m in the UK so it’s 98.5. Let me try using default_state_formatting: false and I’ll come back shortly.