maxwroc / battery-state-card

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

Entity already included but nowhere on card even with debug #706

Closed heagan01 closed 6 months ago

heagan01 commented 6 months ago

Describe what is wrong So I want to add my laptop's battery percentage (from Hass.Agent) to this card, it has an entity named

sensor.desktop_2gbc68r_desktop_2gbc68r_battery_charge_remaining_percentage

I added it in include with the entity (see YAML configuration below)

YAML configuration


type: custom:battery-state-card
secondary_info: '{last_changed}'
filter:
  include:
    - name: attributes.device_class
      value: battery
    - name: entity.id
      entity: >-
        sensor.desktop_2gbc68r_desktop_2gbc68r_battery_charge_remaining_percentage
  exclude:
    - name: entity_id
      value: binary_sensor.*
sort:
  by: state
collapse: 8
bulk_rename:
  - from: ' Battery'
  - from: ' level'
colors:
  steps:
    - '#ff0000'
    - '#ffff00'
    - '#00ff00'
  gradient: true
debug: true

Screenshot

image debug only shows these two

Version

3.2.1

maxwroc commented 6 months ago

There are few issues in your config.

In the docs you can find that filter object has two fields "name" and "value" (there is an "operator" one too but not relevant here).

The "name" should provide the name of the entity property while the "value" the value against the match should happen.

  1. When you expand the debug data of one of the entities which show up you will see that there is no property "entity" which has the property "id". This means that your "entity.id" cannot be found so the filter won't work. What you should see is that there is a property which contains the entity id but it is called "entity_id" and this is what you should put in the name field image
  2. The "value" setting of filter object is missing, instead you have added "entity" which is not a valid filter field/setting

The alternative simplified solution is to add a fixed list of entities by adding "entities" setting in the card config e.g.

entities:
  - sensor.desktop_2gbc68r_desktop_2gbc68r_battery_charge_remaining_percentage

This will work fine with the filters - you basically tell the card to include the entities from the above list and in addition filters are being applied

heagan01 commented 6 months ago

image Thanks! It totally works now