Hello,
I see you showing here how to retrieve the electricity rate with Node-RED via the file: https://www.data.gouv.fr/fr/datasets/r/c13d05e5-9e55-4d03-bf7e-042a2ade7e49 and then transfer it to an MQTT topic to use it in Gladys ![]()
This file can be found here: https://www.data.gouv.fr/fr/datasets/historique-des-tarifs-reglementes-de-vente-delectricite-pour-les-consommateurs-residentiels/
This tutorial is compatible with the « Base » option only because it is the option associated with my contract ![]()
But I think it’s quite easy to set it up for the « Peak hours / Off-peak hours » option.
Final result:
![]()
Here is the Node-RED flow:
Here is the flow in JSON format to import into your Node-RED:
(The value is retrieved every night at 3:00 AM)
[
{
"id": "d6333988d9cfb817",
"type": "tab",
"label": "Flux - Coût EDF",
"disabled": false,
"info": "",
"env": []
},
{
"id": "d79ac3d249808c33",
"type": "mqtt out",
"z": "d6333988d9cfb817",
"name": "",
"topic": "gladys/master/device/mqtt:edf/feature/mqtt:cout-abonnement/state",
"qos": "2",
"retain": "true",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "0ee77e0f90aa9681",
"x": 830,
"y": 400,
"wires": []
},
{
"id": "1852e9b329fd3f44",
"type": "http request",
"z": "d6333988d9cfb817",
"name": "Download CSV",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "https://www.data.gouv.fr/fr/datasets/r/c13d05e5-9e55-4d03-bf7e-042a2ade7e49",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 240,
"y": 160,
"wires": [
[
"24804ed33b7a2cd6"
]
]
},
{
"id": "24804ed33b7a2cd6",
"type": "csv",
"z": "d6333988d9cfb817",
"name": "Conversion CSV en tableau",
"sep": ";",
"hdrin": true,
"hdrout": "none",
"multi": "mult",
"ret": "\\n",
"temp": "DATE_DEBUT;DATE_FIN;P_SOUSCRITE;PART_FIXE_HT;PART_FIXE_TTC;PART_VARIABLE_HT;PART_VARIABLE_TTC",
"skip": "0",
"strings": false,
"include_empty_strings": false,
"include_null_values": false,
"x": 400,
"y": 220,
"wires": [
[
"8576856348eb0e34"
]
]
},
{
"id": "8576856348eb0e34",
"type": "function",
"z": "d6333988d9cfb817",
"name": "Extraction de la plus recente PART_VARIABLE_TTC en fonction de P_SOUSCRITE",
"func": "// Filter data for P_SOUSCRITE = 6 and DATE_FIN missing or empty\\nmsg.payload = msg.payload.filter(item =\\u003e item.P_SOUSCRITE === \\\"6\\\" \\u0026\\u0026 (!item.DATE_FIN || item.DATE_FIN.trim() === \\\"\\\"));\\n\\n// Replace commas with dots in PART_VARIABLE_TTC values\\nmsg.payload = msg.payload.map(item =\\u003e {\\n // Replace commas with dots in the PART_VARIABLE_TTC value\\n item.PART_VARIABLE_TTC = item.PART_VARIABLE_TTC.replace(/,/g, '.');\\n // Convert PART_VARIABLE_TTC to a number\\n item.PART_VARIABLE_TTC = parseFloat(item.PART_VARIABLE_TTC);\\n return item.PART_VARIABLE_TTC;\\n});\\nreturn msg;\\n\\n",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 630,
"y": 280,
"wires": [
[
"644a3870177af55a"
]
]
},
{
"id": "644a3870177af55a",
"type": "function",
"z": "d6333988d9cfb817",
"name": "Convertion en nombre",
"func": "msg.payload = parseFloat(msg.payload);\\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 600,
"y": 340,
"wires": [
[
"d79ac3d249808c33"
]
]
},
{
"id": "1943b35881c8a2fa",
"type": "cronplus",
"z": "d6333988d9cfb817",
"name": "Cron daily",
"outputField": "payload",
"timeZone": "",
"storeName": "",
"commandResponseMsgOutput": "output1",
"defaultLocation": "",
"defaultLocationType": "default",
"outputs": 1,
"options": [
{
"name": "schedule1",
"topic": "topic1",
"payloadType": "default",
"payload": "",
"expressionType": "cron",
"expression": "0 0 01 * * *",
"location": "",
"offset": "0",
"solarType": "all",
"solarEvents": "sunrise,sunset"
}
],
"x": 140,
"y": 100,
"wires": [
[
"1852e9b329fd3f44"
]
]
},
{
"id": "670838a9edef0758",
"type": "catch",
"z": "d6333988d9cfb817",
"name": "Erreurs",
"scope": null,
"uncaught": false,
"x": 110,
"y": 60,
"wires": [
[
"c097dad994334b5e"
]
]
},
{
"id": "c097dad994334b5e",
"type": "e-mail",
"z": "d6333988d9cfb817",
"server": "monsmtp.a.remplacer",
"port": "465",
"authtype": "BASIC",
"saslformat": false,
"token": "oauth2Response.access_token",
"secure": true,
"tls": true,
"name": "aremplacer@monmail.fr",
"dname": "Mail",
"x": 250,
"y": 60,
"wires": []
},
{
"id": "0ee77e0f90aa9681",
"type": "mqtt-broker",
"name": "Gladys",
"broker": "mqtt://192.168.x.x",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"autoUnsubscribe": true,
"birthTopic": "",
"birthQos": "0",
"birthRetain": "false",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closeRetain": "false",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willRetain": "false",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
}
]
Be sure to modify the value of P_SOUSCRITE in the function “Extraction de la plus recente PART_VARIABLE_TTC en fonction de P_SOUSCRITE”
And also the IP address of your MQTT broker
Here is the MQTT device with the feature:
If you have any questions/comments, feel free to let me know ![]()
Changelog to come:
- None (Waiting for your feedback
)
Edit 23/04/2024 :
- Added screenshots for the MQTT device
- Added a catch-all for error handling and to be notified by e-mail


