Crear un dispositivo virtual de la siguiente manera en Gladys en la integración MQTT
Con las siguientes funcionalidades
Importar este flujo en node-red
Código del flujo
[
{
"id": "2b792c822e8e46f1",
"type": "tab",
"label": "TEMPO EDF",
"disabled": false,
"info": "",
"env": []
},
{
"id": "42d67acc049f7425",
"type": "group",
"z": "2b792c822e8e46f1",
"name": "TEMPO EDF",
"style": {
"stroke": "#000000",
"fill": "#bfdbef",
"label": true,
"label-position": "n",
"color": "#000000"
},
"nodes": [
"3d684dcab20a9914",
"3645d0bfbb46151e",
"967e5501fcd58cdd",
"71a73d70ed628528",
"e87b67de861c3256",
"50e0c479b04cb23c",
"418c3a4174d195aa",
"e89633a377e594b8",
"0de6bf94f39e7f8b"
],
"x": 74,
"y": 39,
"w": 1052,
"h": 262
},
{
"id": "02e46bae52d39d3b",
"type": "group",
"z": "2b792c822e8e46f1",
"name": "TEMPO EDF - Nb Jours Blanc Rouge Bleu",
"style": {
"stroke": "#000000",
"fill": "#bfdbef",
"label": true,
"label-position": "n",
"color": "#000000"
},
"nodes": [
"c930bd12d3f44d91",
"9c8bd280de70d67b",
"590aa4f85a232830",
"6d3c60cbfc8197ad",
"4c96ef17847a98b3",
"25f4c2d57f2b9c3d",
"341b7ddd6a3eb996",
"25b74b7de9880f61",
"6c60d01b69c8beda"
],
"x": 74,
"y": 319,
"w": 1052,
"h": 262
},
{
"id": "3d684dcab20a9914",
"type": "inject",
"z": "2b792c822e8e46f1",
"g": "42d67acc049f7425",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "01 13 * * *",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 190,
"y": 80,
"wires": [
[
"3645d0bfbb46151e"
]
]
},
{
"id": "3645d0bfbb46151e",
"type": "function",
"z": "2b792c822e8e46f1",
"g": "42d67acc049f7425",
"name": "Generar fecha",
"func": "const date = new Date();\n\nlet day = date.getDate();\nlet month = date.getMonth() + 1;\nlet year = date.getFullYear();\n\nlet currentDate = `${year}-${month}-${day}`;\n\nmsg.query = currentDate;\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 190,
"y": 140,
"wires": [
[
"967e5501fcd58cdd"
]
]
},
{
"id": "967e5501fcd58cdd",
"type": "http request",
"z": "2b792c822e8e46f1",
"g": "42d67acc049f7425",
"name": "Color_TEMPO",
"method": "GET",
"ret": "obj",
"paytoqs": "ignore",
"url": "https://particulier.edf.fr/services/rest/referentiel/searchTempoStore?dateRelevant={{{query}}}",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 210,
"y": 200,
"wires": [
[
"e87b67de861c3256",
"418c3a4174d195aa",
"e89633a377e594b8",
"0de6bf94f39e7f8b"
]
]
},
{
"id": "71a73d70ed628528",
"type": "debug",
"z": "2b792c822e8e46f1",
"g": "42d67acc049f7425",
"name": "debug 2",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 940,
"y": 140,
"wires": []
},
{
"id": "e87b67de861c3256",
"type": "debug",
"z": "2b792c822e8e46f1",
"g": "42d67acc049f7425",
"name": "debug 1",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 420,
"y": 80,
"wires": []
},
{
"id": "50e0c479b04cb23c",
"type": "mqtt out",
"z": "2b792c822e8e46f1",
"g": "42d67acc049f7425",
"name": "Broker Mqtt IP Gladys:1883",
"topic": "",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "f4ab211ed11dc81c",
"x": 980,
"y": 200,
"wires": []
},
{
"id": "418c3a4174d195aa",
"type": "function",
"z": "2b792c822e8e46f1",
"g": "42d67acc049f7425",
"name": "Enviar TEMPO JOURJ1 => Gladys:MAÑANA ...",
"func": "var tempo = msg.payload.couleurJourJ1;\n\n// ** Inicio de bloque ************************************************************************************************\n\n// Nombre de los dispositivos dados en Gladys\nvar nomAppareilGladys = \"TEMPO-EDF\"; // nombre del dispositivo en Gladys\nvar nomIdAppareilGladys = \"DEMAIN\"; // nombre del ID externo de la funcionalidad\n\n// Valor del tema y carga útil para enviar a Gladys\n// gladys/master/device/mqtt:\" TEMPO-EDF /feature/mqtt:\" JOUR /text\nmsg.topic = \"gladys/master/device/mqtt:\" + nomAppareilGladys + \"/feature/mqtt:\" + nomIdAppareilGladys + \"/text\";\n\n// Cambia la carga útil de salida según el valor de la carga útil enviada por EDF\nif (tempo === \"TEMPO_BLEU\") {\n msg.payload = \"TEMPO AZUL\";\n node.status({ fill: \"blue\", shape: \"ring\", text: tempo });\n}\nif (tempo === \"TEMPO_BLANC\") {\n msg.payload = \"TEMPO BLANCO\";\n node.status({ fill: \"white\", shape: \"ring\", text: tempo });\n}\n\nif (tempo === \"TEMPO_ROUGE\") {\n msg.payload = \"TEMPO ROJO\";\n node.status({ fill: \"red\", shape: \"ring\", text: tempo });\n}\n\nif (tempo === \"NON_DEFINI\") {\n msg.payload = \"NOM DEFINI\";\n node.status({ fill: \"grey\", shape: \"ring\", text: tempo });\n}\n\n// ** Fin de bloque ************************************************************************************************\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 540,
"y": 200,
"wires": [
[
"50e0c479b04cb23c",
"71a73d70ed628528"
]
]
},
{
"id": "e89633a377e594b8",
"type": "function",
"z": "2b792c822e8e46f1",
"g": "42d67acc049f7425",
"name": "Enviar TEMPO JOURJ => Gladys:DÍA ....",
"func": "var tempo = msg.payload.couleurJourJ;\n\n// ** Inicio de bloque ************************************************************************************************\n\n// Nombre de los dispositivos dados en Gladys\nvar nomAppareilGladys = \"TEMPO-EDF\"; // nombre del dispositivo en Gladys\nvar nomIdAppareilGladys = \"JOUR\"; // nombre del ID externo de la funcionalidad\n\n// Valor del tema y carga útil para enviar a Gladys\n// gladys/master/device/mqtt:\" TEMPO-EDF /feature/mqtt:\" JOUR /text\nmsg.topic = \"gladys/master/device/mqtt:\" + nomAppareilGladys + \"/feature/mqtt:\" + nomIdAppareilGladys + \"/text\";\n\n// Cambia la carga útil de salida según el valor de la carga útil enviada por EDF\nif (tempo === \"TEMPO_BLEU\") {\n msg.payload = \"TEMPO AZUL\";\n node.status({ fill: \"blue\", shape: \"ring\", text: tempo });\n}\nif (tempo === \"TEMPO_BLANC\") {\n msg.payload = \"TEMPO BLANCO\";\n node.status({ fill: \"white\", shape: \"ring\", texto: tempo });\n}\n \nif (tempo === \"TEMPO_ROUGE\") {\n msg.payload = \"TEMPO ROUGE\";\n node.status({ fill: \"red\", shape: \"ring\", text: tempo });\n}\n\nif (tempo === \"NON_DEFINI\") {\n msg.payload = \"NOM DEFINI\";\n node.status({ fill: \"grey\", shape: \"ring\", text: tempo });\n}\n\n// ** Fin Bloc ************************************************************************************************\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 530,
"y": 140,
"wires": [
[
"50e0c479b04cb23c",
"71a73d70ed628528"
]
]
},
{
"id": "0de6bf94f39e7f8b",
"type": "function",
"z": "2b792c822e8e46f1",
"g": "42d67acc049f7425",
"name": "Envoi TEMPO JOURJ => Gladys:TEMPO-EDF-COULEUR-1-2-3",
"func": "var tempo = msg.payload.couleurJourJ;\n\n// ** Début Bloc ***********************************************************************************************\n\n// Nom des appareils donnés dans Gladys\nvar nomAppareilGladys = \"TEMPO-EDF\"; // nom du device dans Gladys\nvar nomIdAppareilGladys = \"COULEUR-1-2-3\"; // nom de l'ID externe de la fonctionnalité\n\n// Valeur Topic et Payload à envoyer à Gladys\n// gladys/master/device/mqtt: TEMPO-EDF /feature/mqtt: TEMPO-EDF-COULEUR-1-2-3/state\nmsg.topic = \"gladys/master/device/mqtt:\" + nomAppareilGladys + \"/feature/mqtt:\" + nomIdAppareilGladys + \"/state\";\n\n// Change le payload de sortie selon la valeur du payload envoyé par EDF\nif (tempo === \"TEMPO_BLEU\") {\n msg.payload = 1;\n node.status({ fill: \"blue\", shape: \"ring\", text: tempo });\n}\nif (tempo === \"TEMPO_BLANC\") {\n msg.payload = 2;\n node.status({ fill: \"white\", shape: \"ring\", text: tempo });\n}\n\nif (tempo === \"TEMPO_ROUGE\") {\n msg.payload = 3;\n node.status({ fill: \"red\", shape: \"ring\", text: tempo });\n}\n\nif (tempo === \"NON_DEFINI\") {\n msg.payload = 4;\n node.status({ fill: \"grey\", shape: \"ring\", text: tempo });\n}\n\n// ** Fin Bloc ************************************************************************************************\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 600,
"y": 260,
"wires": [
[
"50e0c479b04cb23c",
"71a73d70ed628528"
]
]
},
{
"id": "c930bd12d3f44d91",
"type": "inject",
"z": "2b792c822e8e46f1",
"g": "02e46bae52d39d3b",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "01 13 * * *",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 190,
"y": 360,
"wires": [
[
"9c8bd280de70d67b"
]
]
},
{
"id": "9c8bd280de70d67b",
"type": "function",
"z": "2b792c822e8e46f1",
"g": "02e46bae52d39d3b",
"name": "Génére Date ",
"func": "const date = new Date();\n\nlet day = date.getDate();\nlet month = date.getMonth() + 1;\nlet year = date.getFullYear();\n\nlet currentDate = `${year}-${month}-${day}`;\n\nmsg.query = currentDate;\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 190,
"y": 420,
"wires": [
[
"590aa4f85a232830"
]
]
},
{
"id": "590aa4f85a232830",
"type": "http request",
"z": "2b792c822e8e46f1",
"g": "02e46bae52d39d3b",
"name": "Couleur_TEMPO",
"method": "GET",
"ret": "obj",
"paytoqs": "ignore",
"url": "https://particulier.edf.fr/services/rest/referentiel/getNbTempoDays?TypeAlerte=TEMPO",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 210,
"y": 480,
"wires": [
[
"4c96ef17847a98b3",
"341b7ddd6a3eb996",
"25b74b7de9880f61",
"6c60d01b69c8beda"
]
]
},
{
"id": "6d3c60cbfc8197ad",
"type": "debug",
"z": "2b792c822e8e46f1",
"g": "02e46bae52d39d3b",
"name": "debug 14",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 940,
"y": 420,
"wires": []
},
{
"id": "4c96ef17847a98b3",
"type": "debug",
"z": "2b792c822e8e46f1",
"g": "02e46bae52d39d3b",
"name": "debug 15",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 420,
"y": 360,
"wires": []
},
{
"id": "25f4c2d57f2b9c3d",
"type": "mqtt out",
"z": "2b792c822e8e46f1",
"g": "02e46bae52d39d3b",
"name": "Broker Mqtt IP Gladys:1883",
"topic": "",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "f4ab211ed11dc81c",
"x": 980,
"y": 480,
"wires": []
},
{
"id": "341b7ddd6a3eb996",
"type": "function",
"z": "2b792c822e8e46f1",
"g": "02e46bae52d39d3b",
"name": "Envoi TEMPO PARAM_NB_J_BLANC",
"func": "var nbJour = msg.payload.PARAM_NB_J_BLANC;\n\n// ** Début Bloc ***********************************************************************************************\n\n// Nom des appareils donnés dans Gladys\nvar nomAppareilGladys = \"TEMPO-EDF\"; // nom du device dans Gladys\nvar nomIdAppareilGladys = \"NbJourBlanc\"; // nom de l'ID externe de la fonctionnalité\n\n// Valeur Topic et Payload à envoyer à Gladys\n// gladys/master/device/mqtt:\" TEMPO-EDF /feature/mqtt:\" JOUR /text\nmsg.topic = \"gladys/master/device/mqtt:\" + nomAppareilGladys + \"/feature/mqtt:\" + nomIdAppareilGladys + \"/text\";\n\n// Change le payload de sortie selon la valeur du payload envoyé par EDF\nmsg.payload = nbJour;\nnode.status({ fill: \"white\", shape: \"ring\", text: nbJour });\n\n// ** Fin Bloc ************************************************************************************************\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 520,
"y": 480,
"wires": [
[
"25f4c2d57f2b9c3d",
"6d3c60cbfc8197ad"
]
]
},
{
"id": "25b74b7de9880f61",
"type": "function",
"z": "2b792c822e8e46f1",
"g": "02e46bae52d39d3b",
"name": "Envoi TEMPO PARAM_NB_J_BLEU",
"func": "var nbJour = msg.payload.PARAM_NB_J_BLEU;\n\n// ** Début Bloc ***********************************************************************************************\n\n// Nom des appareils donnés dans Gladys\nvar nomAppareilGladys = \"TEMPO-EDF\"; // nom du device dans Gladys\nvar nomIdAppareilGladys = \"NbJourBleu\"; // nombre de la ID externa de la funcionalidad\n\n// Valor Topic y Payload para enviar a Gladys\n// gladys/master/device/mqtt:\" TEMPO-EDF /feature/mqtt:\" JOUR /text\nmsg.topic = \"gladys/master/device/mqtt:\" + nomAppareilGladys + \"/feature/mqtt:\" + nomIdAppareilGladys + \"/text\";\n\n// Cambia el payload de salida según el valor del payload enviado por EDF\nmsg.payload = nbJour;\nnode.status({ fill: \"white\", shape: \"ring\", text: nbJour });\n\n// ** Fin Bloc ************************************************************************************************\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 510,
"y": 420,
"wires": [
[
"25f4c2d57f2b9c3d",
"6d3c60cbfc8197ad"
]
]
},
{
"id": "6c60d01b69c8beda",
"type": "function",
"z": "2b792c822e8e46f1",
"g": "02e46bae52d39d3b",
"name": "Envoi TEMPO PARAM_NB_J_ROUGE",
"func": "var nbJour = msg.payload.PARAM_NB_J_ROUGE;\n\n// ** Début Bloc ***********************************************************************************************\n\n// Nombre de los dispositivos dados en Gladys\nvar nomAppareilGladys = \"TEMPO-EDF\"; // nombre del dispositivo en Gladys\nvar nomIdAppareilGladys = \"NbJourRouge\"; // nombre de la ID externa de la funcionalidad\n\n// Valor Topic y Payload para enviar a Gladys\n// gladys/master/device/mqtt:\" TEMPO-EDF /feature/mqtt:\" JOUR /text\nmsg.topic = \"gladys/master/device/mqtt:\" + nomAppareilGladys + \"/feature/mqtt:\" + nomIdAppareilGladys + \"/text\";\n\n// Cambia el payload de salida según el valor del payload enviado por EDF\nmsg.payload = nbJour;\nnode.status({ fill: \"white\", shape: \"ring\", text: nbJour });\n\n// ** Fin Bloc ************************************************************************************************\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 520,
"y": 540,
"wires": [
[
"25f4c2d57f2b9c3d",
"6d3c60cbfc8197ad"
]
]
},
{
"id": "f4ab211ed11dc81c",
"type": "mqtt-broker",
"name": "192.168.0.125:1883",
"broker": "192.168.0.125",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"autoUnsubscribe": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
}
]
(inspirado desde Couleur EDF TEMPO dans Node Red)
Debes tener esto ahora en Node-red
Adaptar los parámetros del broker Mqtt a sus parámetros
Crear en el dashboard de Gladys
Ahora el TEMPO EDF se muestra en su dashboard.
Para enviar el color Tempo por Telegram con una escena
Puedes crear una escena
Ahora puedes recibir el TEMPO EDF a través de TELEGRAM todas las mañanas a las 8:00. ![]()
Puedes condicionar el envío al valor del color enviado creando una acción « Continuar solo si » para colocar antes de la acción enviar un mensaje
Los colores están indicados en el código del nodo en el valor payload
![]()
// Cambia el payload de salida según el valor del payload enviado por EDF
if (tempo === "TEMPO_BLEU") {
msg.payload = 1;
node.status({ fill: "blue", shape: "ring", text: tempo });
}
if (tempo === "TEMPO_BLANC") {
msg.payload = 2;
node.status({ fill: "white", shape: "ring", text: tempo });
}
if (tempo === "TEMPO_ROUGE") {
msg.payload = 3;
node.status({ fill: "red", shape: "ring", text: tempo });
}
if (tempo === "NON_DEFINI") {
msg.payload = 4;
node.status({ fill: "grey", shape: "ring", text: tempo });
}
¡Así que ahorrarás más! ![]()
PS: 03/12/23 actualización con la adición del número de días restantes en Azul, Blanco y Rojo
La recuperación de la información TEMPO se realiza a través de los nodos inyectar a las 13:01 (EDF los cambia a las 13:00)











