Get EDF Tempo information

Hello
I discovered this huge API library on RTE website and no one seems to have integrated this in HA yet.
Can you tell how you manage to do OAUTH2 requests to RTE API in HomeAssistant ?
I have little to no knowledge about coding API calls, so RTE tutorial is of no help for getting it work with HA
Regards

Updated my code to remove device_class: date, as this now expects a python date object.

Hello, thanks all for contributions. Sorry i didn’t succeed to replace old “style” with new rest part ! it give error platform rest. what is the complete code to put on sensor file please !
Thanks a lot

code below didn’t work when i put it in an yaml file on the sensor folder.

  • resource_template: https://particulier.edf.fr/bin/edf_rc/servlets/ejptemponew?Date_a_remonter={{now().strftime("%Y-%m-%d")}}&TypeAlerte=TEMPO
    scan_interval: 3600
    headers:
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
    Content-Type: application/json
    User-Agent: Wget/1.20.3 (linux-gnu)
    sensor:

    • name: “edf_tempo_today”
      device_class: monetary
      value_template: >
      {% if value_json.JourJ.Tempo in [‘TEMPO_BLEU’,‘TEMPO_BLANC’,‘TEMPO_ROUGE’] %}
      {{ value_json.JourJ.Tempo |regex_replace(find=’^TEMPO_’, replace=’’) }}
      {% else %}
      unknown
      {% endif %}
    • name: “edf_tempo_tomorrow”
      device_class: monetary
      value_template: >
      {% if value_json.JourJ1.Tempo in [‘TEMPO_BLEU’,‘TEMPO_BLANC’,‘TEMPO_ROUGE’] %}
      {{ value_json.JourJ1.Tempo |regex_replace(find=’^TEMPO_’, replace=’’) }}
      {% else %}
      unknown
      {% endif %}
  • resource: https://particulier.edf.fr/bin/edf_rc/servlets/ejptempodaysnew?TypeAlerte=TEMPO
    scan_interval: 3600
    headers:
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
    Content-Type: application/json
    User-Agent: Wget/1.20.3 (linux-gnu)
    sensor:
    - name: edf_tempo_blue_remaining
    value_template: “{{ value_json.PARAM_NB_J_BLEU | int }}”
    unit_of_measurement: “d”
    - name: edf_tempo_white_remaining
    value_template: “{{ value_json.PARAM_NB_J_BLANC | int }}”
    unit_of_measurement: “d”
    - name: edf_tempo_red_remaining
    value_template: “{{ value_json.PARAM_NB_J_ROUGE | int }}”
    unit_of_measurement: “d”

  • resource_template: https://particulier.edf.fr/bin/edf_rc/servlets/ejptemponew?Date_a_remonter={{now().strftime("%Y-%m-%d")}}&TypeAlerte=TEMPO
    scan_interval: 3600
    headers:
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
    Content-Type: application/json
    User-Agent: Wget/1.20.3 (linux-gnu)
    sensor:

    • name: “edf_tempo_today”
      device_class: monetary
      value_template: >
      {% if value_json.JourJ.Tempo in [‘TEMPO_BLEU’,‘TEMPO_BLANC’,‘TEMPO_ROUGE’] %}
      {{ value_json.JourJ.Tempo |regex_replace(find=’^TEMPO_’, replace=’’) }}
      {% else %}
      unknown
      {% endif %}
    • name: “edf_tempo_tomorrow”
      device_class: monetary
      value_template: >
      {% if value_json.JourJ1.Tempo in [‘TEMPO_BLEU’,‘TEMPO_BLANC’,‘TEMPO_ROUGE’] %}
      {{ value_json.JourJ1.Tempo |regex_replace(find=’^TEMPO_’, replace=’’) }}
      {% else %}
      unknown
      {% endif %}
  • resource: https://particulier.edf.fr/bin/edf_rc/servlets/ejptempodaysnew?TypeAlerte=TEMPO
    scan_interval: 3600
    headers:
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
    Content-Type: application/json
    User-Agent: Wget/1.20.3 (linux-gnu)
    sensor:
    - name: edf_tempo_blue_remaining
    value_template: “{{ value_json.PARAM_NB_J_BLEU | int }}”
    unit_of_measurement: “d”
    - name: edf_tempo_white_remaining
    value_template: “{{ value_json.PARAM_NB_J_BLANC | int }}”
    unit_of_measurement: “d”
    - name: edf_tempo_red_remaining
    value_template: “{{ value_json.PARAM_NB_J_ROUGE | int }}”
    unit_of_measurement: “d”

