Operator in entity filter includes wrong entities

Hello, I’m trying to display in a card only the entities that are currently drawing power, but as you can see from the screenshot, this is not working. Where is the error? Thank you everyone.

Here’s the code:

type: entity-filter
entities:
  - entity: sensor.peanut3_electrical_measurement
    name: Entertainment center
  - entity: sensor.peanut2_electrical_measurement
    name: Fridge
  - entity: sensor.peanut1_electrical_measurement
    name: Dishwasher
  - entity: sensor.peanut4_electrical_measurement
    name: Kitchen appliance
  - entity: sensor.peanut5_electrical_measurement
state_filter:
  - operator: '!='
  - value: '0.0'
card:
  type: entities
  title: Currently Drawing Power
  show_state: false

You’re filtering entities whose value is not the string '0.0'. Try losing the quotes.

no change

how about

state_filter:
  - operator: '>'
  - value: 0.0

or

state_filter:
  - operator: '>'
  - value: 0.01

no improvement (the entertainment center is still drawing power but it doesn’t show)



Well that just seems broken. If no one else can work out what is wrong I suggest you open an issue here:

1 Like

for reference, here’s my current environment.

I just tried it and can confirm your observations. It’s completely busted.

1 Like

Everything is working fine. Your configuration is just incorrect for what you are trying to achieve.
Your state_filter section has two entries (two dashes): One that only specifies an operator and one that only specifies a value. As the docs state, having multiple filters is fine, but an entity will be shown as soon as one matches.

So your actual conditions are: Show entities if value is not equal to undefined/ blank string or if value is ‘0.0’.

What could be discussed is trying to provide better guidance to the user by enforcing the fact that we require a value element, since the docs state it is mandatory but the editor is not actually enforcing it.

1 Like

I’ve followed the documentation, wasn’t trying to get creative…
What would be the correct way considering that I want only the entities that are not reporting a 0.0 value to show up? This way it can be consulted by someone else in my same shoes.

For anyone curious, the solution was to remove one of the entries (the dash).
so the correct, working code now would be

type: entity-filter
state_filter:
  - value: '0.0'
    operator: '!='
entities:
  - entity: sensor.peanut3_electrical_measurement
    name: Entertainment center
  - entity: sensor.peanut2_electrical_measurement
    name: Fridge
  - entity: sensor.peanut1_electrical_measurement
    name: Dishwasher
  - entity: sensor.peanut4_electrical_measurement
    name: Kitchen appliance
  - entity: sensor.peanut5_electrical_measurement
    name: Microwave
card:
  type: entities
  title: Currently Drawing Power
  show_state: false

here’s the screenshot:

2 Likes

I figured out what’s going on here. The home assistant documentation has some bad examples displayed here:

state_filter:
  - operator: "!="
    value: home
  - operator: "!="
    value: work

This is incorrect. It should state:

state_filter:
  - value: home
    operator: "!="
  -  value: work
    operator: "!="

At least, that’s what happened to me just a moment ago when configuring a new card.

Lists are unordered. It makes no difference which one you put first. Your two examples result in exactly the same thing. Or they would if your indentation was correct.

You are entirely correct. That’s what I get when trying to configure things on a iPad…
My apologies.

Thank you for sharing this. If the device was previously turned on in the day before, the value would be > 0 right? How would we find out if the device is ‘Currently’ consuming power?
Please let me know how/if you figured that out.