Présentation + [Mon Dashboard] BBE

Petite nouveauté, nous avons adopté un mouton… On l’a appelé Shaun…

Pas d’integration Gardena smart home officielle, donc je suis passé par cette intégration: GitHub - py-smart-gardena/hass-gardena-smart-system: Home Assistant custom component integration for Gardena Smart System · GitHub

Le mouton remonte avec une entité lawn_mover, un sensor batterie et deux actions pour le démarrer ou le ramener à la maison:

Je me suis pelé la doc pour me faire une petite carte mushroom template hyper complète affichée dans la vue Jardin (tous les codes d’état et d’erreur sont traduits en français, le badge affiche la batterie ou les erreurs), les boutons (features) permettent de démarrer ou retourner à la base.

le code
features:
  - type: lawn-mower-commands
    commands:
      - start_pause
      - dock
type: custom:mushroom-template-card
primary: >-
  Shaun : {{ state_translated(entity) }} {{ states('sensor.shaun_battery_level')
  }}%
secondary: >-
  {% set s = state_attr(entity, 'state') %} {% set err = state_attr(entity,
  'error') %} {%- if s == 'PAUSED' -%}En pause capot fermé {%- elif s ==
  'PAUSED_IN_CS' -%}En pause sur la base {%- elif s == 'OK_CUTTING' -%}En train
  de tondre (auto) {%- elif s == 'OK_CUTTING_TIMER_OVERRIDDEN' -%}En train de
  tondre (hors planning) {%- elif s == 'OK_SEARCHING' -%}Recherche de la base
  {%- elif s == 'OK_LEAVING' -%}Sortie de la base {%- elif s == 'OK_CHARGING'
  -%}En charge (batterie faible) {%- elif s == 'PARKED_TIMER' -%}Garé (attend le
  planning) {%- elif s == 'PARKED_PARK_SELECTED' -%}Garé jusqu'à nouvel ordre
  {%- elif s == 'PARKED_AUTOTIMER' -%}Garé (herbe trop courte) {%- elif s ==
  'PARKED_FROST' -%}Garé (gel détecté) {%- elif s == 'PARKED_NO_LIGHT' -%}Garé
  (luminosité insuffisante) {%- elif s == 'PARKED_MOWING_COMPLETED' -%}Terminé
  (zone couverte) {%- elif s == 'PARKED_RAIN' -%}Garé (pluie détectée) {%- elif
  s == 'STOPPED_IN_GARDEN' -%}Arrêté dans le jardin {%- elif s ==
  'INITIATE_NEXT_ACTION' -%}Préparation de l'action suivante {%- elif s ==
  'SEARCHING_FOR_SATELLITES' -%}Recherche des satellites GPS {%- elif s ==
  'NONE' -%}État inconnu ou erreur {%- else -%}Inconnu{%- endif %}

  {% if err == 'NO_MESSAGE' -%}Système OK {%- elif err in ['NONE', none] -%}Pas
  de soucis {%- elif err == 'OUTSIDE_WORKING_AREA' -%}Hors zone de travail {%-
  elif err == 'NO_LOOP_SIGNAL' -%}Pas de signal boucle {%- elif err == 'TRAPPED'
  -%}Shaun est coincé ! {%- elif err == 'UPSIDE_DOWN' -%}Shaun est sur le dos !
  {%- elif err == 'LIFTED' -%}Shaun a été soulevé {%- elif err ==
  'CUTTING_SYSTEM_BLOCKED' -%}Lames bloquées {%- elif err.startswith('ALARM_')
  -%}⚠️ ALERTE : {{ err | replace('ALARM_MOWER_', '') | lower }} {%- elif
  'SENSOR_DEFECT' in err or 'PROBLEM' in err -%}Défaut capteur ({{ err }}) {%-
  else -%}Erreur : {{ err | lower | replace('_', ' ') }}{%- endif %}
icon: >-
  {% set s = state_attr(entity, 'state') %} {% if s == 'PAUSED' %}
  mdi:pause-circle {% elif s == 'PAUSED_IN_CS' %} mdi:home-pause {% elif s in
  ['OK_CUTTING', 'OK_CUTTING_TIMER_OVERRIDDEN'] %} mdi:robot-mower {% elif s ==
  'OK_SEARCHING' %} mdi:home-search {% elif s == 'OK_CHARGING' %}
  mdi:battery-charging-high {% elif s == 'PARKED_TIMER' %} mdi:clock-outline {%
  elif s == 'PARKED_AUTOTIMER' %} mdi:grass {% elif s == 'PARKED_FROST' %}
  mdi:snowflake {% elif s == 'PARKED_RAIN' %} mdi:weather-rainy {% elif s ==
  'STOPPED_IN_GARDEN' %} mdi:alert-octagon {% else %} mdi:robot-mower-outline {%
  endif %}
