Thansk Maks, looks like itās working. Will try a bit more but after I cleared my browser cache it seemed good. Now to find my iPhone and see if it still happens.
Nice! All seems to be working here as intended now, thank you for managing to track it down
just wanted to show my config for " Low battery Card "
type: 'custom:battery-state-card'
title: Low Battery
show_empty: false
sort_by_level: asc
entities: null
filter:
include:
- name: entity_id
value: '*_battery'
- name: attributes.device_class
value: battery
exclude:
- name: entity_id
value: '*.state'
- name: state
value: Good
- name: state
value: 25
operator: '>'
bulk_rename:
- from: Battery
Hide card if empty.
Sort Ascending (lowest battery top)
Include / list all devices with battery in its āentity idā or ādevice classā
Exclude any ābattery stateā entities, and Good Health states, ( āGoodā battery health, charging/discharging state)
Exclude any battery level above 25% remaining.
Rename all devices to remove the word ābatteryā
Is it possible to use state_map with a filter?
Iām trying to do a wildcard to include all my nest protects battery health sensors, then use a state map to convert the āokā and āreplaceā states to 100 and 25 respectively. However, this isnāt working:
filter:
include:
- name: entity_id
value: '*_nest_protect_battery_health'
state_map:
- from: Ok
to: 100
- from: Replace
to: 25
This unfortunately isnāt applying the state map and instead I get this:
State map belongs to the ācommon settingsā so it can be used in entity or card (to be applied for all entities). You cannot specify state_map for filter. I think in your case the card-level settings will work as expected
type: 'cusom:battery-state-card'
state_map:
- from: Ok
to: 100
- from: Replace
to: 25
filter:
include:
- name: entity_id
value: '*_nest_protect_battery_health'
How do you do a bulk rename with a case insensitive search? Iāve tried trailing the regex with i
but it isnāt working for me.
bulk_rename:
- from: "/(battery health)/i"
to: ''
I got it to work with this instead but the trailing āiā shouldāve worked and is more flexible?
bulk_rename:
- from: '/([b|B]attery [h|H]ealth)/'
to: ''
Separately, I wonder if by default, it should be case insensitive?
Oh yeah that is true - I have a silly way of detecting whether it is a regex pattern or not (regexp flags wonāt work). I will fix it - I have created a task to track it https://github.com/maxwroc/battery-state-card/issues/159
Thanks for reporting it!
What is the right way to use this to show a card that only has battery levels less than some percentage (e.g. 30)? When I try to include entities based on state filter, using <30, itās going across all entities and not just battery level sensors. So Iām trying to figure out how to combine both a entity ID filter then apply a state level filter.
Is there a way to do 2 levels of sorting? By battery level, and by entity name?
E.g. I have sorting by battery level right now ascending, but look at the sort of the entity names:
Furthermore, is there a way to sort by entity name at all when using wildcard includes? (regardless of battery level)
hereās my card right now:
type: 'custom:battery-state-card'
title: Low Batteries
tap_action: more-info
bulk_rename:
- from: Battery Level
to: ''
filter:
include:
- name: entity_id
value: '*_battery_level'
exclude:
- name: entity_id
value: '*_battery_state'
- name: entity_id
value: '*_iphone*'
- name: entity_id
value: '*_mac_internal*'
which generates the following:
FYI the bug with regexp filters not respecting flags is fixed now in v1.6.0
Is there a way to do 2 levels of sorting? By battery level, and by entity name?
No it is not possible now, sorry. If you want to have such option please create issue on github - maybe Iāll add it next time (especially when more people would be interested in that kind of functionality).
Iām thinking nowā¦ maybe it make sense to add sorting by name (when val is the same) as a default behavior whenever user used filters?
FYI If you have tried 1.6.0 youāve probably realized that the regex bug is still there. I have released accidentally the previous version of the card code. It is fixed now (added new release 1.6.1 with correct code )
That behavior you describe makes sense to me. I canāt imagine why someone would want it not sorted by name after the primary sort
Thanks!!
You sure this is fixed? This still isnāt working for me
bulk_rename:
- from: '/(battery health)/i'
to:
Bulk rename doesnāt support regex. You were reporting problem with filter and this one is fixed (let me know if that is not the case).
I have created two issues to cover the stuff you were suggesting:
Oh sorry I was confused as I mentioned the bulk rename issue earlier: š Lovelace: Battery state card - #92 by tmchow
In re reading the thread I see where it was a bit confusing in the sequence of convos. No worries.
Dear maxwroc,
thank you very much for this wonderful card!
I have been using it for quite a while now without any problems. Just recently, after the upgrade to the latest version, the secondary_info disappeared. So I downgraded to the previous version, but the secondary_info is still missing.
Where there any major changes or do I miss something really important?
Thanks in advance and kind regards!
Iām glad to hear that you like it. Please give me some more details, like exact version of the card and HA, additionally paste your card config.
There was an issue with secondary info which was fixed in 1.6.2 (released yesterday). The problem was only with showing last-changed/updated time.
The exact reason of missing text was that translations have changed in recent HA releases and I had to switch to the new ones. So the fix for the new HA probably broke the older one (let me know if that is your case).
Dear maxwroc,
thank you very much for your reply.
A couple of minutes ago I shut down my Home Assistant virtual machine in order to make a backup. Once finished, I restarted Home Assistant and now the secondary_info is shown again. Whatās really weird is that a ānormalā restart within Home Assistant did not fix the problem because I have tried that several times yesterday. However, a complete reboot seems like to have the problem fixed.
Kind regards!
Hi @maxwroc,
Congratulations on your great work! Iāve been using your card for several months already and Iām happy camper! I recently needed to switch the configuration of my RFXTRX hub and now I keep detecting rfxtrx devices constantly. Guess what? those new devices make a mess of my card and I frequently find things like this:
As per your documentation, I believe I canāt filter out these results
Note: Include filters should rely on static entity properties. E.g. you should not add include filter which checks the state property. Include filters are processed only once - when page is loaded (to minimize perf impact).
Any chance I could remove the Unavailable devices?
thanks
Hi,
Is there a way to round the battery level ?