Créer un appareil virtuel comme suit dans Gladys dans
Importer ce flow dans node-red
[
{
"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": "3d684dcab20a9914",
"type": "inject",
"z": "2b792c822e8e46f1",
"g": "42d67acc049f7425",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "05 00 * * *",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 190,
"y": 80,
"wires": [
[
"3645d0bfbb46151e"
]
]
},
{
"id": "3645d0bfbb46151e",
"type": "function",
"z": "2b792c822e8e46f1",
"g": "42d67acc049f7425",
"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": 140,
"wires": [
[
"967e5501fcd58cdd"
]
]
},
{
"id": "967e5501fcd58cdd",
"type": "http request",
"z": "2b792c822e8e46f1",
"g": "42d67acc049f7425",
"name": "Couleur_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": 920,
"y": 180,
"wires": []
},
{
"id": "e87b67de861c3256",
"type": "debug",
"z": "2b792c822e8e46f1",
"g": "42d67acc049f7425",
"name": "debug 1",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 420,
"y": 140,
"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": 220,
"wires": []
},
{
"id": "418c3a4174d195aa",
"type": "function",
"z": "2b792c822e8e46f1",
"g": "42d67acc049f7425",
"name": "Envoi TEMPO JOURJ1 => Gladys:DEMAIN ...",
"func": "var tempo = msg.payload.couleurJourJ1;\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 = \"DEMAIN\"; // 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\nif (tempo === \"TEMPO_BLEU\") {\n msg.payload = \"TEMPO BLEU\";\n node.status({ fill: \"blue\", shape: \"ring\", text: tempo });\n}\nif (tempo === \"TEMPO_BLANC\") {\n msg.payload = \"TEMPO BLANC\";\n node.status({ fill: \"white\", shape: \"ring\", text: 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": 520,
"y": 220,
"wires": [
[
"50e0c479b04cb23c",
"71a73d70ed628528"
]
]
},
{
"id": "e89633a377e594b8",
"type": "function",
"z": "2b792c822e8e46f1",
"g": "42d67acc049f7425",
"name": "Envoi TEMPO JOURJ => Gladys:JOUR ....",
"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 = \"JOUR\"; // 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\nif (tempo === \"TEMPO_BLEU\") {\n msg.payload = \"TEMPO BLEU\";\n node.status({ fill: \"blue\", shape: \"ring\", text: tempo });\n}\nif (tempo === \"TEMPO_BLANC\") {\n msg.payload = \"TEMPO BLANC\";\n node.status({ fill: \"white\", shape: \"ring\", text: 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": 520,
"y": 180,
"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": 580,
"y": 260,
"wires": [
[
"50e0c479b04cb23c",
"71a73d70ed628528"
]
]
},
{
"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": ""
}
]
(inspiré depuis Couleur EDF TEMPO dans Node Red)
Vous devez avoir cela maintenant dans Node-red
Adapter les paramètres du broker Mqtt à vos paramètres
Créez dans le dashboard de Gladys
Voila maintenant le TEMPO EDF est affiché dans votre dashboard.
Vous pouvez créer une scène
Voila maintenant vous pouvez recevoir LE TEMPO EDF via TELEGRAM tout les matins à 8h.
Vous pouvez conditionner l’envoi à la valeur de la couleur envoyée en créant une action « Continuer seulement si » à placer avant l’action envoyer un message
Les couleurs sont indiquées dans le code du node dans la valeur payload
// Change le payload de sortie selon la valeur du payload envoyé par 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 });
}
Voila de quoi faire des économies supplémentaires !