Calcul de la consommation et du prix recharge d'une voiture électrique

Je l’ai déjà donné ce lien ! C’est plus Influx DB, c’est pour faire quoi ? Avoir une base de données à part de celle de HA ?
Et Grafana pour faire des graphiques ? Pour remplacer ce que j’ai fais ?
Moi ce que j’ai fais ça m’allait mais c’est tellement lent !

Bref ça apporte quoi de plus ? Parce que ça n’a pas l’air super simple à mettre en place.
Et pourquoi avoir une autre base de données Inluxdb ?

Bon, j’ai récupéré mes graphiques en faisant un reset de la date (bouton en haut à gauche de chaque graphique), mais dès qu’on déplace le graphique il charge et ne fait plus rien.
Si j’arrive à faire fonctionner ça ce serait gagné.

EDIT : bon, j’ai ajouté des un no data dans la configuration de chaque graphique, ça évite que ça charge sans rien faire :

apex_config:
  noData:
    text: "Aucune donnée"

Et ajouté :

show:
  in_header: false

Voici le code complet modifié :

path: consommation-green-up
title: Consommation Green'Up
icon: mdi:home-lightning-bolt
type: custom:grid-layout
cards:
  - type: custom:layout-card
    layout_type: custom:grid-layout
    layout:
      grid-template-columns: 2% 96% 2%
      grid-template-rows: auto
      grid-template-areas: |
        "left middle right"
    cards:
      - type: custom:gap-card
        view_layout:
          grid:area: left
      - type: vertical-stack
        cards:
          - type: horizontal-stack
            cards:
              - show_name: false
                show_icon: true
                type: custom:button-card
                entity: input_number.greenup_graph_day_offset
                show_state: false
                size: 1.5em
                tap_action:
                  action: perform-action
                  perform_action: counter.reset
                  target:
                    entity_id: counter.greenup_graph_day_offset_value
                  data: {}
                hold_action:
                  action: none
                icon: mdi:timer-remove
                triggers_update: all
              - show_name: false
                show_icon: true
                type: custom:button-card
                entity: input_number.greenup_graph_day_offset
                show_state: false
                size: 1.5em
                tap_action:
                  action: perform-action
                  perform_action: counter.decrement
                  target:
                    entity_id: counter.greenup_graph_day_offset_value
                  data: {}
                hold_action:
                  action: none
                icon: mdi:less-than
                triggers_update: all
              - type: custom:mushroom-template-card
                primary: >-
                  {% set offset_val =
                  states('counter.greenup_graph_day_offset_value') | int(0)  %} 
                  {% set offset = now() + timedelta( days = offset_val, hours =
                  0, minutes = 00 )  %}  {{
                    as_datetime(offset).strftime('%d/%m/%Y')
                   }}
                secondary: ""
                multiline_secondary: false
                tap_action:
                  action: none
                hold_action:
                  action: none
                double_tap_action:
                  action: none
                layout: vertical
                fill_container: true
              - show_name: false
                show_icon: true
                type: custom:button-card
                entity: input_number.greenup_graph_day_offset
                show_state: false
                size: 1.5em
                tap_action:
                  action: perform-action
                  perform_action: counter.increment
                  target:
                    entity_id: counter.greenup_graph_day_offset_value
                  data: {}
                hold_action:
                  action: none
                icon: mdi:greater-than
                triggers_update: all
          - type: custom:card-templater
            entities:
              - counter.greenup_graph_day_offset_value
              - sensor.consommation_de_la_greenup
              - sensor.cout_de_la_consommation_de_la_greenup
            card:
              type: custom:apexcharts-card
              graph_span: 1d1
              span:
                end: day
                offset_template: >
                  {% if states['counter.greenup_graph_day_offset_value'].state |
                  int == 0 %}{% else %}{% if
                  states['counter.greenup_graph_day_offset_value'].state | int
                  >= 0 %}+{% endif %}{{
                  states['counter.greenup_graph_day_offset_value'].state | int
                  }}d{% endif %}
              apex_config:
                legend:
                  position: top
                chart:
                  height: 300px
                xaxis:
                  labels:
                    format: HH
                plotOptions:
                  bar:
                    columnWidth: 15
                noData:
                  text: "Aucune donnée"
              yaxis:
                - id: conso
                  decimals: 2
                  min: ~0
                  max: ~0.1
                  opposite: false
                - id: cumulative_conso
                  min: 0
                  max: 0
                  show: false
                - id: cumulative_price
                  min: 0
                  max: 0
                  show: false
                - id: price
                  decimals: 2
                  opposite: true
                  min: ~0
                  max: ~0.1
              header:
                show: true
                title: Consommation / Coût (jour)
                show_states: true
                colorize_states: true
              series:
                - entity: sensor.consommation_de_la_greenup
                  name: Consommation (heure en cours)
                  yaxis_id: conso
                  stroke_width: 2
                  unit: " kWh"
                  float_precision: 2
                  color: orange
                  type: column
                  group_by:
                    func: diff
                    duration: 1h
                - entity: sensor.cout_de_la_consommation_de_la_greenup
                  name: Coût (heure en cours)
                  yaxis_id: price
                  stroke_width: 2
                  color: darkblue
                  unit: " €"
                  float_precision: 2
                  type: column
                  group_by:
                    func: diff
                    duration: 1h
                - entity: sensor.consommation_de_la_greenup
                  name: Consommation totale
                  yaxis_id: cumulative_conso
                  unit: " kWh"
                  float_precision: 2
                  color: red
                  group_by:
                    func: diff
                    duration: 1d
                  show:
                    in_chart: false
                    datalabels: false
                    legend_value: false
                    in_header: false
                - entity: sensor.cout_de_la_consommation_de_la_greenup
                  name: Coût total
                  yaxis_id: cumulative_price
                  unit: " €"
                  float_precision: 2
                  color: green
                  group_by:
                    func: diff
                    duration: 1d
                  show:
                    in_chart: false
                    datalabels: false
                    legend_value: false
                    in_header: false
      - type: custom:gap-card
        view_layout:
          grid:area: right
  - type: custom:layout-card
    layout_type: custom:grid-layout
    layout:
      grid-template-columns: 2% 96% 2%
      grid-template-rows: auto
      grid-template-areas: |
        "left middle right"
    cards:
      - type: custom:gap-card
        view_layout:
          grid:area: left
      - type: vertical-stack
        cards:
          - type: horizontal-stack
            cards:
              - show_name: false
                show_icon: true
                type: custom:button-card
                entity: input_number.greenup_graph_week_offset
                show_state: false
                size: 1.5em
                tap_action:
                  action: perform-action
                  perform_action: counter.reset
                  target:
                    entity_id: counter.greenup_graph_week_offset_value
                  data: {}
                hold_action:
                  action: none
                icon: mdi:timer-remove
                triggers_update: all
              - show_name: false
                show_icon: true
                type: custom:button-card
                entity: input_number.greenup_graph_week_offset
                show_state: false
                size: 1.5em
                tap_action:
                  action: perform-action
                  perform_action: counter.decrement
                  target:
                    entity_id: counter.greenup_graph_week_offset_value
                  data: {}
                hold_action:
                  action: none
                icon: mdi:less-than
                triggers_update: all
              - type: custom:mushroom-template-card
                primary: >-
                  {% set offset_val =
                  states('counter.greenup_graph_week_offset_value') | int(0) 
                  %}  {% set offset = now() + timedelta( days = 7 * offset_val,
                  hours = 0, minutes = 00 )  %}  {{
                    as_datetime(offset).strftime('%d/%m/%Y')
                   }}
                secondary: ""
                multiline_secondary: false
                tap_action:
                  action: none
                hold_action:
                  action: none
                double_tap_action:
                  action: none
                layout: vertical
                fill_container: true
              - show_name: false
                show_icon: true
                type: custom:button-card
                entity: input_number.greenup_graph_week_offset
                show_state: false
                size: 1.5em
                tap_action:
                  action: perform-action
                  perform_action: counter.increment
                  target:
                    entity_id: counter.greenup_graph_week_offset_value
                  data: {}
                hold_action:
                  action: none
                icon: mdi:greater-than
                triggers_update: all
          - type: custom:card-templater
            entities:
              - counter.greenup_graph_week_offset_value
              - sensor.consommation_de_la_greenup
              - sensor.cout_de_la_consommation_de_la_greenup
            card:
              type: custom:apexcharts-card
              apex_config:
                legend:
                  position: top
                chart:
                  height: 300px
                plotOptions:
                  bar:
                    columnWidth: 15
                xaxis:
                  labels:
                    format: dddd
                noData:
                  text: "Aucune donnée"
              graph_span: 7d1
              span:
                end: isoWeek
                offset_template: >
                  {% if states['counter.greenup_graph_week_offset_value'].state
                  | int == 0 %}{% else %}{% if
                  states['counter.greenup_graph_week_offset_value'].state | int
                  >= 0 %}+{% endif %}{{ 7 *
                  states['counter.greenup_graph_week_offset_value'].state | int
                  }}d{% endif %}
              yaxis:
                - id: conso
                  decimals: 2
                  min: ~0
                  max: ~0.1
                  opposite: false
                - id: cumulative_conso
                  min: 0
                  max: 0
                  show: false
                - id: cumulative_price
                  min: 0
                  max: 0
                  show: false
                - id: price
                  decimals: 2
                  opposite: true
                  min: ~0
                  max: ~0.1
              header:
                show: true
                title: Consommation / Coût (semaine)
                show_states: true
                colorize_states: true
              series:
                - entity: sensor.consommation_de_la_greenup
                  name: Consommation (jour en cours)
                  yaxis_id: conso
                  unit: " kWh"
                  float_precision: 2
                  color: orange
                  type: column
                  group_by:
                    func: diff
                    duration: 1day
                - entity: sensor.cout_de_la_consommation_de_la_greenup
                  name: Coût (jour en cours)
                  yaxis_id: price
                  color: darkblue
                  unit: " €"
                  float_precision: 2
                  type: column
                  group_by:
                    func: diff
                    duration: 1day
                - entity: sensor.consommation_de_la_greenup
                  name: Consommation totale
                  yaxis_id: cumulativeconso
                  unit: " kWh"
                  float_precision: 2
                  type: column
                  color: red
                  group_by:
                    func: diff
                    duration: 7day
                  show:
                    in_chart: false
                    datalabels: false
                    legend_value: false
                    in_header: false
                - entity: sensor.cout_de_la_consommation_de_la_greenup
                  name: Coût total
                  yaxis_id: cumulativeprice
                  unit: " €"
                  float_precision: 2
                  type: column
                  color: green
                  group_by:
                    func: diff
                    duration: 7day
                  show:
                    in_chart: false
                    datalabels: false
                    legend_value: false
                    in_header: false
      - type: custom:gap-card
        view_layout:
          grid:area: right
  - type: custom:layout-card
    layout_type: custom:grid-layout
    layout:
      grid-template-columns: 2% 96% 2%
      grid-template-rows: auto
      grid-template-areas: |
        "left middle right"
    cards:
      - type: custom:gap-card
        view_layout:
          grid:area: left
      - type: vertical-stack
        cards:
          - type: horizontal-stack
            cards:
              - show_name: false
                show_icon: true
                type: custom:button-card
                entity: input_number.greenup_graph_month_offset
                show_state: false
                size: 1.5em
                tap_action:
                  action: perform-action
                  perform_action: counter.reset
                  target:
                    entity_id: counter.greenup_graph_month_offset_value
                  data: {}
                hold_action:
                  action: none
                icon: mdi:timer-remove
                triggers_update: all
              - show_name: false
                show_icon: true
                type: custom:button-card
                entity: input_number.greenup_graph_month_offset
                show_state: false
                size: 1.5em
                tap_action:
                  action: perform-action
                  perform_action: counter.decrement
                  target:
                    entity_id: counter.greenup_graph_month_offset_value
                  data: {}
                hold_action:
                  action: none
                icon: mdi:less-than
                triggers_update: all
              - type: custom:mushroom-template-card
                primary: >
                  {% set offset_val =
                  states('counter.greenup_graph_month_offset_value') | int(0) 
                  %}

                  {% set cur_date = now() %}

                  {% set str_date = (cur_date.year + (cur_date.month +
                  offset_val - 1) // 12 | int) | string + '-' + ((cur_date.month
                  + offset_val - 1) % 12 + 1) | string + '-' + cur_date.day |
                  string %} {% set cur_date = strptime(str_date, '%Y-%m-%d') %}

                  {{ as_datetime(cur_date).strftime('%d/%m/%Y') }}
                secondary: ""
                multiline_secondary: false
                tap_action:
                  action: none
                hold_action:
                  action: none
                double_tap_action:
                  action: none
                layout: vertical
                fill_container: true
              - show_name: false
                show_icon: true
                type: custom:button-card
                entity: input_number.greenup_graph_month_offset
                show_state: false
                size: 1.5em
                tap_action:
                  action: perform-action
                  perform_action: counter.increment
                  target:
                    entity_id: counter.greenup_graph_month_offset_value
                  data: {}
                hold_action:
                  action: none
                icon: mdi:greater-than
                triggers_update: all
          - type: custom:card-templater
            entities:
              - counter.greenup_graph_month_offset_value
              - sensor.consommation_de_la_greenup
              - sensor.cout_de_la_consommation_de_la_greenup
            card:
              type: custom:apexcharts-card
              apex_config:
                legend:
                  position: top
                chart:
                  height: 300px
                xaxis:
                  labels:
                    format: dd
                plotOptions:
                  bar:
                    columnWidth: 15
                noData:
                  text: "Aucune donnée"
              graph_span: 1month
              span:
                end: month
                offset_template: >
                  {% set valueDecalUTC = (now().utcoffset().seconds / 60) | int
                  %}

                  {% if states['counter.greenup_graph_month_offset_value'].state
                  | int == 0 %}

                  {% if valueDecalUTC > 0 %}+{{ valueDecalUTC }}m{% else %}-{{
                  valueDecalUTC }}m{% endif %}

                  {% else %}

                  {% if states['counter.greenup_graph_month_offset_value'].state
                  | int >= 0 %}+{% endif %}

                  {% set offset_val =
                  states['counter.greenup_graph_month_offset_value'].state |
                  int(0)  %}

                  {% set cur_date = now() %}

                  {% set str_date = (cur_date.year + (cur_date.month +
                  offset_val - 1) // 12 | int) | string + '-' + ((cur_date.month
                  + offset_val - 1) % 12 + 1) | string + '-' + cur_date.day |
                  string %}

                  {% set new_date = strptime(str_date + ' ' +
                  cur_date.strftime('%H:%M:%S'), '%Y-%m-%d %H:%M:%S') %} {{
                  ((as_timestamp(new_date) - as_timestamp(cur_date)) / 60 +
                  valueDecalUTC) | round(0) }}m {% endif %}
              all_series_config:
                extend_to: now
              stacked: false
              yaxis:
                - id: conso
                  decimals: 2
                  min: ~0
                  max: ~0.1
                  opposite: false
                - id: cumulative_conso
                  min: 0
                  max: 0
                  show: false
                - id: cumulative_price
                  min: 0
                  max: 0
                  show: false
                - id: price
                  decimals: 2
                  opposite: true
                  min: ~0
                  max: ~0.1
              header:
                show: true
                title: Consommation / Coût (mois)
                show_states: true
                colorize_states: true
              series:
                - entity: sensor.consommation_de_la_greenup
                  name: Consommation (jour en cours)
                  yaxis_id: conso
                  unit: " kWh"
                  float_precision: 2
                  color: orange
                  type: column
                  group_by:
                    func: diff
                    duration: 1day
                - entity: sensor.cout_de_la_consommation_de_la_greenup
                  name: Coût (jour en cours)
                  yaxis_id: price
                  color: darkblue
                  unit: " €"
                  float_precision: 2
                  type: column
                  group_by:
                    func: diff
                    duration: 1day
                - entity: sensor.consommation_de_la_greenup
                  name: Consommation totale
                  yaxis_id: cumulativeconso
                  unit: " kWh"
                  float_precision: 2
                  type: column
                  color: red
                  group_by:
                    func: diff
                    duration: 1month
                  show:
                    in_chart: false
                    datalabels: false
                    legend_value: false
                    in_header: false
                - entity: sensor.cout_de_la_consommation_de_la_greenup
                  name: Coût total
                  yaxis_id: cumulativeprice
                  unit: " €"
                  float_precision: 2
                  type: column
                  color: green
                  group_by:
                    func: diff
                    duration: 1month
                  show:
                    in_chart: false
                    datalabels: false
                    legend_value: false
                    in_header: false
      - type: custom:gap-card
        view_layout:
          grid:area: right
  - type: custom:layout-card
    layout_type: custom:grid-layout
    layout:
      grid-template-columns: 2% 96% 2%
      grid-template-rows: auto
      grid-template-areas: |
        "left middle right"
    cards:
      - type: custom:gap-card
        view_layout:
          grid:area: left
      - type: vertical-stack
        cards:
          - type: horizontal-stack
            cards:
              - show_name: false
                show_icon: true
                type: custom:button-card
                entity: input_number.greenup_graph_year_offset
                show_state: false
                size: 1.5em
                tap_action:
                  action: perform-action
                  perform_action: counter.reset
                  target:
                    entity_id: counter.greenup_graph_year_offset_value
                  data: {}
                hold_action:
                  action: none
                icon: mdi:timer-remove
                triggers_update: all
              - show_name: false
                show_icon: true
                type: custom:button-card
                entity: input_number.greenup_graph_year_offset
                show_state: false
                size: 1.5em
                tap_action:
                  action: perform-action
                  perform_action: counter.decrement
                  target:
                    entity_id: counter.greenup_graph_year_offset_value
                  data: {}
                hold_action:
                  action: none
                icon: mdi:less-than
                triggers_update: all
              - type: custom:mushroom-template-card
                primary: >
                  {% set offset_val =
                  states('counter.greenup_graph_year_offset_value') | int(0)  %}
                  {% set cur_date = now() %} {% set str_date = (cur_date.year +
                  offset_val) | string + '-' + cur_date.month | string + '-' +
                  cur_date.day | string %} {% set cur_date = strptime(str_date,
                  '%Y-%m-%d') %} {{ as_datetime(cur_date).strftime('%d/%m/%Y')
                  }}
                secondary: ""
                multiline_secondary: false
                tap_action:
                  action: none
                hold_action:
                  action: none
                double_tap_action:
                  action: none
                layout: vertical
                fill_container: true
              - show_name: false
                show_icon: true
                type: custom:button-card
                entity: input_number.greenup_graph_year_offset
                show_state: false
                size: 1.5em
                tap_action:
                  action: perform-action
                  perform_action: counter.increment
                  target:
                    entity_id: counter.greenup_graph_year_offset_value
                  data: {}
                hold_action:
                  action: none
                icon: mdi:greater-than
                triggers_update: all
          - type: custom:card-templater
            entities:
              - counter.greenup_graph_year_offset_value
              - sensor.consommation_de_la_greenup
              - sensor.cout_de_la_consommation_de_la_greenup
            card:
              type: custom:apexcharts-card
              apex_config:
                legend:
                  position: top
                chart:
                  height: 300px
                xaxis:
                  labels:
                    format: MMMM
                plotOptions:
                  bar:
                    columnWidth: 15
                noData:
                  text: "Aucune donnée"
              graph_span: 1year
              span:
                end: year
                offset_template: >
                  {% if states['counter.greenup_graph_year_offset_value'].state
                  | int == 0 %}{% else %}{% if
                  states['counter.greenup_graph_year_offset_value'].state | int
                  >= 0 %}+{% endif %}{{
                  states['counter.greenup_graph_year_offset_value'].state | int
                  }}year{% endif %}
              stacked: false
              yaxis:
                - id: conso
                  decimals: 2
                  min: ~0
                  max: ~0.1
                  opposite: false
                - id: cumulative_conso
                  min: 0
                  max: 0
                  show: false
                - id: cumulative_price
                  min: 0
                  max: 0
                  show: false
                - id: price
                  decimals: 2
                  opposite: true
                  min: ~0
                  max: ~0.1
              header:
                show: true
                title: Consommation / Coût (année)
                show_states: true
                colorize_states: true
              series:
                - entity: sensor.consommation_de_la_greenup
                  name: Consommation (mois en cours)
                  yaxis_id: conso
                  unit: " kWh"
                  float_precision: 2
                  color: orange
                  type: column
                  group_by:
                    func: diff
                    duration: 1month
                - entity: sensor.cout_de_la_consommation_de_la_greenup
                  name: Coût (mois en cours)
                  yaxis_id: price
                  color: darkblue
                  unit: " €"
                  float_precision: 2
                  type: column
                  group_by:
                    func: diff
                    duration: 1month
                - entity: sensor.consommation_de_la_greenup
                  name: Consommation totale
                  yaxis_id: cumulativeconso
                  unit: " kWh"
                  float_precision: 2
                  type: column
                  color: red
                  group_by:
                    func: diff
                    duration: 1year
                  show:
                    in_chart: false
                    datalabels: false
                    legend_value: false
                    in_header: false
                - entity: sensor.cout_de_la_consommation_de_la_greenup
                  name: Coût total
                  yaxis_id: cumulativeprice
                  unit: " €"
                  float_precision: 2
                  type: column
                  color: green
                  group_by:
                    func: diff
                    duration: 1year
                  show:
                    in_chart: false
                    datalabels: false
                    legend_value: false
                    in_header: false
      - type: custom:gap-card
        view_layout:
          grid:area: right
layout:
  layout:
    max_cols: 1
    cols: 1
    grid-template-columns: 100%
    place-content: center

Par contre, au dela de 10 jours, j’ai plus de données alors que dans l’historique j’en ai !