How to decode special JSON ? Ex => "conso_hc" : 006699756,

Thank you so much for sharing this.
I have updated a lit bit your code.
You call 5 times the rest service te get “Puissances Instantanées”.
You could do it only once, and so get them more often.

Here is an example :

sensor:
  - platform: rest
    resource: !secret Legrand_Source_Instantanes
    value_template: "{{ value_json.Date_Time }}"
    name: legrand_source_instantanes
    scan_interval: 5
    json_attributes:
      - data1
      - data2
      - data3
      - data4
      - data5

  - platform: template
    sensors:
      legrand_data1:
        value_template: >
          {{ state_attr('sensor.legrand_source_instantanes','data1') | round(0) }}
        device_class: power
        unit_of_measurement: W
        friendly_name: "Legrand Puissance Data1"
      legrand_data2:
        value_template: >
          {{ state_attr('sensor.legrand_source_instantanes','data2') | round(0) }}
        device_class: power
        unit_of_measurement: W
        friendly_name: "Legrand Puissance Data2"
      legrand_data3:
        value_template: >
          {{ state_attr('sensor.legrand_source_instantanes','data3') | round(0) }}
        device_class: power
        unit_of_measurement: W
        friendly_name: "Legrand Puissance Data3"
      legrand_data4:
        value_template: >
          {{ state_attr('sensor.legrand_source_instantanes','data4') | round(0) }}
        device_class: power
        unit_of_measurement: W
        friendly_name: "Legrand Puissance Data4"
      legrand_data5:
        value_template: >
          {{ state_attr('sensor.legrand_source_instantanes','data5') | round(0) }}
        device_class: power
        unit_of_measurement: W
        friendly_name: "Legrand Puissance Data5"
2 Likes

hello,
first of all I would like to thank you for your work on the eco-counter and your code sharing for HA.
I am a beginner, so please be indulgent …
your code works fine if i copy / paste package_legrand.yaml directly to configuration.yaml. My problem is that I can not create a line of code to call a package or other, I always have errors “because” of your code too complicated for me;). I do not know how you did it but if you can help me even if it is not too related to the eco-meter.
Thanking you in advance and sorry for the translation

Hi @JBHA1,

Everyone must have started one day so no problem.

Well instead of adding this code directly into the configuration.yaml file you can just put this into :

packages: !include_dir_named packages

Then create a folder ‘packages’ in your root folder and put inside a file ‘package_legrand.yaml’ with his code.

If you want more exemples you can read this : Packages - Home Assistant

Good luck

Hello,
thank you for your comeback. indeed, I had already tried to do as you described it to me … but I got a message "integration error: packages - intregration ‘packages not found’ ‘. I added’ home assistant 'above line and nothing found on Google … Sorry to bother you with my little bugs and thank you for helping me.

Bonjour Maxtonne66 j’ai utilisé ton script pour la gestion de l’éco compteur et te remercie pour le travail effectué !!!
J’ai une subtilité chez moi je suis en offre TEMPO avec 6 tarifs différents et là du coup toutes les formules de calcul ne fonctionnent plus.

Offre Tempo=6 tarifs
Heures pleines bleu
Heures creuses bleu
Heures pleines blanc
Heures creuses blanc
Heures pleines rouge
Heure creuses rouge

Si tu pouvais m’aider (ainsi que la communauté car cette offre revient à la mode)

Merci à toi

Hi @maxtone66
Is it your last version of the scripts ?
Did you take into account the suggested optimisation ?
Is there any code for the dashboard ?
Thank you for you help.
Lyes

Hi @ablyes
I don’t use this device for over 2 years since I sold the house, so I won’t be helpful.
I use HA now in an RV.
Maybe you’ll get an answer from someone else who still uses it…
Good luck