Hi maxwroc, thank you so much for this wonderfull card.
This is exaclty the way i want my batteries to be showed, i’m trying to include in the less than 30% state batteries section that are not visible for the past 7 days, is it possible?
Hi maxwroc, thank you so much for this wonderfull card.
This is exaclty the way i want my batteries to be showed, i’m trying to include in the less than 30% state batteries section that are not visible for the past 7 days, is it possible?
Hello. Is there any way (other than using pre-defined groups, as the idea is precisely not to have to specify a fixed list of entities) of, after applying the first filter in a macro way custom:battery-state-card, reapplying a second filter for each collapse, filtering by name of the entity. I know the code below doesn’t work, but I added it just to illustrate what i need. I tried to do it with a template but I couldn’t.
- type: custom:battery-state-card
title: "All Battery"
filter:
include:
- name: "attributes.device_class"
value: "battery"
collapse:
- name: 'Door Sensors (Qt: {count})'
filter:
include:
- name: entity_id
value: '*_door_*'
- name: 'Temperature sensors (Qt: {count})'
filter:
include:
- name: entity_id
value: '*_temp_*'
- name: 'Presence sensors (Qt: {count})'
filter:
include:
- name: entity_id
value: '*_presence_*'
Is it possible to change the background of this card? Can’t seem to figure it out.
You can change the line-height and I would assume you will need to reduce the line-height of the secondary info line. I haven’t figured it out myself but I would also like to do this so will report back if I figure it out
That would be great! Thanks!
Hi maxwroc, Is it possible to feed the min/max values in the Group Object sections by Helpers ?
Many Thanks,
|min|number||v1.4.0|Minimal battery level. Batteries below that level won’t be assigned to this group.|
|max|number||v1.4.0|Maximal battery level. Batteries above that level won’t be assigned to this group.|
thank you for sharing
Unfortunately group name and secondary_info support now only fixed set of keywords. But it make sense to change the logic and use “KString” which would mean you could use any value, from any other entity. I think this is something what you’re looking for, right?
You can add an issue on github with such proposal
First, thank you for this card. Brand new user. Wondering why I’m getting duplicates with the + sign. If it matters, I’m also using the Battery Notes custom integration.
Hello,
I am really liking this card. i currently have one card for all my batteries and one for our door sensors. I am trying to have the collapse field change based on the number of doors open but i keep getting this error:
Ive tried a couuple different versions of the code and i keep getting this error.
Hello all,
is there a way to place entities with ‘unknown’ state at the end of the list instead of the beginning?
Thank you
Not sure what you mean. Did you see my example from above? 🔋 Lovelace: Battery state card - #280 by ThomDietrich
Does anyone know how to get the Secondary Info to be two lines? I can’t seem to figure out how to put a line break in. I’d prefer to have the battery type below the title but for now I’ve settled on adding it next to the name. Here is a code snippet:
type: custom:auto-entities
card:
type: custom:battery-state-card
gradient: true
collapse:
- name: Honeycomb Blinds (min {min}%, {count})
icon: mdi:blinds
group_id: sensor.non_tilt_blind_batteries
- name: Tilt Blinds (min {min}%, {count})
icon: mdi:blinds-horizontal
group_id: sensor.tilt_blind_batteries
filter:
include:
- integration: battery_notes
attributes:
device_class: battery
entity_id: "*blind*"
options:
name: >-
{attributes.friendly_name|replace(Battery+, (Type:)}
{attributes.battery_type_and_quantity})
secondary_info: "Last charged: {attributes.battery_last_replaced|reltime()}"
exclude:
- entity_id: "*_low*"
- entity_id: "*remote*"
show_empty: true
sort:
method: state
reverse: false
numeric: true
I ended up making my own instead. I have two cards setup, one is in a popup that shows all batteries, the other is anything under 35% as shown below:
type: markdown
title: Low Battery Devices (<35%)
content: >
{% set ignore_list = ['sensor.david_s_iphone_battery_level',
'sensor.michelles_iphone_battery_level',
'sensor.david_s_iphone_remote_battery_level'] %}
{% set batteries = states.sensor
| selectattr('attributes.device_class', 'defined')
| selectattr('attributes.device_class', 'eq', 'battery')
| rejectattr('entity_id', 'in', ignore_list)
| rejectattr('state', 'in', ['unknown', 'unavailable'])
| selectattr('state', 'le', '35')
| sort(attribute='state') %}
{% for battery in batteries %}
<span style="display: inline-block; margin-bottom: 5px;">
<ha-icon icon="mdi:battery-{{ (states[battery.entity_id].state | int / 10) | int * 10 }}" style="color:
{% if states[battery.entity_id].state | int < 10 %}red
{% elif states[battery.entity_id].state | int < 20 %}orange
{% elif states[battery.entity_id].state | int < 50 %}yellow
{% else %}green{% endif %};"></ha-icon>
{{ states[battery.entity_id].name }}: {{ states[battery.entity_id].state }}%
</span><br>
{% endfor %}
theme: Mytheme
Hello, congrats and thank you very much for this very useful card!
I’m trying to exclude devices that are charging. Is there a way to use the charging attribute/state to filter out some entities? Thanks!
Hi @biva ,
I am definitely not a pro. But I would go to “Developer tools” → state and filter entity for “charg”. I saw there entities which look like
type: custom:battery-state-card
secondary_info: "{last_changed}"
filter:
include:
- name: attributes.device_class
value: battery
exclude:
- name: entity_id
value: binary_sensor.*
I hope this helpled a little.
Juergen
Hi,
I have some Lorawan Sensors with very long battery live, and they only have battery status 0, 1, 2, 3. So my ideas was to multiply this value by 33, to get 0, 33, 66, 99 which would drop into more useful values but I do not understand how to use the multiply.
type: custom:battery-state-card
secondary_info: "{last_changed}"
filter:
include:
- name: entity_id
value: sensor.dragino*bat*
options:
name: "{state|multiply(33)}"
sort:
by: state
collapse: 8
bulk_rename:
- from: " Battery"
- from: " level"
colors:
steps:
- value: 0
color: "#ff0000"
- value: 1
color: "#ffff00"
- value: 2
color: "#00ff00"
gradient: true
leads to
The values of the sensory are like e.g.
sensor.dragino_275a08_018905e3_bat_stat_2
can anyone enlighten me?
Many thanks
Juergen
HI,
this:
type: custom:battery-state-card
secondary_info: "{last_changed}"
multiplier: 33
entities:
- entity: sensor.dragino_275a08_018905e3_bat_stat_2
name: Liebherr Fach 4
multiplier: 33
- entity: sensor.dragino_275a08_018905e4_bat_stat
name: Liebherr Fach 2
multiplier: 33
- entity: sensor.dragino_275a08_018905e6_bat_stat_3
name: Garage Dragino
multiplier: 33
- entity: sensor.dragino_275a08_0189ee98_bat_stat_4
name: Hauswirtschaftsraum Dragino
multiplier: 33
sort:
by: state
colors:
steps:
- value: 0
color: "#ff0000"
- value: 1
color: "#ffff00"
- value: 2
color: "#00ff00"
gradient: true
works as I hoped. Is it possible, that the multiplier only works on single entities? Which is not a real problem, as I only have thos “special” four, but if there is an easier way to use multiplier on more it would be great.
thanks
Juergen
Couldn’t get the ha-icon to change colour, so added in ha-alert’s instead and added in condition to only show the card when >1 is below my threshold.
type: conditional
conditions:
- entity: sensor.low_battery_count
state_not: "0"
card:
type: custom:vertical-stack-in-card
cards:
- type: markdown
content: |
## Low Battery Alerts
- type: markdown
title: null
content: |
{%- set friendly_names = {
"sensor.XX_battery_level": "XX Phone",
"sensor.iXX_watch_battery_level": "XX Watch",
"sensor.XX_battery_level": "Kiosk Battery",
"sensor.iXXmacbook_pro_internal_battery_level": "MacBook",
"sensor.XXX_iphone_2_battery_level": "XX Phone"
} -%}
{%- set all_batteries = states.sensor
| selectattr('attributes.device_class', 'defined')
| selectattr('attributes.device_class', 'eq', 'battery')
| sort(attribute='state', reverse=False) -%}
{%- for battery in all_batteries -%}
{%- set raw_state = battery.state -%}
{%- set clean_state = raw_state | trim -%}
{%- set state_int = clean_state | int(default=None) -%}
{%- if state_int is not none and state_int <= 20 %}
{%- set state_int = battery.state | int %}
{%- if state_int <= 5 %}
<ha-alert alert-type="error" style="display: flex; align-items: center;">
<ha-icon
icon="mdi:battery-{{ (state_int / 10) | int * 10 }}"
style="margin-right: 8px;">
</ha-icon>
{{ friendly_names.get(battery.entity_id, battery.entity_id) }}: {{ state_int }}%
</ha-alert>
{%- elif state_int <= 13 %}
<ha-alert alert-type="warning" style="display: flex; align-items: center;">
<ha-icon
icon="mdi:battery-{{ (state_int / 10) | int * 10 }}"
style="margin-right: 8px;">
</ha-icon>
{{ friendly_names.get(battery.entity_id, battery.entity_id) }}: {{ state_int }}%
</ha-alert>
{%- elif state_int <= 20 %}
<ha-alert alert-type="info" style="display: flex; align-items: center;">
<ha-icon
icon="mdi:battery-{{ (state_int / 10) | int * 10 }}"
style="margin-right: 8px;">
</ha-icon>
{{ friendly_names.get(battery.entity_id, battery.entity_id) }}: {{ state_int }}%
</ha-alert>
{%- endif %}
{%- endif %}
{%- endfor %}
I did this:
card_mod:
style: |
ha-card .entity-spacing {
margin: -10px 0px;
}