Surveillance electrique et shelly em

Ha oui voila je suis dedans, erreur duplicate keys :stuck_out_tongue:

Voici ton code comme l’attend le tutoriel :

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Stockage utility meter

utility_meter:
  energy_total_usage_daily:
    source: sensor.compteur_general_energy
    cycle: daily
    tariffs:
      - day
      - night

  energy_total_usage_weekly:
    source: sensor.compteur_general_energy
    cycle: weekly
    tariffs:
      - day
      - night

  energy_total_usage_monthly:
    source: sensor.compteur_general_energy
    cycle: monthly
    tariffs:
      - day
      - night

  energy_total_usage_quarterly:
    source: sensor.compteur_general_energy
    cycle: quarterly
    tariffs:
      - day
      - night

  energy_total_usage_yearly:
    source: sensor.compteur_general_energy
    cycle: yearly
    tariffs:
      - day
      - night
      
sensor:
  - platform: template
    sensors:
    # consomation journaliere
        energy_total_daily:  # Consommation journalière HP + HC
          friendly_name: 'Energie journaliere consommée'
          entity_id:
            - sensor.energy_total_usage_daily_day
            - sensor.energy_total_usage_daily_night
          value_template: "{{ (states('sensor.energy_total_usage_daily_day')|float + states('sensor.energy_total_usage_daily_night')|float)|round(3) }}"
          unit_of_measurement: "kWh"
          
  - platform: template
    sensors:
    # consommation semaine
        energy_total_weekly:# Consommation semaine HP + HC
          friendly_name: 'Energie semaine consommée'
          entity_id:
            - sensor.energy_total_usage_weekly_day
            - sensor.energy_total_usage_weekly_night
          value_template: "{{ (states('sensor.energy_total_usage_weekly_day')|float + states('sensor.energy_total_usage_weekly_night')|float)|round(3) }}"
          unit_of_measurement: "kWh"
          

  - platform: template
    sensors:
    # Consommation du moi
        energy_total_monthly:# Consommation moi HP + HC
          friendly_name: 'Energie du moi consommée'
          entity_id:
            - sensor.energy_total_usage_monthly_day
            - sensor.energy_total_usage_monthly_night
          value_template: "{{ (states('sensor.energy_total_usage_monthly_day')|float + states('sensor.energy_total_usage_monthly_night')|float)|round(3) }}"
          unit_of_measurement: "kWh"
          

  - platform: template
    sensors:
# consomation Trimestrielle
        energy_total_quarterly:# Consommation trimestrielle HP + HC
          friendly_name: 'Energie trimestrielle consommée'
          entity_id:
            - sensor.energy_total_usage_quarterly_day
            - sensor.energy_total_usage_quarterly_night
          value_template: "{{ (states('sensor.energy_total_usage_quarterly_day')|float + states('sensor.energy_total_usage_quarterly_night')|float)|round(3) }}"
          unit_of_measurement: "kWh"
          

  - platform: template
    sensors:
# consomation de l'année
        energy_total_yearly: # Consommation de l'année HP + HC
          friendly_name: 'Energie de l année consommée'
          entity_id:
            - sensor.energy_total_usage_yearly_day
            - sensor.energy_total_usage_yearly_night
          value_template: "{{ (states('sensor.energy_total_usage_yearly_day')|float + states('sensor.energy_total_usage_yearly_night')|float)|round(3) }}"
          unit_of_measurement: "kWh"
          

  - platform: template
# sensor pour mettre en euros par jour
    sensors:
      hp_cost_today:# Coût journalier HP
        friendly_name: 'HP Cost Today'
        entity_id:
          - sensor.energy_total_usage_daily_day
          - input_number.hp_daily_cost
          - input_number.hp_energy_cost
        value_template: "{{ (states('sensor.energy_total_usage_daily_day')|float * states('input_number.hp_energy_cost')|float + states('input_number.hp_daily_cost')|float)|round(2) }}"
        unit_of_measurement: "€"

  - platform: template
    sensors:
      hc_cost_today:# Coût journalier HC
        friendly_name: 'HC Cost Today'
        entity_id:
          - sensor.energy_total_usage_daily_night
          - input_number.hc_daily_cost
          - input_number.hc_energy_cost
        value_template: "{{ (states('sensor.energy_total_usage_daily_night')|float * states('input_number.hc_energy_cost')|float + states('input_number.hc_daily_cost')|float)|round(2) }}"
        unit_of_measurement: "€"

  - platform: template
    sensors:
      cost_today:# Coût journalier HP + HC
        friendly_name: "Aujourd'hui"
        entity_id:
          - sensor.hp_cost_today
          - sensor.hc_cost_today
        value_template: "{{ (states('sensor.hp_cost_today')|float + states('sensor.hc_cost_today')|float)|round(2) }}"
        unit_of_measurement: "€"
    
    
    
    