Hello @Dartymath
It was the same for me, I was never able to transform my code with this lighter version.
So I kept what I did and just used regex_replace command to remove the “TEMPO_” text.
This is the code I’m actually use in sensor.yaml:

  - platform: rest
    name: 'Tempo Demain'
    resource_template: https://particulier.edf.fr/bin/edf_rc/servlets/ejptemponew?Date_a_remonter={{now().strftime("%Y-%m-%d")}}&TypeAlerte=TEMPO
    value_template: "{{ value_json.JourJ1.Tempo |regex_replace(find='^TEMPO_', replace='') }}"
    scan_interval: 3600
    headers:
      Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
      Content-Type: application/json
      User-Agent: Wget/1.20.3 (linux-gnu)
  - platform: rest
    name: "Tempo Aujourd'hui"
    resource_template: https://particulier.edf.fr/bin/edf_rc/servlets/ejptemponew?Date_a_remonter={{now().strftime("%Y-%m-%d")}}&TypeAlerte=TEMPO
    value_template: "{{ value_json['JourJ'].Tempo|regex_replace(find='^TEMPO_', replace='') }}"
    scan_interval: 3600
    headers:
      Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
      Content-Type: application/json
      User-Agent: Wget/1.20.3 (linux-gnu)

  - platform: rest
    name: 'Jours Rouge restants'
    resource: https://particulier.edf.fr/bin/edf_rc/servlets/ejptempodaysnew?TypeAlerte=TEMPO
    value_template: '{{ value_json.PARAM_NB_J_ROUGE }}'
    scan_interval: 3600
    headers:
      Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
      Content-Type: application/json
      User-Agent: Wget/1.20.3 (linux-gnu)
  - platform: rest
    name: 'Jours Blanc restants'
    resource: https://particulier.edf.fr/bin/edf_rc/servlets/ejptempodaysnew?TypeAlerte=TEMPO
    value_template: '{{ value_json.PARAM_NB_J_BLANC }}'
    scan_interval: 3600
    headers:
      Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
      Content-Type: application/json
      User-Agent: Wget/1.20.3 (linux-gnu)
  - platform: rest
    name: 'Jours Bleu restants'
    resource: https://particulier.edf.fr/bin/edf_rc/servlets/ejptempodaysnew?TypeAlerte=TEMPO
    value_template: '{{ value_json.PARAM_NB_J_BLEU }}'
    scan_interval: 3600
    headers:
      Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
      Content-Type: application/json
      User-Agent: Wget/1.20.3 (linux-gnu)

The scan interval is set to 3600 seconds and my IP was never banned from edf.fr site anymore.

1 Like

Thanks Patrice,
i just see that my Ip was ban this afternoon after only 5 hours !
How did you recover the possibility to connect to edf.fr ?
Thanks

If you don’t have a fixed IP, you may just restart your box to get a new IP. If it is fixed, you will have to wait few hours before you could get the service back.

Thanks Patrice, still blocked this morning i move to 14400s, will see if i recover access tomorrow ! Edf app also blocked now ! i have a fixed ip

Hello

The URL above give an error 404
https://particulier.edf.fr/bin/edf_rc/servlets/ejptemponew?Date_a_remonter=2022-06-11&TypeAlerte=TEMPO

The following seems to be working now:
https://particulier.edf.fr/services/rest/referentiel/searchTempoStore?dateRelevant=2022-6-11

1 Like

Hello jpty,

Thank you very much for the new working URL for Tempo.
Do you know if there is also the same alternative URL for EJP ?

For TEMPO, this is currently working for me :slight_smile:

Hello,
This is not the first year that the service has stopped working during the summer and then become available again.
I would recommend that you wait before making any changes.

Hi c4rr3r4

have you find a solution to integrate the RTE Api ?
can you share you code for the sensor and the display?
thank you

Here the last code I use :

configuration.yaml

rest: !include rest.yaml

rest.yaml

- resource_template: https://particulier.edf.fr/services/rest/referentiel/searchTempoStore?dateRelevant={{now().strftime("%Y-%m-%d")}}
  scan_interval: 3600
  sensor:
    - name: "Tempo Demain"
      value_template: "{{ value_json.couleurJourJ1 }}"
    - name: "Tempo Aujourd'hui"
      value_template: "{{ value_json.couleurJourJ }}"
- resource: https://particulier.edf.fr/services/rest/referentiel/getNbTempoDays?TypeAlerte=TEMPO
  scan_interval: 3600
  sensor:
    - name: "Jours Rouge restants"
      value_template: "{{ value_json.PARAM_NB_J_ROUGE }}"
    - name: "Jours Blanc restants"
      value_template: "{{ value_json.PARAM_NB_J_BLANC }}"
    - name: "Jours Bleu restants"
      value_template: "{{ value_json.PARAM_NB_J_BLEU }}"

Using rest in place of sensors permits to get all data from one API call.

5 Likes

Hi,
I would like to create an automation with this sensor. When it change from NON_DEFINI to BLEU or BLANC, I would do an action. The issue is I can’t put NON_DEFINI in the « FROM » box. Do you know why and what can I do ?

Thanks in advance

Hello Nouch77
I did this automation and it works fine for me. I received an alert on my mobile phone when the state moved from NON_DEFINI to BLEU.
Funilly enough, I forgot to put BLEU in the To: field, and I received the message, so you can do that if you just want to detect when the value change.
BR

great job, please can you share your template code? steplait, steplait…

Sorry for the delay, I did not received any notifications from the forum :thinking:

Documentation was buggy from v1.0.0 to v1.1.0, it has been fixed since :slight_smile:

For the refresh, it is a bit more complicated than that:

  • If the integration has the next day color, it goes to sleep until next day at 6am
  • If it does not have the next day color, it retries every 30 minutes
  • If anything went wrong (like API down or network issue) it is retried after 10 minutes

And each of these delays are a bit randomized to avoid everyone hammering the RTE API at the same time !

You can check the current implementation details here.

2 Likes

I just wanted to add that this article really helped me:

In my case, I don’t have anything connected to the Linky: I only have a Shelly EM reading imported and exported energy.

So to couple the prices with the RTE Tempo integration from @hekmon, I have created a bunch of entries:

First one input number for each combination of Color and HP / HC.

Then I have created a utility meter with 6 tariffs + TRV (this will auto-create 7 utility meters with a selector)

I can then create these cards to set prices and select the current utility meter where the read energy data will go:

But now, the magic is that thanks to the RTE Temp plugin, I can have a script and an automation that will automatically switch the right utility meter to use:

The script:

alias: "Grid: Energy Meter Selection"
sequence:
  - choose:
      - conditions:
          - condition: state
            entity_id: sensor.rte_tempo_couleur_actuelle
            state: Bleu
          - type: is_on
            condition: device
            device_id: 9c2a0444638b52b827cc51a274c5d1f9
            entity_id: binary_sensor.rte_tempo_heures_creuses
            domain: binary_sensor
        sequence:
          - service: select.select_option
            data:
              option: EDF Tempo Bleu HC
            target:
              entity_id: select.grid_energy_meter
      - conditions:
          - condition: state
            entity_id: sensor.rte_tempo_couleur_actuelle
            state: Bleu
          - type: is_off
            condition: device
            device_id: 9c2a0444638b52b827cc51a274c5d1f9
            entity_id: binary_sensor.rte_tempo_heures_creuses
            domain: binary_sensor
        sequence:
          - service: select.select_option
            data:
              option: EDF Tempo Bleu HP
            target:
              entity_id: select.grid_energy_meter
      - conditions:
          - condition: state
            entity_id: sensor.rte_tempo_couleur_actuelle
            state: Blanc
          - type: is_on
            condition: device
            device_id: 9c2a0444638b52b827cc51a274c5d1f9
            entity_id: binary_sensor.rte_tempo_heures_creuses
            domain: binary_sensor
        sequence:
          - service: select.select_option
            data:
              option: EDF Tempo Blanc HC
            target:
              entity_id: select.grid_energy_meter
      - conditions:
          - condition: state
            entity_id: sensor.rte_tempo_couleur_actuelle
            state: Blanc
          - type: is_off
            condition: device
            device_id: 9c2a0444638b52b827cc51a274c5d1f9
            entity_id: binary_sensor.rte_tempo_heures_creuses
            domain: binary_sensor
        sequence:
          - service: select.select_option
            data:
              option: EDF Tempo Blanc HP
            target:
              entity_id: select.grid_energy_meter
      - conditions:
          - condition: state
            entity_id: sensor.rte_tempo_couleur_actuelle
            state: Rouge
          - type: is_on
            condition: device
            device_id: 9c2a0444638b52b827cc51a274c5d1f9
            entity_id: binary_sensor.rte_tempo_heures_creuses
            domain: binary_sensor
        sequence:
          - service: select.select_option
            data:
              option: EDF Tempo Rouge HC
            target:
              entity_id: select.grid_energy_meter
      - conditions:
          - condition: state
            entity_id: sensor.rte_tempo_couleur_actuelle
            state: Rouge
          - type: is_off
            condition: device
            device_id: 9c2a0444638b52b827cc51a274c5d1f9
            entity_id: binary_sensor.rte_tempo_heures_creuses
            domain: binary_sensor
        sequence:
          - service: select.select_option
            data:
              option: EDF Tempo Rouge HP
            target:
              entity_id: select.grid_energy_meter
mode: single
icon: mdi:script-text

The automation:

alias: "Grid: Energy Meter Selection"
description: ""
trigger:
  - type: turned_on
    platform: device
    device_id: 9c2a0444638b52b827cc51a274c5d1f9
    entity_id: binary_sensor.rte_tempo_heures_creuses
    domain: binary_sensor
  - type: turned_off
    platform: device
    device_id: 9c2a0444638b52b827cc51a274c5d1f9
    entity_id: binary_sensor.rte_tempo_heures_creuses
    domain: binary_sensor
  - platform: state
    entity_id:
      - sensor.rte_tempo_couleur_actuelle
condition: []
action:
  - service: script.grid_energy_meter_selection
    data: {}
mode: single

Device ID 9c2a0444638b52b827cc51a274c5d1f9 is actually the RTE Tempo device created by the RTE Tempo integration.

Then in the Energy Dashboard, we need to add all the utility meters, and for each one, link it with the corresponding price entity

2 Likes

I am glad you got it working :blush:

1 Like

I was even not lazy enough to add the utility meters for weekly, monthly and yearly stats :wink: