Get EDF Tempo information

Previously I was using information coming from this site to know the color of the day and the color for tomorrow http://domogeek.entropialux.com/tempoedf/now/json (French electricity provider EDF, that offering six level of costs depending on three colors, Blue, White and Red)

The link http://domogeek.entropialux.com/tempoedf/now/json is not working anymore so I tried another solution.

We can get information on EDF site in JSON format https://particulier.edf.fr/bin/edf_rc/servlets/ejptemponew?Date_a_remonter=2019-10-28&TypeAlerte=TEMPO

this is the sensors I added in configuration.yaml

sensor:


- platform: rest
    name: 'edfTempoTomorrow'
    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 }}'
    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: 'edfTempo'
    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 }}"
    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)

2 Likes

Hi,

Do you have the same for EJP ?

Merci :slight_smile:

- platform: rest
      name: 'EdF : EJP : Jours restants'
      resource: https://particulier.edf.fr/services/rest/referentiel/historicEJPStore?searchType=ejp
      value_template: '{{ 22 - value_json.SUD.TotalCurrentPeriod }}'
      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)

Thank you.
Found in the meantime. And even added the number of days remaining in EJP.

I have compiled some info on HA in French here:


1 Like

Hello,

I follow yours instructions with the following code in my configuration yaml file, but I get a status “unknown” with the sensors.
My URL is correct because I get a result directly with my browser.

Anything else to do ? I’m a newbie with HA.

sensor:

Thanks
=Theodine=

Hello Theodine
It looks like curl command is not working anymore.
You have to use rest instead.
You can replace the code with this


- platform: rest
    name: 'edfTempoTomorrow'
    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 }}'
    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: 'edfTempo'
    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 }}"
    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)

Merci for your speedy response.

it’s work fine.

=Theodine=

@PatriceL It seems that our friends EDF are having fun
 Could you give us the right code for EJP please?

today
tomorrow
days remaining

I think it will help a lot of people :slight_smile:

Thank you!

Tu as raison @Canaletto it is time to start from scratch.

So in France, our electricity supplier EDF offers us various contracts and two of them are called EJP or Tempo. The prices are not the same according to the color for the Tempo contract and the EJP days for the contract with the same name.
We are informed the day before of the color of the next day and for the most expensive days (Red or EJP) we must use an alternative heating solution in order to limit our consumption.
This information is available on the supplier’s website in JSON format and here is the result in Home Assistant

Her you can get the code to include into configuration.yaml file in sensor: part

TEMPO VERSION

  - 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 }}'
    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 }}"
    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 }}'
    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 }}'
    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 }}'
    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)

Then, after restarting HA, you could add an “Entities” card like this:

EJP VERSION

  - platform: rest
    name: "EJP Aujourd'hui"
    resource_template: https://particulier.edf.fr/bin/edf_rc/servlets/ejptemponew?Date_a_remonter={{now().strftime("%Y-%m-%d")}}&TypeAlerte=EJP
    value_template: '{{ value_json.JourJ.EjpSud }}'
    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: 'EJP Demain'
    resource_template: https://particulier.edf.fr/bin/edf_rc/servlets/ejptemponew?Date_a_remonter={{now().strftime("%Y-%m-%d")}}&TypeAlerte=EJP
    value_template: "{{ value_json['JourJ1'].EjpSud }}"
    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 restants'
    resource: https://particulier.edf.fr/services/rest/referentiel/historicEJPStore?searchType=ejp
    value_template: '{{ 22 - value_json.SUD.TotalCurrentPeriod }}'
    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)

This example works for the South region and you should modify it to suit your region.
Then, after restarting HA, you could add an “Entities” card like this:

Personally, I have a Tempo contract and I thank Lionel for the information he added regarding EJP.
Hope this example helps you

1 Like

Thank you Patrice!

We can add this to make a binary


- platform: template
  sensors:
    ejp_on:
      friendly_name: "Edf : EJP"
      value_template: "{{ is_state('sensor.ejp_aujourd_hui', 'EST_EJP') }}"
      device_class: power   
      icon_template: >
        {% if is_state('binary_sensor.ejp_on','on') %} 
          mdi:alert
          red
        {% else %} 
          mdi:sleep
        {% endif %}
#        icon_color: >
#           if (state === 'on') return 'red';
#           return 'green';

