is there a way to get the last known status or value of an entity which is offline ?
Brilliant!
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
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.
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:
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).
Right, I see: The auto entities card (as an alternative) indeed supports templates.
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"
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?
Hi did you manage to solve this as Im having the same issue