# sensor pour mettre en euros par semaine
  - platform: template
    sensors:
      hp_cost_weekly:# Coût semaine HP
        friendly_name: 'HP Cost semaine'
        entity_id:
          - sensor.energy_total_usage_weekly_day
          - input_number.hp_daily_cost
          - input_number.hp_energy_cost
        value_template: "{{ (states('sensor.energy_total_usage_weekly_day')|float * states('input_number.hp_energy_cost')|float + states('input_number.hp_weekly_cost')|float)|round(2) }}"
        unit_of_measurement: "€"

  - platform: template
    sensors:
      hc_cost_weekly:# Coût semaine HC
        friendly_name: 'HC Cost semaine'
        entity_id:
          - sensor.energy_total_usage_weekly_night
          - input_number.hc_daily_cost
          - input_number.hc_energy_cost
        value_template: "{{ (states('sensor.energy_total_usage_weekly_night')|float * states('input_number.hc_energy_cost')|float + states('input_number.hc_weekly_cost')|float)|round(2) }}"
        unit_of_measurement: "€"

  - platform: template
    sensors:
      cost_weekly:# Coût semaine HP + HC
        friendly_name: "semaine"
        entity_id:
          - sensor.hp_cost_weekly
          - sensor.hc_cost_weekly
        value_template: "{{ (states('sensor.hp_cost_weekly')|float + states('sensor.hc_cost_weekly')|float)|round(2) }}"
        unit_of_measurement: "€"
          
          

# sensor pour mettre en euros par moi
  - platform: template
    sensors:
      hp_cost_monthly:# Coût par moi HP
        friendly_name: 'HP Cost monthly'
        entity_id:
          - sensor.energy_total_usage_monthly_day
          - input_number.hp_daily_cost
          - input_number.hp_energy_cost
        value_template: "{{ (states('sensor.energy_total_usage_monthly_day')|float * states('input_number.hp_energy_cost')|float + states('input_number.hp_monthly_cost')|float)|round(2) }}"
        unit_of_measurement: "€"

  - platform: template
    sensors:
      hc_cost_monthly:# Coût par moi HC
        friendly_name: 'HC Cost monthly'
        entity_id:
          - sensor.energy_total_usage_monthly_night
          - input_number.hc_daily_cost
          - input_number.hc_energy_cost
        value_template: "{{ (states('sensor.energy_total_usage_monthly_night')|float * states('input_number.hc_energy_cost')|float + states('input_number.hc_monthly_cost')|float)|round(2) }}"
        unit_of_measurement: "€"

  - platform: template
    sensors:
      cost_monthly:# Coût par moi HP + HC
        friendly_name: "Le moi"
        entity_id:
          - sensor.hp_cost_monthly
          - sensor.hc_cost_monthly
        value_template: "{{ (states('sensor.hp_cost_monthly')|float + states('sensor.hc_cost_monthly')|float)|round(2) }}"
        unit_of_measurement: "€"
          
# sensor pour mettre en euros par trimestre

  - platform: template
    sensors:
      hp_cost_quarterly:# Coût par trimestre HP 
        friendly_name: 'HP Cost quarterly'
        entity_id:
          - sensor.energy_total_usage_quarterly_day
          - input_number.hp_daily_cost
          - input_number.hp_energy_cost
        value_template: "{{ (states('sensor.energy_total_usage_quarterly_day')|float * states('input_number.hp_energy_cost')|float + states('input_number.hp_quarterly_cost')|float)|round(2) }}"
        unit_of_measurement: "€"

  - platform: template
    sensors:
      hc_cost_quarterly:# Coût par trimestre HC
        friendly_name: 'HC Cost quarterly'
        entity_id:
          - sensor.energy_total_usage_quarterly_night
          - input_number.hc_daily_cost
          - input_number.hc_energy_cost
        value_template: "{{ (states('sensor.energy_total_usage_quarterly_night')|float * states('input_number.hc_energy_cost')|float + states('input_number.hc_quarterly_cost')|float)|round(2) }}"
        unit_of_measurement: "€"

  - platform: template
    sensors:
      cost_quarterly:# Coût par trimestre HP + HC
        friendly_name: "Le trimestre"
        entity_id:
          - sensor.hp_cost_quarterly
          - sensor.hc_cost_quarterly
        value_template: "{{ (states('sensor.hp_cost_quarterly')|float + states('sensor.hc_cost_quarterly')|float)|round(2) }}"
        unit_of_measurement: "€"


# sensor pour mettre en euros par année

  - platform: template
    sensors:
      hp_cost_yearly:# Coût par année HP      
        friendly_name: 'HP Cost yearly'
        entity_id:
          - sensor.energy_total_usage_yearly_day
          - input_number.hp_daily_cost
          - input_number.hp_energy_cost
        value_template: "{{ (states('sensor.energy_total_usage_yearly_day')|float * states('input_number.hp_energy_cost')|float + states('input_number.hp_yearly_cost')|float)|round(2) }}"
        unit_of_measurement: "€"

  - platform: template
    sensors:
      hc_cost_yearly:# Coût par année HC
        friendly_name: 'HC Cost yearly'
        entity_id:
          - sensor.energy_total_usage_yearly_night
          - input_number.hc_daily_cost
          - input_number.hc_energy_cost
        value_template: "{{ (states('sensor.energy_total_usage_yearly_night')|float * states('input_number.hc_energy_cost')|float + states('input_number.hc_yearly_cost')|float)|round(2) }}"
        unit_of_measurement: "€"

  - platform: template
    sensors:
      cost_yearly:# Coût par année HP + HC
        friendly_name: "L année"
        entity_id:
          - sensor.hp_cost_yearly
          - sensor.hc_cost_yearly
        value_template: "{{ (states('sensor.hp_cost_yearly')|float + states('sensor.hc_cost_yearly')|float)|round(2) }}"
        unit_of_measurement: "€"

# entrees 
input_number:
  hp_daily_cost:
    name: HP - Cout journalier
    mode: box
    min: 0
    max: 100
    unit_of_measurement: "€/day"
    icon: mdi:currency-eur

  hp_energy_cost:
    name: HP - Coût du Kwh
    mode: box
    min: 0
    max: 100
    unit_of_measurement: "€/kWh"
    icon: mdi:currency-eur

  hc_daily_cost:
    name: HC - Cout journalier
    mode: box
    min: 0
    max: 100
    unit_of_measurement: "€/day"
    icon: mdi:currency-eur

  hc_energy_cost:
    name: HC - Coût du Kwh
    mode: box
    min: 0
    max: 100
    unit_of_measurement: "€/kWh"
    icon: mdi:currency-eur
    

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
1 « J'aime »

Ok super merci je prend le temps de bien y comprendre :slight_smile:

Rhofl en copiant ce code je tombe direct sur cette erreur, apparement ce serait un changement dans la nomination du code ?

           - sensor.energy_total_usage_daily_day
            - sensor.energy_total_usage_daily_night
String does not match the pattern of "DEPRECATED^".yaml-schema: http://schemas.home-assistant.io/configuration

Toutes les entités qui ont la clé entity_id doivent être reprise car cette clé n’est plus utilisée (tutoriel vieux… dans la vie des versions de HA).

Comme ceci pour la partie cité en debut de message (une suppression pure et simple) :

- platform: template
    sensors:
      cost_monthly:# Coût par moi HP + HC
        friendly_name: "Le moi"
        value_template: "{{ (states('sensor.hp_cost_monthly')|float + states('sensor.hc_cost_monthly')|float)|round(2) }}"
        unit_of_measurement: "€"

Re-bonjour,
Aprés avoir passé un temps fou a rechercher les alternative et ce qui se fait maintenant comme code, je ne sais plus quoi faire :s
Le code n’a pas l’air d’être compliqué au final, d’autant que j’ai toutes les infos qui arrivent avec l’intégration native de shelly :s
la partie utility meter, les input-number et l’addition kwh en euros…
Pourquoi rien ne fonctionne aaaaaghhrr :stuck_out_tongue:
Merci a ceux qui m’aident


# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Stockage utility meter
utility_meter:
  ###########################################
  energy_total_usage_daily:
    source: sensor.compteur_general_energy
    cycle: daily
    tariffs:
      - day
      - night
  ###########################################
  energy_total_usage_weekly:
    source: sensor.compteur_general_energy
    cycle: weekly
    tariffs:
      - day
      - night
  ###########################################
  energy_total_usage_monthly:
    source: sensor.compteur_general_energy
    cycle: monthly
    tariffs:
      - day
      - night
  ###########################################
  energy_total_usage_quarterly:
    source: sensor.compteur_general_energy
    cycle: quarterly
    tariffs:
      - day
      - night
  ###########################################
  energy_total_usage_yearly:
    source: sensor.compteur_general_energy
    cycle: yearly
    tariffs:
      - day
      - night
  ###########################################
sensor:
  - platform: template
    sensors:
      # consomation journaliere
      energy_total_daily: # Consommation journalière HP + HC
        friendly_name: "Energie journaliere consommée"
        value_template: "{{ (states('sensor.energy_total_usage_daily_day')|float + states('sensor.energy_total_usage_daily_night')|float)|round(3) }}"
        unit_of_measurement: "kWh"




# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

j’en suis la j’ai tout recommencé, mais voila la partie -platform: template avec les sensor ne fonctionne pas, il ne se passe rien…

Mon besoin en code est pas compliqué je le sent, :slight_smile:

