# Batterie niveau: faible, indisponible, bonne

**URL:** <https://forum.hacf.fr/t/batterie-niveau-faible-indisponible-bonne/14337>\
**Category:** Automatisation / Scène / Script / BluePrint\
**Created:** [Janvier 11, 2021, 12:23 UTC](https://forum.hacf.fr/t/batterie-niveau-faible-indisponible-bonne/14337 "2021-01-11T12:23:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![steffleur](https://forum.hacf.fr/user_avatar/forum.hacf.fr/steffleur/32/16500_2.png) [@steffleur](https://forum.hacf.fr/u/steffleur)\
**Post date:** [Janvier 11, 2021, 12:23 UTC](https://forum.hacf.fr/t/batterie-niveau-faible-indisponible-bonne/14337/1 "2021-01-11T12:23:42Z")

</div>

bonjour,  
un petit mots sur un addons HACS \> [custom:auto-entities](https://github.com/thomasloven/lovelace-auto-entities).

ce vous partage ce code, il faut bien sure que vos entités soit nommés batterie ou battery (dans mon cas)

 ![1](https://forum.hacf.fr/uploads/default/original/1X/f30b39cc5b0a4f06d640dfe6de22cc9f4b10b0bd.jpeg)

```
type: grid
cards:
  - type: 'custom:auto-entities'
    card:
      title: Batterie faible
      type: entities
    filter:
      include:
        - domain: sensor
          entity_id: '*battery*'
          state: <= 30
          options:
            type: 'custom:button-card'
            color_type: icon
            show_name: true
            show_state: true
            state:
              - value: '20'
                operator: '>'
                color: orange
              - value: '20'
                operator: <
                color: red
            size: 5%
  - type: 'custom:auto-entities'
    card:
      title: Batterie > 30
      type: entities
    filter:
      include:
        - domain: sensor
          entity_id: '*battery*'
          state: '> 30'
          options:
            type: 'custom:button-card'
            color_type: icon
            show_name: true
            show_state: true
            state:
              - value: '50'
                operator: '>='
                color: green
              - value: '50'
                operator: <
                color: blue
            size: 5%
  - type: 'custom:auto-entities'
    card:
      title: Batterie HS
      type: entities
    filter:
      include:
        - domain: sensor
          entity_id: '*battery*'
          state: unavailable
          options:
            type: 'custom:button-card'
            color_type: icon
            show_name: true
            show_state: true

```

---

<div class="post-metadata">

**Author:** ![domokalu\_1](https://forum.hacf.fr/user_avatar/forum.hacf.fr/domokalu_1/32/32283_2.png) [@domokalu\_1](https://forum.hacf.fr/u/domokalu_1)\
**Post date:** [Janvier 11, 2021, 12:55 UTC](https://forum.hacf.fr/t/batterie-niveau-faible-indisponible-bonne/14337/2 "2021-01-11T12:55:47Z")

</div>

Merci, tjs pratique c’est vrai 👍

Toute petite modif puisque j’ai eu le cas: lorsque la batterie est à 50% pile ca s’affiche en blanc, du coup j’ai remplacé ‹&nbsp;\>&nbsp;› par ‹&nbsp;\>=&nbsp;›.

---

<div class="post-metadata">

**Author:** ![pyg](https://forum.hacf.fr/letter_avatar_proxy/v4/letter/p/46a35a/32.png) [@pyg](https://forum.hacf.fr/u/pyg)\
**Post date:** [Janvier 13, 2021, 8:59 UTC](https://forum.hacf.fr/t/batterie-niveau-faible-indisponible-bonne/14337/3 "2021-01-13T08:59:34Z")

</div>

Bonjour,  
Merci, c’est adopté!

---

<div class="post-metadata">

**Author:** ![steffleur](https://forum.hacf.fr/user_avatar/forum.hacf.fr/steffleur/32/16500_2.png) [@steffleur](https://forum.hacf.fr/u/steffleur)\
**Post date:** [Janvier 20, 2021, 10:34 UTC](https://forum.hacf.fr/t/batterie-niveau-faible-indisponible-bonne/14337/4 "2021-01-20T10:34:47Z")

</div>

petites modifications/  
5 colonnes, et filtre +/- le % plus incorporation des 30, 40, 50% merci @pyg  
sur un onglet en mode panneau

 ![1](https://forum.hacf.fr/uploads/default/original/1X/c5e3a53b506f7f70df70c10ac1d119e86468d1cc.jpeg)

```
type: grid
columns: 5
cards:
  - type: 'custom:auto-entities'
    card:
      title: Batterie HS
      type: entities
    filter:
      include:
        - domain: sensor
          entity_id: '*battery*'
          state: unavailable
          options:
            type: 'custom:button-card'
            color_type: icon
            show_name: true
            show_state: true
            state:
              - value: unavailable
                operator: <=
                color: red
  - type: 'custom:auto-entities'
    card:
      title: Batterie 0 à 30
      type: entities
    filter:
      include:
        - domain: sensor
          entity_id: '*battery*'
          state: '>= 0'
          options:
            type: 'custom:button-card'
            color_type: icon
            show_name: true
            show_state: true
            state:
              - value: '20'
                operator: <=
                color: red
              - value: '20'
                operator: '>='
                color: orange
      exclude:
        - domain: sensor
          entity_id: '*battery*'
          state: '>= 30'
          options:
            type: 'custom:button-card'
            color_type: icon
            show_name: true
            show_state: true
  - type: 'custom:auto-entities'
    card:
      title: Batterie 30 à 40
      type: entities
    filter:
      include:
        - domain: sensor
          entity_id: '*battery*'
          state: '>= 30'
          options:
            type: 'custom:button-card'
            color_type: icon
            show_name: true
            show_state: true
            state:
              - value: '35'
                operator: <
                color: orange
              - value: '35'
                operator: '>='
                color: green
      exclude:
        - domain: sensor
          entity_id: '*battery*'
          state: '>= 40'
          options:
            type: 'custom:button-card'
            color_type: icon
            show_name: true
            show_state: true
  - type: 'custom:auto-entities'
    card:
      title: Batterie 40 à 50
      type: entities
    filter:
      include:
        - domain: sensor
          entity_id: '*battery*'
          state: '>= 40'
          options:
            type: 'custom:button-card'
            color_type: icon
            show_name: true
            show_state: true
            state:
              - value: '45'
                operator: <
                color: green
              - value: '45'
                operator: '>='
                color: blue
      exclude:
        - domain: sensor
          entity_id: '*battery*'
          state: '>= 50'
          options:
            type: 'custom:button-card'
            color_type: icon
            show_name: true
            show_state: true
  - type: 'custom:auto-entities'
    card:
      title: Batterie > 50
      type: entities
    filter:
      include:
        - domain: sensor
          entity_id: '*battery*'
          state: '>= 50'
          options:
            type: 'custom:button-card'
            color_type: icon
            show_name: true
            show_state: true
            state:
              - value: '50'
                operator: '>='

```

---

<div class="post-metadata">

**Author:** ![pyg](https://forum.hacf.fr/letter_avatar_proxy/v4/letter/p/46a35a/32.png) [@pyg](https://forum.hacf.fr/u/pyg)\
**Post date:** [Février 16, 2021, 1:41 UTC](https://forum.hacf.fr/t/batterie-niveau-faible-indisponible-bonne/14337/5 "2021-02-16T13:41:34Z")

</div>

Un petit problème de logique, les batteries à exactement 30, 40 et 50% n’apparaissent nul part.

```yaml
      exclude:
        - domain: sensor
          entity_id: '*battery*'
          state: '>= 30'
...
    filter:
      include:
        - domain: sensor
          entity_id: '*battery*'
          state: '>= 31'

```

Update : c’est corrigé dans le message précédent, merci @steffleur
