https://github.com/benct/lovelace-battery-entity-row
Show battery states or attributes with dynamic icon on entity rows in Home Assistant's Lovelace UI
https://github.com/benct/lovelace-battery-entity-row
attribute battery card entity entity-rows hacs home-assistant home-assistant-frontend lovelace lovelace-ui state
Last synced: 5 months ago
JSON representation
Show battery states or attributes with dynamic icon on entity rows in Home Assistant's Lovelace UI
- Host: GitHub
- URL: https://github.com/benct/lovelace-battery-entity-row
- Owner: benct
- License: mit
- Created: 2020-10-14T00:02:44.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-12T15:50:43.000Z (over 4 years ago)
- Last Synced: 2025-04-28T11:16:49.405Z (5 months ago)
- Topics: attribute, battery, card, entity, entity-rows, hacs, home-assistant, home-assistant-frontend, lovelace, lovelace-ui, state
- Language: JavaScript
- Homepage:
- Size: 64.5 KB
- Stars: 71
- Watchers: 1
- Forks: 6
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# battery-entity-row
Show battery states or attributes with dynamic icon on entity rows in Home Assistant's Lovelace UI
[](https://github.com/benct/lovelace-battery-entity-row/releases)
[](https://github.com/benct/lovelace-battery-entity-row/releases)
[](https://github.com/benct/lovelace-battery-entity-row/commits/master)
[](https://github.com/benct/lovelace-battery-entity-row)
[](https://github.com/hacs)Rewritten and improved version of cbulock's [battery-entity](https://github.com/cbulock/lovelace-battery-entity) card _(deprecated/unmaintained)_.
**NOTE:** This is not a standalone lovelace card, but a row element for the [entities](https://www.home-assistant.io/lovelace/entities/) card.
If you need a standalone card or want _a lot_ more customizability, check out maxwroc's [battery-state-card](https://github.com/maxwroc/battery-state-card).## Installation
Manually add [battery-entity-row.js](https://raw.githubusercontent.com/benct/lovelace-battery-entity-row/master/battery-entity-row.js)
to your `/www/` folder and add the following to the `configuration.yaml` file:```yaml
lovelace:
resources:
- url: /local/battery-entity-row.js?v=1.3.1
type: module
```_OR_ install using [HACS](https://hacs.xyz/) and add this (if in YAML mode):
```yaml
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.## Configuration
This card produces an `entity-row` and must therefore be configured as an entity in an [entities](https://www.home-assistant.io/lovelace/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`.
### Charging object
| 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) |## Examples

```yaml
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](https://github.com/thomasloven/lovelace-auto-entities) card:
```yaml
type: custom:auto-entities
card:
type: entities
filter:
include:
- entity_id: sensor.battery* # or use other matchers
options:
type: custom:battery-entity-row
```## My cards
[xiaomi-vacuum-card](https://github.com/benct/lovelace-xiaomi-vacuum-card) |
[multiple-entity-row](https://github.com/benct/lovelace-multiple-entity-row) |
[github-entity-row](https://github.com/benct/lovelace-github-entity-row) |
[battery-entity-row](https://github.com/benct/lovelace-battery-entity-row) |
[~~attribute-entity-row~~](https://github.com/benct/lovelace-attribute-entity-row)[](https://www.buymeacoff.ee/benct)