Récupérer sur des période (jours,semaine,moi,trimestre,année) la consommation elec, un input number pour les tarif elec et ensuite les additionnés a la conso électrique, le luxe, les stocké avec influxdb et faire un jolie graph lisible avec grafana, je ne souhaite rien d’autre, pas de notification ou autre :stuck_out_tongue:
Le tuto de mycanaletto est une bonne base mais je ne peut plus m’en inspirer car apparement le code HA à été mis a jour depuis. Si quelqu’un sait me donner des lignes directive ou des exemple de code je suis fort preneur, c’est mon tout premier code HA, j’ai plus ou moins compris comment ca fonctionne mais bon apres 1000000 recherche je me perd

  ###########################################
  - platform: template
    sensors:
      ##Passer en euros par jour
      friendly_name: "HP Cost Today"
      value_template: "{{ (states('sensor.energy_total_usage_daily_day')|float * states('input_number.hp_energy_cost')|float + states('input_number.hp_daily_cost')|float)|round(2) }}"
      unit_of_measurement: "€"
  - platform: template
    sensors:
      ##Passer en euros par jour
      friendly_name: "HC Cost Today"
      value_template: "{{ (states('sensor.energy_total_usage_daily_night')|float * states('input_number.hc_energy_cost')|float + states('input_number.hc_daily_cost')|float)|round(2) }}"
      unit_of_measurement: "€"
      ##Passer en euros par jour
  - platform: template
    sensors:
      friendly_name: "Aujourd hui"
      value_template: "{{ (states('sensor.hp_cost_today')|float + states('sensor.hc_cost_today')|float)|round(2) }}"
      unit_of_measurement: "€"
  ###########################################

C’est vraiment a partir de la que ca déconne :stuck_out_tongue:

2021-07-15 13:12:00 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.energy_total_usage_daily_day has unknown unit None
2021-07-15 13:12:00 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.energy_total_usage_weekly_day has unknown unit None
2021-07-15 13:12:00 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.energy_total_usage_monthly_day has unknown unit None
2021-07-15 13:12:00 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.energy_total_usage_quarterly_day has unknown unit None
2021-07-15 13:12:00 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.energy_total_usage_yearly_day has unknown unit None

je comprend pas trop :s

Salut

Retire les guillemets de ton sigle euros

Hum j’ai essayé en enlevant les guillemets, ca me marque une invalid syntax

Invalid config for [sensor.template]: expected dictionary for dictionary value @ data['sensors']['friendly_name']. Got 'HP Cost Today'
expected dictionary for dictionary value @ data['sensors']['unit_of_measurement']. Got '€'
expected dictionary for dictionary value @ data['sensors']['value_template']. Got "{{ (states('sensor.energy_total_usage_daily_day')|float * states('input_number.hp_energy_cost')|float + states('input_number.hp_daily_cost')|float)|round(2) }}". (See ?, line ?).
Invalid config for [sensor.template]: expected dictionary for dictionary value @ data['sensors']['friendly_name']. Got 'HC Cost Today'
expected dictionary for dictionary value @ data['sensors']['unit_of_measurement']. Got '€'
expected dictionary for dictionary value @ data['sensors']['value_template']. Got "{{ (states('sensor.energy_total_usage_daily_night')|float * states('input_number.hc_energy_cost')|float + states('input_number.hc_daily_cost')|float)|round(2) }}". (See ?, line ?).
Invalid config for [sensor.template]: expected dictionary for dictionary value @ data['sensors']['friendly_name']. Got 'Aujourd hui'
expected dictionary for dictionary value @ data['sensors']['unit_of_measurement']. Got '€'
expected dictionary for dictionary value @ data['sensors']['value_template']. Got "{{ (states('sensor.hp_cost_today')|float + states('sensor.hc_cost_today')|float)|round(2) }}". (See ?, line ?).

J’obtient ce résultat la avec guillemet

Invalid config for [sensor.template]: expected dictionary for dictionary value @ data['sensors']['friendly_name']. Got 'HP Cost Today'
expected dictionary for dictionary value @ data['sensors']['unit_of_measurement']. Got '€'
expected dictionary for dictionary value @ data['sensors']['value_template']. Got "{{ (states('sensor.energy_total_usage_daily_day')|float * states('input_number.hp_energy_cost')|float + states('input_number.hp_daily_cost')|float)|round(2) }}". (See ?, line ?).
Invalid config for [sensor.template]: expected dictionary for dictionary value @ data['sensors']['friendly_name']. Got 'HC Cost Today'
expected dictionary for dictionary value @ data['sensors']['unit_of_measurement']. Got '€'
expected dictionary for dictionary value @ data['sensors']['value_template']. Got "{{ (states('sensor.energy_total_usage_daily_night')|float * states('input_number.hc_energy_cost')|float + states('input_number.hc_daily_cost')|float)|round(2) }}". (See ?, line ?).
Invalid config for [sensor.template]: expected dictionary for dictionary value @ data['sensors']['friendly_name']. Got 'Aujourd hui'
expected dictionary for dictionary value @ data['sensors']['unit_of_measurement']. Got '€'
expected dictionary for dictionary value @ data['sensors']['value_template']. Got "{{ (states('sensor.hp_cost_today')|float + states('sensor.hc_cost_today')|float)|round(2) }}". (See ?, line ?).

