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)

Hi,

Do you have the same for EJP ?

Merci :slight_smile:

Bonjour Lionel,
It is quite similar. On the url, if you replace TypeAlerte=TEMPO by TypeAlerte=EJP, you will get this result

As you can see, you will have to choose your region in the result. In my example I choose EjpSud so the code you have to add in configuration.yaml is this one

  - platform: command_line
    name: edfEJPTomorrow
    command: curl -A "'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0' '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 }}"

  - platform: command_line
    name: edfEJP
    command: curl -A "'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0' '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 }}"  

Et voila le résultat :slight_smile:

Now you need to add these lines in customize.yaml file to replace the variable name by “Aujourd’hui” and “Demain”

sensor.edfEJP:
   friendly_name: Aujourd’hui
sensor.edfEJPtomorrow:
   friendly_name: Demain
- 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