maxwroc / battery-state-card

Battery state card for Home Assistant
MIT License
848 stars 38 forks source link

Filter exclude on attribute stopped working in 3.2.0 #694

Closed andrew-codechimp closed 6 months ago

andrew-codechimp commented 7 months ago

Describe the bug I have been using the exclude filter on a boolean attribute but with 3.2.0 this has stopped working, ignoring the filter and listing everything.

How to reproduce Add a filter on an attribute, I've flipped it to include or exclude and it doesn't seem to be looking at attributes any more.

Expected behaviour Only show battery_plus entities that have an attribute of battery_low set to true.

YAML configuration

type: custom:battery-state-card
title: Battery Warnings
round: 0
secondary_info: '{attributes.battery_type_and_quantity}'
filter:
  include:
    - name: entity_id
      value: '*_battery_plus'
  exclude:
    - name: attributes.battery_low
      value: false
bulk_rename:
  - from: Battery+
sort:
  - state

Entity debug data

Dev console errors

Screenshots

Version 3.2.0

maxwroc commented 7 months ago

Have you upgraded from v3.1.6 or an earlier version?

I kind of have a repro but didn't have time to check the code carefully so I don't know what exactly has happened.

It looks like it doesn't work as the attribute is converted at some point to string. And when the boolean false is being compared with string "false" it doesn't match.

Adding quotes in your config can mitigate the issue for now

andrew-codechimp commented 7 months ago

Yes I upgraded from 3.1.6 where it was working. Just checked my side on Battery Notes and it's setting that attribute as a bool. I can work with the workaround though 😄

maxwroc commented 6 months ago

Will be fixed in the next release