et la sans

Tu es sûr que les logs correspondent bien ?
2 erreurs différentes dans le même cas avec les guillemets, ça veut dire qu’autre chose a changé également.

oui les logs sont bien ceux la, celui du bas c’est celui sans guillemet

Mon code en est la

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Stockage utility meter
utility_meter:
  ###########################################
  energy_total_usage_daily:
    source: sensor.compteur_general_energy
    cycle: daily
    tariffs:
      - day
      - night
  ###########################################
  energy_total_usage_weekly:
    source: sensor.compteur_general_energy
    cycle: weekly
    tariffs:
      - day
      - night
  ###########################################
  energy_total_usage_monthly:
    source: sensor.compteur_general_energy
    cycle: monthly
    tariffs:
      - day
      - night
  ###########################################
  energy_total_usage_quarterly:
    source: sensor.compteur_general_energy
    cycle: quarterly
    tariffs:
      - day
      - night
  ###########################################
  energy_total_usage_yearly:
    source: sensor.compteur_general_energy
    cycle: yearly
    tariffs:
      - day
      - night
  ###########################################
sensor:
  - platform: template
    sensors:
      # consomation journaliere
      energy_total_daily: # Consommation journalière HP + HC
        friendly_name: "Energie journaliere consommée"
        value_template: "{{ (states('sensor.energy_total_usage_daily_day')|float + states('sensor.energy_total_usage_daily_night')|float)|round(3) }}"
        unit_of_measurement: "kWh"
  ###########################################
  - platform: template
    sensors:
      # consomation semaine
      energy_total_weekly: # Consommation semaine HP + HC
        friendly_name: "Energie de la semaine consommée"
        value_template: "{{ (states('sensor.energy_total_usage_weekly_day')|float + states('sensor.energy_total_usage_weekly_night')|float)|round(3) }}"
        unit_of_measurement: "kWh"
  ###########################################
  - platform: template
    sensors:
      # consomation du mois
      energy_total_monthly: # Consommation du mois HP + HC
        friendly_name: "Energie du mois"
        value_template: "{{ (states('sensor.energy_total_usage_monthly_day')|float + states('sensor.energy_total_usage_monthly_night')|float)|round(3) }}"
        unit_of_measurement: "kWh"
  ###########################################
  - platform: template
    sensors:
      # consomation du trimestre
      energy_total_quarterly: # Consommation trimestre HP + HC
        friendly_name: "Energie du trimestre"
        value_template: "{{ (states('sensor.energy_total_usage_quarterly_day')|float + states('sensor.energy_total_usage_quarterly_night')|float)|round(3) }}"
        unit_of_measurement: "kWh"
  ###########################################
  - platform: template
    sensors:
      # consomation de l année
      energy_total_yearly: # Consommation de l année HP + HC
        friendly_name: "Energie de l année"
        value_template: "{{ (states('sensor.energy_total_usage_yearly_day')|float + states('sensor.energy_total_usage_yearly_night')|float)|round(3) }}"
        unit_of_measurement: "kWh"
  ###########################################
  ###########################################
  - platform: template
    sensors:
      ##Passer en euros par jour
      friendly_name: "HP Cost Today"
      value_template: "{{ (states('sensor.energy_total_usage_daily_day')|float * states('input_number.hp_energy_cost')|float + states('input_number.hp_daily_cost')|float)|round(2) }}"
      unit_of_measurement: €
  - platform: template
    sensors:
      ##Passer en euros par jour
      friendly_name: "HC Cost Today"
      value_template: "{{ (states('sensor.energy_total_usage_daily_night')|float * states('input_number.hc_energy_cost')|float + states('input_number.hc_daily_cost')|float)|round(2) }}"
      unit_of_measurement: €
      ##Passer en euros par jour
  - platform: template
    sensors:
      friendly_name: "Aujourd hui"
      value_template: "{{ (states('sensor.hp_cost_today')|float + states('sensor.hc_cost_today')|float)|round(2) }}"
      unit_of_measurement: €
  ###########################################
# entrees
input_number:
  hp_daily_cost:
    name: HP - Cout journalier
    mode: box
    min: 0
    max: 100
    unit_of_measurement: "€/day"
    icon: mdi:currency-eur

  hp_energy_cost:
    name: HP - Coût du Kwh
    mode: box
    min: 0
    max: 100
    unit_of_measurement: "€/kWh"
    icon: mdi:currency-eur

  hc_daily_cost:
    name: HC - Cout journalier
    mode: box
    min: 0
    max: 100
    unit_of_measurement: "€/day"
    icon: mdi:currency-eur

  hc_energy_cost:
    name: HC - Coût du Kwh
    mode: box
    min: 0
    max: 100
    unit_of_measurement: "€/kWh"
    icon: mdi:currency-eur

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

Il manque un niveau pour les 3 derniers templates au dessus de input_number

Sur le téléphone c’est difficile de faire plus précis, il faut comparer avec le tuto

