battery-state-card icon indicating copy to clipboard operation
battery-state-card copied to clipboard

Battery charging status not working

Open rcdailey opened this issue 2 years ago • 3 comments

Describe what is wrong

I do not see a charging indicator on my card.

YAML configuration

  - type: custom:battery-state-card
    title: Battery Levels
    filter:
      include:
        - name: entity_id
          value: "*battery_level*"
    tap_action:
      action: more-info
    charging_state:
      attribute: # whenever one of below attributes is matching
        - name: "Battery State"
          value: "Charging"
        - name: "is_charging"
          value: true
      state: # or if entity state matches one of the following
        - "charging"
        - "Charging"
    color_gradient:
      - "#ff0000" # red
      - "#ffff00" # yellow
      - "#00ff00" # green

Screenshot

Entities (developer tools): image

How the card looks: image

Version

2.1.0

rcdailey avatar Apr 16 '22 23:04 rcdailey

It looks like it is a bug. When you have the charging attribute specified it doesn't look at the state. I will fix it

maxwroc avatar Apr 22 '22 12:04 maxwroc

Thanks. Worth noting I took that yaml from your examples.

rcdailey avatar Apr 22 '22 14:04 rcdailey

Hello. This doesn't look like it's been fixed. I am using v2.1.1 and I tried all possible combinations in then YAML code. The charging phone does not get the secondary info based on it's state.

MihaiKrieger avatar Aug 14 '22 17:08 MihaiKrieger

It was a while since this issue was reported... TBH I don't know why I haven't noticed this back then when I looked at this issue for the first time.

The reason why this doesn't work for you is that in your case the charging state is in a separate entity. To get it you need to specify that other entity name (it doesn't happen automatically)

https://github.com/maxwroc/battery-state-card#charging-state-object

In the charging_state section you need to add the entity_id

    charging_state:
      entity_id: sensor.pixel_6_pro_battery_state
      state: 
        - "charging"

And you don't need the rest of the junk in this section.

Copy-pasting stuff without understanding and trying to adjust it for your case is not always a good idea. It's not possible to provide examples which would work for all of the people.

Hope this helped and your problem is solved.

maxwroc avatar Oct 21 '23 22:10 maxwroc