- platform: template
  sensors:
    ejp_on_demain:
      friendly_name: "EdF : EJP Demain"
      value_template: "{{ is_state('sensor.ejp_demain', 'EST_EJP') }}"
      device_class: power   
      icon_template: >
        {% if is_state('binary_sensor.ejp_on_demain','on') %} 
          mdi:alert
          red
        {% else %} 
          mdi:sleep
        {% endif %}

If you don’t see any inconveniences, I’m going to do a cc on my blog in french.

Thank you for your tip, I will see how to adapt it to Tempo.

Please feel free to link it to your blog

The EJP alert SMS is received between 1 and 2 p.m. .
So tomorrow is EJP and it doesn’t appear on HA, when is the status updated?

I have no ideas. Information has been updated for EJP after 16:00, it maybe this time.
Let’s see tomorrow

Hello,
only for Tempo contract, you can find an other API here : https://data.rte-france.com/catalog/-/api/consumption/Tempo-Like-Supply-Contract/v1.1
You have to create an account to have an Apikey and the color information is available every day at 10h40.
You can have today and tomorrow colors, the resumĂ© of each colors count and a full calendar over 1 year with every day’s color (you can filter dates with 1 year data max).

An example of their presentation :

If I have some time, I will reproduce that in a sensor :+1:

And the calendar :

Hello c4rr3r4,
I didn’t know this API+. It looks very useful !
Can you share the code you wrote to display your example, please ?
image

Salut, merci pour les exemples :slight_smile:

So I tried to update the above to what seems considered “modern syntax”. It’s a bit hard to make it look like what I want, and the documentation is inconsistent.

The following can go in a rest: block. Don’t forget the rest: part.

- 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"

(edit: I improved it a bit by forcing int, and detecting unknown states)

That seems to be working, but I can’t use unique_ids. I am not sure using a modern-syntax templated rest sensor is really better, but at least the version above also reduces the number of requests to one per endpoint.

Custom user-friendly names can be given trough the customization interface.

Doing only two requests was also possible with the old API, here’s one of my drafts:

Former approach with an older syntax, untested work-in-progress
- platform: rest
  #name: EDF_TEMPO_report_daily
  resource_template: https://particulier.edf.fr/bin/edf_rc/servlets/ejptemponew?Date_a_remonter={{now().strftime("%Y-%m-%d")}}&TypeAlerte=TEMPO
  json_attributes:
    - JourJ1
    - JourJ
  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: EDF_TEMPO_report_remaining
  resource: https://particulier.edf.fr/bin/edf_rc/servlets/ejptempodaysnew?TypeAlerte=TEMPO
  scan_interval: 3600
  json_attributes:
    - PARAM_NB_J_ROUGE
    - PARAM_NB_J_BLANC
    - PARAM_NB_J_BLEU
  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: template
  - sensor:
    name: today
    state: >
          {% if is_state('EDF_TEMPO_report_daily', 'TEMPO_BLEU') %}
            BLEU
          {% elif is_state('EDF_TEMPO_report_daily', 'TEMPO_BLANC') %}
            BLANC
          {% elif is_state('EDF_TEMPO_report_daily', 'TEMPO_ROUGE') %}
            ROUGE
          {% else %}
            INCONNU
          {% endif %}
  - sensor:
    unique_id: blue_remaining
    state: "{{ state_attr('sensor.EDF_TEMPO_report_daily', 'PARAM_NB_J_BLEU') }}"
    name: "Jours Bleus Restant"
    unit_of_measurement: "d"
  - sensor:
    unique_id: white_remaining
    state: "{{ state_attr('sensor.EDF_TEMPO_report_daily', 'PARAM_NB_J_BLANC') }}"
    name: "Jours Blancs Restant"
    unit_of_measurement: "d"
  - sensor:
    unique_id: red_remaining
    state: "{{ state_attr('sensor.EDF_TEMPO_report_daily', 'PARAM_NB_J_ROUGE') }}"
    friendly_name: "Jours Rouges Restant"
    name: "d"
1 Like

Thank you for the coding lesson. Yes, it reduces the number of requests, and this is a good point and it is also cleaner for reading.
I will use this example to modernize my syntax. :wink:

Dear @c4rr3r4,

can you share you code for the sensor and the display?

thank you
regards

Hello.

I have succeed to retreive the TEMPO day :

https://data.rte-france.com/catalog/-/api/consumption/Tempo-Like-Supply-Contract/v1.1#

FAQ - API Data RTE and especially the PDF.

basically two steps : retreive the OATH token, the use it on the TEMPO api. As a reminder TEMPO days are set by RTE, not EDF.
I will try to reuse existing code to make it work with this API

1 Like