EDIT
j’ai mis 3 noms au pif

  • hp_cost_today:
  • hc_cost_today:
  • total_today:
- platform: template
  sensors:
    ##Passer en euros par jour
    hp_cost_today:
      friendly_name: "HP Cost Today"
      value_template: "{{ (states('sensor.energy_total_usage_daily_day')|float * states('input_number.hp_energy_cost')|float + states('input_number.hp_daily_cost')|float)|round(2) }}"
      unit_of_measurement: €
- platform: template
  sensors:
    ##Passer en euros par jour
    hc_cost_today:
      friendly_name: "HC Cost Today"
      value_template: "{{ (states('sensor.energy_total_usage_daily_night')|float * states('input_number.hc_energy_cost')|float + states('input_number.hc_daily_cost')|float)|round(2) }}"
      unit_of_measurement: €
      ##Passer en euros par jour
- platform: template
  sensors:
    total_today:
      friendly_name: "Aujourd hui"
      value_template: "{{ (states('sensor.hp_cost_today')|float + states('sensor.hc_cost_today')|float)|round(2) }}"
      unit_of_measurement: €

graah ca veux pas :stuck_out_tongue:
Je comprend pas ou j’ai faux

  ###########################################
- platform: template
  sensors:
      ##Passer en euros par jour
      hp_cost_today:
       friendly_name: "HP Cost Today"
       value_template: "{{ (states('sensor.energy_total_usage_daily_day')|float * states('input_number.hp_energy_cost')|float + states('input_number.hp_daily_cost')|float)|round(2) }}"
       unit_of_measurement: €

Quand je veux save le code, tout ok visual me détecte aucune erreur je veux redémarrer et la ca veux pas faire la Verif de configuration, le rond tourne sans dire ok…
j’ai le journal remplis d’1 milliard d’erreur… :sa:

2021-07-15 14:37:43 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Archer_MR600' for upnp integration not ready yet: None; Retrying in background
2021-07-15 15:24:30 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
resp = await self._request_handler(request)
File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 499, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 119, in impl
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 77, in forwarded_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 24, in request_context_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 78, in ban_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 144, in auth_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 135, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/config/core.py", line 29, in post
errors = await async_check_ha_config_file(request.app["hass"])
File "/usr/src/homeassistant/homeassistant/config.py", line 904, in async_check_ha_config_file
res = await check_config.async_check_ha_config_file(hass)
File "/usr/src/homeassistant/homeassistant/helpers/check_config.py", line 225, in async_check_ha_config_file
p_validated = platform_schema(p_validated)
File "/usr/local/lib/python3.9/site-packages/voluptuous/validators.py", line 218, in __call__
return self._exec((Schema(val) for val in self.validators), v)
File "/usr/local/lib/python3.9/site-packages/voluptuous/validators.py", line 337, in _exec
v = func(v)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 272, in __call__
return self._compiled([], data)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
return schema(data)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 272, in __call__
return self._compiled([], data)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict
return base_validate(path, iteritems(data), out)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 386, in validate_mapping
cval = cvalue(key_path, value)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
return schema(data)
File "/usr/src/homeassistant/homeassistant/helpers/config_validation.py", line 487, in verify
return cast(dict, schema(value))
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 272, in __call__
return self._compiled([], data)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict
return base_validate(path, iteritems(data), out)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 386, in validate_mapping
cval = cvalue(key_path, value)
File "/usr/local/lib/python3.9/site-packages/voluptuous/validators.py", line 215, in _run
return self._exec(self._compiled, value, path)
File "/usr/local/lib/python3.9/site-packages/voluptuous/validators.py", line 339, in _exec
v = func(path, v)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
return schema(data)
File "/usr/src/homeassistant/homeassistant/helpers/config_validation.py", line 738, in validator
if key in config:
TypeError: argument of type 'NoneType' is not iterable
2021-07-15 15:44:33 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
resp = await self._request_handler(request)
File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 499, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 119, in impl
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 77, in forwarded_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 24, in request_context_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 78, in ban_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 144, in auth_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 135, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/config/core.py", line 29, in post
errors = await async_check_ha_config_file(request.app["hass"])
File "/usr/src/homeassistant/homeassistant/config.py", line 904, in async_check_ha_config_file
res = await check_config.async_check_ha_config_file(hass)
File "/usr/src/homeassistant/homeassistant/helpers/check_config.py", line 225, in async_check_ha_config_file
p_validated = platform_schema(p_validated)
File "/usr/local/lib/python3.9/site-packages/voluptuous/validators.py", line 218, in __call__
return self._exec((Schema(val) for val in self.validators), v)
File "/usr/local/lib/python3.9/site-packages/voluptuous/validators.py", line 337, in _exec
v = func(v)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 272, in __call__
return self._compiled([], data)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
return schema(data)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 272, in __call__
return self._compiled([], data)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict
return base_validate(path, iteritems(data), out)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 386, in validate_mapping
cval = cvalue(key_path, value)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
return schema(data)
File "/usr/src/homeassistant/homeassistant/helpers/config_validation.py", line 487, in verify
return cast(dict, schema(value))
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 272, in __call__
return self._compiled([], data)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict
return base_validate(path, iteritems(data), out)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 386, in validate_mapping
cval = cvalue(key_path, value)
File "/usr/local/lib/python3.9/site-packages/voluptuous/validators.py", line 215, in _run
return self._exec(self._compiled, value, path)
File "/usr/local/lib/python3.9/site-packages/voluptuous/validators.py", line 339, in _exec
v = func(path, v)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
return schema(data)
File "/usr/src/homeassistant/homeassistant/helpers/config_validation.py", line 738, in validator
if key in config:
TypeError: argument of type 'NoneType' is not iterable
2021-07-15 15:54:16 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
resp = await self._request_handler(request)
File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 499, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 119, in impl
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 77, in forwarded_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 24, in request_context_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 78, in ban_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 144, in auth_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 135, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/config/core.py", line 29, in post
errors = await async_check_ha_config_file(request.app["hass"])
File "/usr/src/homeassistant/homeassistant/config.py", line 904, in async_check_ha_config_file
res = await check_config.async_check_ha_config_file(hass)
File "/usr/src/homeassistant/homeassistant/helpers/check_config.py", line 225, in async_check_ha_config_file
p_validated = platform_schema(p_validated)
File "/usr/local/lib/python3.9/site-packages/voluptuous/validators.py", line 218, in __call__
return self._exec((Schema(val) for val in self.validators), v)
File "/usr/local/lib/python3.9/site-packages/voluptuous/validators.py", line 337, in _exec
v = func(v)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 272, in __call__
return self._compiled([], data)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
return schema(data)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 272, in __call__
return self._compiled([], data)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict
return base_validate(path, iteritems(data), out)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 386, in validate_mapping
cval = cvalue(key_path, value)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
return schema(data)
File "/usr/src/homeassistant/homeassistant/helpers/config_validation.py", line 487, in verify
return cast(dict, schema(value))
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 272, in __call__
return self._compiled([], data)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict
return base_validate(path, iteritems(data), out)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 386, in validate_mapping
cval = cvalue(key_path, value)
File "/usr/local/lib/python3.9/site-packages/voluptuous/validators.py", line 215, in _run
return self._exec(self._compiled, value, path)
File "/usr/local/lib/python3.9/site-packages/voluptuous/validators.py", line 339, in _exec
v = func(path, v)
File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
return schema(data)
File "/usr/src/homeassistant/homeassistant/helpers/config_validation.py", line 738, in validator
if key in config:
TypeError: argument of type 'NoneType' is not iterable

