fft2411
(Juergen Egeling)
December 4, 2024, 9:53am
307
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
fft2411
(Juergen Egeling)
December 5, 2024, 2:43pm
308
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
ID_Ant
December 18, 2024, 7:12pm
309
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 %}
samoswall
(Samoswall)
December 20, 2024, 10:58pm
310
I did this:
card_mod:
style: |
ha-card .entity-spacing {
margin: -10px 0px;
}
bemo47
(Bernard Morgan)
January 3, 2025, 3:59pm
311
is there a way to get the last known status or value of an entity which is offline ?
peterwup
(Peterwup)
January 4, 2025, 8:52pm
313
Is there a possibility to show the replace timestamp with a relative time and in a second step
to add a color which depends on the years which are ago since the last battery replacement.
0-1 year green
1-2 years yellow âŚ
I managed to get the list, but I have no idea how to show a relaitive time.
type: custom:battery-state-card
title: Replaced at
debug: ftrue
colors:
steps:
- â#ff0000 â
- â#ffff00 â
- â#00ff00 â
gradient: true
filter:
include:
- name: entity_id
value: â*_battery_last_replacedâ
options: null
exclude:
- name: state
value: Unknown
bulk_rename:
from: Batterie ersetzt
Changed:
state|reltime(): null
sort:
by: name
desc: true
petterca
(Petterca)
January 6, 2025, 11:23am
314
Iâm currently using the battery-state-card to visualize a range of temperatures in my Home Assistant setup. While Iâm quite satisfied with the card overall, Iâve encountered an issue where it seems unable to display negative temperature values. Could you please advise on how I can configure the card to correctly show negative temperatures?
Is it possible to filter entities in this card based on room or floor?
I tried using floor_id but it doesnât seem to work properly.
parautenbach
(Pieter Rautenbach)
January 9, 2025, 12:25pm
316
Show what youâve tried.
I have 3 rooms: room 1, room 2, room 3.
Floor 1 has room 1 and 2.
Floor 2 has room 3.
Devices are associated with one of the 3 rooms.
This is my config:
type: custom:battery-state-card
secondary_info: "{last_changed}"
filter:
include:
- name: attributes.device_class
value: battery
- name: attributes.floor_id
value: "floor_1"
exclude:
- name: entity_id
value: device_tracker.*
- name: entity_id
value: binary_sensor.*_battery_low
- name: entity_id
value: sensor.iphone*
- name: entity_id
value: sensor.ipad*
sort:
by: state
collapse: 20
bulk_rename:
- from: " Battery"
- from: " level"
colors:
steps:
- "#ff0000"
- "#ffff00"
- "#00ff00"
gradient: true
My second attempt is to change to:
filter:
include:
- attributes:
device_class: battery
floor_id: "floor_1"
Other attempt:
filter:
include:
- domain: "floor_1"
I am missing how to make the link between a device and its room+floor.
And I didnât find any examples on the github.
I also tried with a working template which give me all entities with a battery from a specified floor:
{{ floor_areas("floor_1")
| map('area_entities')| sum(start=[])
| select('match', 'sensor.*_battery')
| list }}
However if I try to integrate it, I get no data. I tried with:
filter:
include:
- name: entity_id
value: |-
{{ floor_areas("floor_1")
| map('area_entities')| sum(start=[])
| select('match', 'sensor.*_battery')
| list }}
and with the template input:
filter:
template: |
{% floor_areas("floor_1") %}
{% map('area_entities') | sum(start=[]) %}
{% select('match', 'sensor.*_battery') %}
{% list %}
With different syntax:
filter:
template: |
value: |-
{{ floor_areas("floor_1")
| map('area_entities')| sum(start=[])
| select('match', 'sensor.*_battery')
| list }}
and:
filter:
template: "{{ floor_areas('floor_1') | map('area_entities') | sum(start=[]) | select('match', 'sensor.*_battery') | list }}"
What am I missing?
What is expected by the âfilter: includeâ ?
A list of entity ?
I tested those in the template tool:
I have the auto-entities card working, but I am missing the nice presentation of this card.
EDIT:
Sorry for the late spamming.
I finally got it working using the auto-entities !!
type: custom:auto-entities
card:
type: custom:battery-state-card
title: Battery warning
secondary_info: "{last_changed}"
sort:
by: state
collapse: 5
bulk_rename:
- from: " Battery"
- from: " level"
colors:
steps:
- "#ff0000"
- "#ffff00"
- "#00ff00"
gradient: true
filter:
template: |
{{ floor_areas("floor_1")
| map('area_entities')| sum(start=[])
| select('match', 'sensor.*_battery')
| list }}
Which gives me:
parautenbach
(Pieter Rautenbach)
January 9, 2025, 8:59pm
320
I donât see that the card support templates. Itâs not stated in the docs anywhere. This is tangentially related too.
The floor, area or label isnât available as a property/attribute on entities.
I think your luck is out, unfortunately.
What I do is to add a custom attribute via my customize.yaml
to indicate it must be monitored.
sensor.kitchen_smoke_battery:
friendly_name: Kitchen Smoke Detector Battery
monitor: True
- type: custom:battery-state-card
title: Battery Charge Levels
filter:
include:
- name: "attributes.monitor"
value: True
bulk_rename:
rules:
- from: "Battery"
sort:
- "state"
- "name"
This is an option as well, but I donât want to configure the area or room twice. HA already provides this.
The last script provided above works as intended. (it displays all entities from âfloor_1â in this example).
parautenbach
(Pieter Rautenbach)
January 10, 2025, 12:52pm
322
Right, I see: The auto entities card (as an alternative) indeed supports templates.
ilexpl01
(Ilexpl01)
January 16, 2025, 8:17pm
323
Hi to All. Is there an option to use template in state_map section ?
My goal is to mark in color the entities which are up-to-date with latest ESPHome version and which are not. Different icon would also be a solution.
Unfortunately, Code below does not work
type: custom:battery-state-card
secondary_info: "{last_changed}"
title: Version
state_map:
- from: "{{ state_attr('sensor.esphome_esphome_latest_release','tag') }}"
to: 1
- from: "off" #have no idea how to select other states
to: 2
filter:
include:
- name: entity_id
value: "*_esphome_version"
- name: entity_id
value: sensor.esphome_esphome_latest_release
exclude:
- name: state
value: Unavailable
sort:
by: state
desc: false
bulk_rename:
- from: ESPHome Version
icon: mdi:information-box-outline
colors:
steps:
- value: 1
color: "#00ff00"
- value: 2
color: "#ffff00"
gemborow
(Ĺukasz)
January 24, 2025, 4:02pm
324
I have exact same issue as @OrangePrize , as soon as I add anything to the YAML (eg. title: âfooâ) the card stops displaying anything. I have pretty much default and up to date install of both HA and the Battery State Card. I donât see any warnings or errors in the browserâs java script console. Any clues?
ppastur
(Paul)
January 31, 2025, 3:07am
326
Hi did you manage to solve this as Im having the same issue