Récupérer les prix de carburants

L’intégration fonctionne bien.
Mais l’utilisation (surtout l’affichage), tel-quel, n’est ni-simple, ni performante :

  • il faut récupérer, un a un, les stationID, afficher, un a un, les attribut de ces stations ID.
  • De plus, avec cette méthode, on peut pas trié (dynamiquement la liste, par prix, par exemple)

Voici comment j’ai fait pour la presentation des données

1/ Group
il faut crée un group avec les differents sensors

group:
  station_essence:
  - sensor.prixcarburant_38220002
  - sensor.prixcarburant_38320006
  - sensor.prixcarburant_38800003
  - sensor.prixcarburant_38700003

2/ Tableau markdown trié par prix

on peut, ensuite utiliser un template pour le parser, trié et affiche « que » ce qu’on a besoin :

type: markdown
content: >-
  {% set update = states('sensor.date') %}

  {% set midnight = now().replace(hour=0, minute=0, second=0,
  microsecond=0).timestamp() %}

  {% set sorted_station_essence = "group.carburant" | expand |
  sort(attribute='attributes.Gasoil') %}
    | Station |     Gasoil     |     Gpl     | Update |
    | :------- | :----: | :----: | ------: |
  {% for station in sorted_station_essence %}| {{-
  state_attr(station.entity_id, 'Station name') -}}
    |{%- if state_attr(station.entity_id, "Gasoil") == "None" -%}-{%- else -%}{{- state_attr(station.entity_id, 'Gasoil') -}}{%- endif -%}
    |{%- if state_attr(station.entity_id, "GPLc") == "None" -%}-{%- else -%}{{- state_attr(station.entity_id, 'GPLc') -}}{%- endif -%}
  {%- set event = state_attr(station.entity_id,'Last Update Gasoil') |
  as_timestamp -%}
  {%- set delta = ((event - midnight) // 86400) | int -%}
    |{{ -delta }} Jours|
  {% endfor %}
title: Prix des carburants