Commit 9d1d1821 authored by Jaxom's avatar Jaxom
Browse files

Nodes version 4

parent 04cb2238
[
{
"id": "4e190166.121e28",
"type": "tab",
"label": "DataConnect Auth-Token",
"disabled": false,
"info": ""
},
{
"id": "ce910788.3497c",
"type": "tab",
"label": "DataConnect Metering Data",
"disabled": false,
"info": ""
},
{
"id": "1f19d480.92fc74",
"type": "ui_tab",
"z": "",
"name": "DataConnect-Proto",
"icon": "fa-fire",
"order": 1,
"disabled": false,
"hidden": false
},
{
"id": "8448d19a.8ec28",
"type": "ui_group",
"z": "",
"name": "Inputs",
"tab": "1f19d480.92fc74",
"order": 2,
"disp": true,
"width": "12",
"collapse": false
},
{
"id": "66d80aab.85fa1c",
"type": "ui_base",
"theme": {
"name": "theme-light",
"lightTheme": {
"default": "#0094CE",
"baseColor": "#0094CE",
"baseFont": "-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif",
"edited": true,
"reset": false
},
"darkTheme": {
"default": "#097479",
"baseColor": "#097479",
"baseFont": "-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif",
"edited": true,
"reset": false
},
"customTheme": {
"name": "Untitled Theme 1",
"default": "#4B7930",
"baseColor": "#4B7930",
"baseFont": "-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"
},
"themeState": {
"base-color": {
"default": "#0094CE",
"value": "#0094CE",
"edited": false
},
"page-titlebar-backgroundColor": {
"value": "#0094CE",
"edited": false
},
"page-backgroundColor": {
"value": "#fafafa",
"edited": false
},
"page-sidebar-backgroundColor": {
"value": "#ffffff",
"edited": false
},
"group-textColor": {
"value": "#1bbfff",
"edited": false
},
"group-borderColor": {
"value": "#ffffff",
"edited": false
},
"group-backgroundColor": {
"value": "#ffffff",
"edited": false
},
"widget-textColor": {
"value": "#111111",
"edited": false
},
"widget-backgroundColor": {
"value": "#0094ce",
"edited": false
},
"widget-borderColor": {
"value": "#ffffff",
"edited": false
},
"base-font": {
"value": "-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"
}
},
"angularTheme": {
"primary": "indigo",
"accents": "blue",
"warn": "red",
"background": "grey"
}
},
"site": {
"name": "Node-RED Dashboard",
"hideToolbar": "false",
"allowSwipe": "true",
"lockMenu": "true",
"allowTempTheme": "true",
"dateFormat": "DD/MM/YYYY",
"sizes": {
"sx": 48,
"sy": 48,
"gx": 6,
"gy": 6,
"cx": 6,
"cy": 6,
"px": 0,
"py": 0
}
}
},
{
"id": "3350c8e.cd02338",
"type": "ui_group",
"z": "",
"name": "Auth Token",
"tab": "1f19d480.92fc74",
"order": 1,
"disp": true,
"width": "12",
"collapse": true
},
{
"id": "6fe02ac5.5bbff4",
"type": "ui_group",
"z": "",
"name": "Courbes",
"tab": "1f19d480.92fc74",
"order": 3,
"disp": true,
"width": "24",
"collapse": false
},
{
"id": "d006e09f.b7eb4",
"type": "ui_spacer",
"name": "spacer",
"group": "3350c8e.cd02338",
"order": 2,
"width": "12",
"height": "2"
},
{
"id": "f0824586.ce1b38",
"type": "function",
"z": "4e190166.121e28",
"name": "IDENTIFIANTS",
"func": "global.set(\"client_id\",\"CHANGEME\");\nglobal.set(\"client_secret\",\"CHANGEME\");\nglobal.set(\"redirect_uri\",\"CHANGEME\");\n\n\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 290,
"y": 45,
"wires": [
[]
]
},
{
"id": "193e6967.e32ba7",
"type": "inject",
"z": "4e190166.121e28",
"name": "Init",
"topic": "",
"payload": " vide",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"x": 100,
"y": 45,
"wires": [
[
"f0824586.ce1b38",
"a4aa882f.a44f8"
]
]
},
{
"id": "71a7788a.270858",
"type": "http request",
"z": "4e190166.121e28",
"name": "AuthCode",
"method": "GET",
"ret": "txt",
"paytoqs": false,
"url": "",
"tls": "",
"proxy": "",
"authType": "basic",
"x": 105,
"y": 420,
"wires": [
[
"350b0f9b.62adb"
]
]
},
{
"id": "350b0f9b.62adb",
"type": "split",
"z": "4e190166.121e28",
"name": "",
"splt": ";",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 290,
"y": 420,
"wires": [
[
"95c801ec.5b6f7"
]
]
},
{
"id": "95c801ec.5b6f7",
"type": "function",
"z": "4e190166.121e28",
"name": "Recup_Code_et_UP",
"func": "regex = new RegExp(global.get(\"redirect_uri\"),'g');\n\nif (msg.payload.match(regex)) {\n\n chaine = msg.payload.split(\"=\");\n code = chaine[2].split(\"&\");\n global.set(\"code\",code[0]);\n up_id = chaine[4].split('\"')[0];\n global.set(\"up_id\",up_id);\n \n return { payload : code[0], \"up_id\" : up_id };\n \n} \n\nelse {return 0;}",
"outputs": 1,
"noerr": 0,
"x": 550,
"y": 420,
"wires": [
[
"5e8217b4.f724a"
]
],
"info": "Ce bloc récupère les paramètres complémentaires d'authentification, qui sont renvoyés par l'API DataConnect dans une requête GET."
},
{
"id": "69eb392.1ade7c8",
"type": "http request",
"z": "4e190166.121e28",
"name": "AuthToken",
"method": "POST",
"ret": "txt",
"paytoqs": false,
"url": "",
"tls": "",
"proxy": "",
"authType": "basic",
"x": 520,
"y": 495,
"wires": [
[
"d5362a0f.fc7f2",
"559feee8.4184f"
]
]
},
{
"id": "5e8217b4.f724a",
"type": "function",
"z": "4e190166.121e28",
"name": "Headers POST",
"func": "msg.headers = {};\nmsg.headers['Content-Type'] = 'application/x-www-form-urlencoded';\nmsg.headers['accept'] = 'text/html';\n\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 125,
"y": 495,
"wires": [
[
"be24459e.16c428"
]
]
},
{
"id": "559feee8.4184f",
"type": "debug",
"z": "4e190166.121e28",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 815,
"y": 510,
"wires": []
},
{
"id": "be24459e.16c428",
"type": "function",
"z": "4e190166.121e28",
"name": "URL+Data",
"func": "\n\nmsg.url={}\nmsg.url = \"https://gw.hml.api.enedis.fr/v1/oauth2/token?redirect_uri=\"+global.get(\"redirect_uri\");\n\nmsg.payload = \"grant_type=authorization_code&client_id=\"+global.get(\"client_id\")+\"&client_secret=\"+global.get(\"client_secret\")+\"&code=\"+msg.payload;\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 310,
"y": 495,
"wires": [
[
"69eb392.1ade7c8"
]
]
},
{
"id": "1d17f313.6f768d",
"type": "http request",
"z": "ce910788.3497c",
"name": "Requete DataConnect",
"method": "GET",
"ret": "obj",
"paytoqs": false,
"url": "",
"tls": "",
"proxy": "",
"authType": "basic",
"x": 145,
"y": 300,
"wires": [
[
"56757e3f.0e9ee",
"6ed7e8fa.bba13",
"d90b29cd.9a1f5"
]
]
},
{
"id": "8d74cd01.096ec",
"type": "ui_chart",
"z": "ce910788.3497c",
"name": "",
"group": "6fe02ac5.5bbff4",
"order": 3,
"width": 0,
"height": 0,
"label": "Courbes",
"chartType": "line",
"legend": "true",
"xformat": "auto",
"interpolate": "linear",
"nodata": "lancez une requête...",
"dot": true,
"ymin": "",
"ymax": "",
"removeOlder": 1,
"removeOlderPoints": "",
"removeOlderUnit": "3600",
"cutout": 0,
"useOneColor": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"useOldStyle": false,
"outputs": 1,
"x": 570,
"y": 375,
"wires": [
[
"6ed7e8fa.bba13"
]
]
},
{
"id": "d5362a0f.fc7f2",
"type": "json",
"z": "4e190166.121e28",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 95,
"y": 570,
"wires": [
[
"6e073dda.206c7c"
]
]
},
{
"id": "6e073dda.206c7c",
"type": "function",
"z": "4e190166.121e28",
"name": "Global_Token",
"func": "global.set(\"refresh_token\",msg.payload.refresh_token);\nglobal.set(\"access_token\",msg.payload.access_token);\n\nreturn {payload : \"OK\"};",
"outputs": 1,
"noerr": 0,
"x": 320,
"y": 570,
"wires": [
[
"a4aa882f.a44f8"
]
]
},
{
"id": "c16cf9d8.77c76",
"type": "ui_button",
"z": "ce910788.3497c",
"name": "",
"group": "8448d19a.8ec28",
"order": 4,
"width": 0,
"height": 0,
"passthru": false,
"label": "Requete Courbes",
"tooltip": "",
"color": "",
"bgcolor": "",
"icon": "fa-cogs",
"payload": "Requête...",
"payloadType": "str",
"topic": "",
"x": 135,
"y": 240,
"wires": [
[
"258a405b.f3814",
"b06f4b43.e3755"
]
]
},
{
"id": "258a405b.f3814",
"type": "function",
"z": "ce910788.3497c",
"name": "URL+token",
"func": "msg.url = \"https://gw.hml.api.enedis.fr/v4/metering_data/\"+flow.get(\"requete\");\nmsg.url += \"?start=\"+flow.get(\"start\")+\"&end=\"+flow.get(\"end\")+\"&usage_point_id=\"+global.get(\"up_id\");\n\nmsg.headers = {} ;\nmsg.headers[\"Accept\"] = \"application/json\";\nmsg.headers[\"Authorization\"] = \"Bearer \"+ global.get(\"access_token\");\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 370,
"y": 240,
"wires": [
[
"1d17f313.6f768d"
]
]
},
{
"id": "6ed7e8fa.bba13",
"type": "debug",
"z": "ce910788.3497c",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 800,
"y": 375,
"wires": []
},
{
"id": "172e4748.571b89",
"type": "ui_date_picker",
"z": "ce910788.3497c",
"name": "",
"label": "Start",
"group": "8448d19a.8ec28",
"order": 1,
"width": 0,
"height": 0,
"passthru": false,
"topic": "",
"x": 245,
"y": 45,
"wires": [
[
"ce0c3659.b7a67"
]
]
},
{
"id": "ea05fb71.b37338",
"type": "ui_date_picker",
"z": "ce910788.3497c",
"name": "",
"label": "End",
"group": "8448d19a.8ec28",
"order": 2,
"width": 0,
"height": 0,
"passthru": true,
"topic": "",
"x": 245,
"y": 90,
"wires": [
[
"a51324b3.9e71f8"
]
]
},
{
"id": "ce0c3659.b7a67",
"type": "function",
"z": "ce910788.3497c",
"name": "setStartDate",
"func": "\nstart = new Date(msg.payload);\nstart = start.toISOString().slice(0,10);\nflow.set(\"start\", start)\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 415,
"y": 45,
"wires": [
[]
]
},
{
"id": "a51324b3.9e71f8",
"type": "function",
"z": "ce910788.3497c",
"name": "setEndDate",
"func": "\nend = new Date(msg.payload);\nend = end.toISOString().slice(0,10);\nflow.set(\"end\", end)\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 415,
"y": 90,
"wires": [
[]
]
},
{
"id": "5d01c454.4cb734",
"type": "inject",
"z": "ce910788.3497c",
"name": "ClearChart",
"topic": "",
"payload": "vide",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"x": 130,
"y": 465,
"wires": [
[
"3df2e104.f858e6",
"b06f4b43.e3755"
]
]
},
{
"id": "a6c2badb.c1e018",
"type": "ui_button",
"z": "4e190166.121e28",
"name": "",
"group": "3350c8e.cd02338",
"order": 3,
"width": "6",
"height": "1",
"passthru": false,
"label": "Demande Token",
"tooltip": "",
"color": "",
"bgcolor": "",
"icon": "",
"payload": "Demande...",
"payloadType": "str",
"topic": "",
"x": 125,