color: >-
  {% set s = state_attr(entity, 'state') %} {% if s in ['OK_CUTTING',
  'OK_CUTTING_TIMER_OVERRIDDEN', 'OK_LEAVING'] %} green {% elif s in
  ['OK_CHARGING', 'OK_SEARCHING', 'SEARCHING_FOR_SATELLITES'] %} blue {% elif s
  in ['PAUSED', 'PAUSED_IN_CS', 'PARKED_TIMER', 'PARKED_RAIN', 'PARKED_FROST']
  %} orange {% elif s == 'STOPPED_IN_GARDEN' %} red {% else %} grey {% endif %}
entity: lawn_mower.shaun
multiline_secondary: true
badge_icon: >-
  {% set bat = state_attr(entity, 'battery_level') | int(0) %} {% set err =
  state_attr(entity, 'error') %} {% if err not in ['NO_MESSAGE', 'NONE', none]
  %}
    mdi:alert-decagram
  {% elif bat == 100 %}
    mdi:battery
  {% elif bat <= 5 %}
    mdi:battery-outline
  {% else %}
    mdi:battery-{{ (bat / 10) | round(0, 'floor') | int }}0
  {% endif %}
badge_color: >-
  {% set bat = state_attr(entity, 'battery_level') | int(0) %} {% set err =
  state_attr(entity, 'error') %} {% if err not in ['NO_MESSAGE', 'NONE', none]
  %}
    red
  {% elif bat >= 80 %}
    green
  {% elif bat >= 50 %}
    light-green
  {% elif bat >= 25 %}
    orange
  {% else %}
    red
  {% endif %}
features_position: bottom
grid_options:
  columns: 12
  rows: auto

J’ai un état plus compact dans le dashboard principal:


le chip ouvre un pop up qui affiche la carte complete vue juste au dessus, et la tuile rappelle le mode en cours en plus compact via un template :

code du template etat compact

Template pour un état compact qui va au delà du state de l’entité lawn_mover (tonte, sur la base, retour, erreur) tous les états de l’attribut states sont décodés…

{% if state_attr('lawn_mower.shaun','state') == 'PAUSED' %} Pause
{% elif state_attr('lawn_mower.shaun','state') == 'PAUSED_IN_CS' %} Pause (base)
{% elif state_attr('lawn_mower.shaun','state') == 'OK_CUTTING' %} Tonte (auto)
{% elif state_attr('lawn_mower.shaun','state') == 'OK_CUTTING_TIMER_OVERRIDDEN' %} Tonte (manuel)
{% elif state_attr('lawn_mower.shaun','state') == 'OK_SEARCHING' %} Retour...
{% elif state_attr('lawn_mower.shaun','state') == 'OK_LEAVING' %} Sortie...
{% elif state_attr('lawn_mower.shaun','state') == 'OK_CHARGING' %} En charge
{% elif state_attr('lawn_mower.shaun','state') == 'PARKED_TIMER' %} Planifié
{% elif state_attr('lawn_mower.shaun','state') == 'PARKED_PARK_SELECTED' %} Garé
{% elif state_attr('lawn_mower.shaun','state') == 'PARKED_AUTOTIMER' %} Repos (gazon)
{% elif state_attr('lawn_mower.shaun','state') == 'PARKED_FROST' %} Gel
{% elif state_attr('lawn_mower.shaun','state') == 'PARKED_NO_LIGHT' %} Nuit
{% elif state_attr('lawn_mower.shaun','state') == 'PARKED_MOWING_COMPLETED' %} Terminé
{% elif state_attr('lawn_mower.shaun','state') == 'PARKED_RAIN' %} Pluie
{% elif state_attr('lawn_mower.shaun','state') == 'STOPPED_IN_GARDEN' %} BLOQUÉ
{% elif state_attr('lawn_mower.shaun','state') == 'INITIATE_NEXT_ACTION' %} Calcul...
{% elif state_attr('lawn_mower.shaun','state') == 'SEARCHING_FOR_SATELLITES' %} Signal GPS...
{% elif state_attr('lawn_mower.shaun','state') == 'NONE' %} Inconnu
{% else %}
Inconnu
{% endif %}