🔋 Lovelace: Battery state card

I decided to try this and installed it from hacs. But after it is installed, hacs says it cannot be loaded. And Lovelace says battery state card (type: ‘custom:battery-state-card’) is not found (of course, as hacs says it cannot be loaded)

Are there any dependencies to this card?

Mine does the same, but I don’t think it does it on all the sensors, just my Hue ones - I will check later and grab a screenshot if I don’t forget!

What exactly do you mean that HACS syst it cannot be loaded? If you have lovelace yaml mode you need to add reference to the js file manually otherwise card code won’t be loaded and HACS will mark the card as red:
image

Card has dependency on Lit-Element but it get’s it from the HA native cards. This way card code is much smaller and there is no need of making external request to get it from the internet. So the answer is no - it doesn’t have any dependencies which can be the reason of your problem.

Ok so we have two people seeing the below issue. Anyone else?
image

But still I have no idea what might be the reason of this problem. Same value is being processed to set the color and the icon.

Question mark icon is the default initial icon or when the state has a string value - not number. Maybe for some reason the icon is not updating when it should but looking at the logic in the code it cannot happen.

If level is not a number then the color should be the default one - there is the same logic in both cases.

One question: are you able to repro it as well in UI editor?

Here everything is fine, only the black ones have a question mark inside:

If this is the UI editor, keep in mind anytime you load HA in a browser or mobile as guess basically a browser app, it will show the question marks. Refreshing they don’t so even though the main screen shows it loading the editor probably wouldn’t as that’s kind of a refresh. What I get when I first load is fine, then if I try to add another light or in this case the same light I get:

Then like 10 seconds later it switches to what it should.

Only one that doesn’t seem to do that is the kitchen flood sensor:

image

On you last screen it looks like the color of the SiPhone is not updated as well. Please open dev tools in the browser (F12) and check the Console tab if there are any errors related to the card. In case of the error the update process can brake and the result may be random (maybe that is the case here).

Probably a bug in HA because I noticed it was saying it could not load ‘battery state car’ when I tried to add the card in lovelace. So I added one letter behind type: ‘custom:battery-state-card’ and removed the extra letter again and then it loaded.

This is what’s in the Console tab:

I assume you have checked it when you were getting the wrong icons in the UI, right? If so I really cant tell what might be wrong

Yes it’s usually always that way as evertime I go into HA it’s the first time so rarely refresh the page to fix it. Anyway, thanks, based on running out of ideas guess I can try another card or something. Not a super big deal but family is asking why the question marks when they look at the page so not idea.

You can give it a try with this one Lovelace Battery Entity Card. It doesn’t have too many settings but it displays the battery states in similar way. If you try it out please let me know if it worked.

FYI: I have installed 0.113.3 and I have a repro in one case. This means that probably I should be able to fix it. It might be hard though - as you were saying it doesn’t repro after refresh.

In HA v0.113 they have updated MDI icons - maybe something is messed up. I’m pretty sure I haven’s seen such problem before. Neither anyone was reporting it.

@jriker1, @davefi Have you used this card before HA v0.113.X?

Yep, I started using it around 6th June, so that would have been around release 0.110 I believe. I’ve had the problem since I first installed it, so its not new to 0.113.

I also check (just forgot to post!) and mine does it on 2 out of 4 sensors. They are all Hue, 2 are Motion Sensors, 2 are Remotes. I have the ? on one of each, so it doesn’t seem related to the device type either!

image

It is only doing it on the ones reading 100% though, I have never seen it on the other two sensors.

I also tried the live view, and that works fine - comes up immediately with all the correct icons, and no ? shown:

1 Like

Hey all,
sorry, not sure what im doing wrong here.

i want to show the secondary info as the charging state.

AS you can see the state is currently “not charging” but its showing as "charging

type: 'custom:battery-state-card'
name: Secondary info
secondary_info: last_updated
entities:
  - entity: sensor.iphone_battery_level
    secondary_info: Charging # only appears when charging is detected
    charging_state:
      attribute:
        name: "Battery State"
        value: 'Charging'

It should be lowercase

secondary_info: charging
1 Like

:man_facepalming:

sorry! that work, thanks

Same problem… i have ? in each sensor (100% and 95%)

I really would like to help you guys and fix this issue but I cannot find any consistent repro. In my case it happened once on my dektop (Win + Chrome) and once on my iPad. Switching to different HA tab and back or refreshing the page fixes the issue and I cannot repro it any more (even if I re-launch the browser).
I have tried clearing web app storage in browser (in incognito mode) but it didn’t help.

I need to find the way to consistently repro this issue :frowning_face:

What automation are you guys using to get a notification if a battery is say at 10% showing the one that is 10% ?