Et dés que j’enleve la partit du code pour transcrire en euros, bam tout refonctionne …

Le décalage de niveau est toujours de 2 espaces. Pas 1, pas 3, pas 4

image

haaaaaaaa ):
merci je vais reprendre ca :slight_smile:

HHHaaaaa y’a du bien mieux,
Bon par contre je sais pas comment verifier si cela fonctionne ? :wink:

  ###########################################
  - platform: template
    sensors:
      ##Passer en euros par jour
      hp_cost_today:
        friendly_name: "HP Cost Today"
        value_template: "{{ (states('sensor.energy_total_usage_daily_day')|float * states('input_number.hp_energy_cost')|float + states('input_number.hp_daily_cost')|float)|round(2) }}"
        unit_of_measurement: €

mais pour le coup plus d’erreurs : )

Attendre que ce qui sert à faire le calcul contienne des valeurs…

Bon me revoila avec mes problèmes :s
Ca fonctionne…presque !!!
Juste la partit de code avec les sensors pour passer en € ne fonctionne pas et pour moi c’est le plus important :’(

j’ai ca comme erreur dans le log

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:567
Integration: Capteur (documentation, issues)
First occurred: 19:20:35 (1 occurrences)
Last logged: 19:20:35

Entity id already exists - ignoring: sensor.hp_cost_today

Already exists … ça indique que cette config est probablement en double … Un petit coup de traduction en ligne, ça donne des pistes si on ne maitrise pas l’anglais

Je maitrise l’anglais, je savais ce que cela veux dire, je me suis peut être mal fait comprendre.
J’ai déja verifié si il n’existait pas déja ce sensors… et bein je ne l’ai pas trouvé.

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
############################################
############################################
############################################

# Stockage utility meter
utility_meter:
  ###########################################
  energy_total_usage_daily:
    source: sensor.compteur_general_energy
    cycle: daily
    tariffs:
      - day
      - night
  ###########################################
  energy_total_usage_weekly:
    source: sensor.compteur_general_energy
    cycle: weekly
    tariffs:
      - day
      - night
  ###########################################
  energy_total_usage_monthly:
    source: sensor.compteur_general_energy
    cycle: monthly
    tariffs:
      - day
      - night
  ###########################################
  energy_total_usage_quarterly:
    source: sensor.compteur_general_energy
    cycle: quarterly
    tariffs:
      - day
      - night
  ###########################################
  energy_total_usage_yearly:
    source: sensor.compteur_general_energy
    cycle: yearly
    tariffs:
      - day
      - night
############################################
############################################
############################################

##LES SENSORS

############################################
############################################
############################################

# consomation journaliere
sensor:
  - platform: template
    sensors:
      energy_total_daily: # Consommation journalière HP + HC
        friendly_name: "Energie journaliere consommée"
        value_template: "{{ (states('sensor.energy_total_usage_daily_day')|float + states('sensor.energy_total_usage_daily_night')|float)|round(3) }}"
        unit_of_measurement: "kWh"
  ###########################################
  # consomation semaine
  - platform: template
    sensors:
      energy_total_weekly: # Consommation semaine HP + HC
        friendly_name: "Energie de la semaine consommée"
        value_template: "{{ (states('sensor.energy_total_usage_weekly_day')|float + states('sensor.energy_total_usage_weekly_night')|float)|round(3) }}"
        unit_of_measurement: "kWh"
  ###########################################
  # consomation du mois
  - platform: template
    sensors:
      energy_total_monthly: # Consommation du mois HP + HC
        friendly_name: "Energie du mois"
        value_template: "{{ (states('sensor.energy_total_usage_monthly_day')|float + states('sensor.energy_total_usage_monthly_night')|float)|round(3) }}"
        unit_of_measurement: "kWh"
  ###########################################
  # consomation du trimestre
  - platform: template
    sensors:
      energy_total_quarterly: # Consommation trimestre HP + HC
        friendly_name: "Energie du trimestre"
        value_template: "{{ (states('sensor.energy_total_usage_quarterly_day')|float + states('sensor.energy_total_usage_quarterly_night')|float)|round(3) }}"
        unit_of_measurement: "kWh"
  ###########################################
  # consomation de l année
  - platform: template
    sensors:
      energy_total_yearly: # Consommation de l année HP + HC
        friendly_name: "Energie de l année"
        value_template: "{{ (states('sensor.energy_total_usage_yearly_day')|float + states('sensor.energy_total_usage_yearly_night')|float)|round(3) }}"
        unit_of_measurement: "kWh"
  ###########################################
  ##Passer en euros par jour HP
  - platform: template
    sensors:
      hp_cost_today:
        friendly_name: "HP Cost Today"
        value_template: "{{ (states('sensor.energy_total_usage_daily_day')|float * states('input_number.hp_energy_cost')|float + states('input_number.hp_daily_cost')|float)|round(2) }}"
        unit_of_measurement: €
  ###########################################
  ##Passer en euros par jour HC
  - platform: template
    sensors:
      hp_cost_today:
        friendly_name: "HC Cost Today"
        value_template: "{{ (states('sensor.energy_total_usage_daily_night')|float * states('input_number.hp_energy_cost')|float + states('input_number.hp_night_cost')|float)|round(2) }}"
        unit_of_measurement: €
  ###########################################
  ##Passer en euros par jour HP+HC
  - platform: template
    sensors:
      cost_today:
        friendly_name: "Cout du jour"
        value_template: "{{ (states('sensor.hp_cost_today')|float + states('sensor.hc_cost_today')|float)|round(2) }}"
        unit_of_measurement: €
############################################
############################################
############################################

#LES ENTRÉES

############################################
############################################
############################################
# Cout electricité
input_number:
  hp_daily_cost:
    name: HP - Cout journalier
    mode: box
    min: 0
    max: 100
    unit_of_measurement: "€/day"
    icon: mdi:currency-eur

  hp_energy_cost:
    name: HP - Coût du Kwh
    mode: box
    min: 0
    max: 100
    unit_of_measurement: "€/kWh"
    icon: mdi:currency-eur

  hc_daily_cost:
    name: HC - Cout journalier
    mode: box
    min: 0
    max: 100
    unit_of_measurement: "€/day"
    icon: mdi:currency-eur

  hc_energy_cost:
    name: HC - Coût du Kwh
    mode: box
    min: 0
    max: 100
    unit_of_measurement: "€/kWh"
    icon: mdi:currency-eur

  cumulative_energy_cost:
    name: Cumulative Energy Cost
    mode: box
    min: 0
    max: 5000
    unit_of_measurement: "€"
    icon: mdi:currency-eur

  yesterday_energy_cost:
    name: Yesterday Energy Cost
    mode: box
    min: 0
    max: 5000
    unit_of_measurement: "€"
    icon: mdi:currency-eur

############################################
############################################
############################################
############################################
############################################
############################################
############################################
############################################
############################################
############################################
############################################
############################################
# Text to speech

tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

Lorsqu’e je rentre les valeurs de ‹ input-number › ca modifie les sensor et…rien ne fonctionne.
:’(