Show battery states or attributes with dynamic icon on entity rows in Home Assistant's Lovelace UI
Rewritten and improved version of cbulock's battery-entity card (deprecated/unmaintained).
NOTE: This is not a standalone lovelace card, but a row element for the entities card. If you need a standalone card or want a lot more customizability, check out maxwroc's battery-state-card.
Manually add battery-entity-row.js
to your <config>/www/
folder and add the following to the configuration.yaml
file:
lovelace:
resources:
- url: /local/battery-entity-row.js?v=1.3.1
type: module
OR install using HACS and add this (if in YAML mode):
lovelace:
resources:
- url: /hacsfiles/lovelace-battery-entity-row/battery-entity-row.js
type: module
The above configuration can be managed directly in the Configuration -> Lovelace Dashboards -> Resources panel when not using YAML mode, or added by clicking the "Add to lovelace" button on the HACS dashboard after installing the plugin.
This card produces an entity-row
and must therefore be configured as an entity in an entities card.
The battery level value is fetched from the entity state
, from the attribute battery
or battery_level
,
or from a custom attribute defined with the attribute
option. Numeric values (0-100
) and some predefined
string values (high
, normal
, low
, etc..) are supported as a battery level value.
Name | Type | Default | Description |
---|---|---|---|
type | string | Required | custom:battery-entity-row |
entity | string | Required | domain.my_entity_id |
attribute | string | battery_level |
Override battery level attribute |
name | string | friendly_name |
Override entity friendly_name |
secondary_info | string | last-changed , last-updated or an attribute of the entity. |
|
unit | string/bool | % |
Override default unit , or hide with false |
icon | string | Override dynamic battery icon |
|
warning | number | 35 |
Level at which the icon will appear yellow |
critical | number | 15 |
Level at which the icon will appear red |
charging | bool/object | false |
Indicate charging based on entity state. See charging object for more options. |
Currently limited support for secondary_info
option with value last-changed
.
Name | Type | Default | Description |
---|---|---|---|
entity | string | main entity |
Get charging state from another entity |
attribute | string | Get charging state from an attribute | |
state | string/list | "on" , "charging" |
Add values that indicate charging (case insensitive) |
type: entities
entities:
- type: custom:battery-entity-row
entity: sensor.bedroom_temperature
- type: custom:battery-entity-row
entity: sensor.bedroom_temperature
attribute: battery_percent
name: Some battery
unit: percent
icon: mdi:battery-alert
secondary_info: last-changed
warning: 50
critical: 25
charging: true
- type: custom:battery-entity-row
entity: sensor.bedroom_temperature
name: Charging battery
charging:
entity: binary_sensor.bedroom_temperature_charger
attribute: charging
state:
- Enabled
- is_charging
Usage in auto-entities card:
type: custom:auto-entities
card:
type: entities
filter:
include:
- entity_id: sensor.battery* # or use other matchers
options:
type: custom:battery-entity-row
<battery-entity-row options>
xiaomi-vacuum-card |
multiple-entity-row |
github-entity-row |
battery-entity-row |
attribute-entity-row