Bonjour,
Je vais vous présenter ici comment récupérer les infos sur le risque pollens et ensuite y transférer dans un topic MQTT.
Les données sont issues de ce site : https://www.pollens.fr
Le résultat final :
Voici le flux Node-Red :
( Un catch all est présent pour récupérer les erreurs et les envoyer par email )
Voici le flux au format JSON pour l’importer sur votre Node-Red :
(Les valeurs sont récupérées tous les matins à 9h00)
[
{
"id": "bbc343252cb25eac",
"type": "tab",
"label": "Flux - Pollens",
"disabled": false,
"info": "",
"env": []
},
{
"id": "7ac575237abb4457",
"type": "http request",
"z": "bbc343252cb25eac",
"name": "API Request",
"method": "GET",
"ret": "obj",
"paytoqs": "ignore",
"url": "https://www.pollens.fr/risks/thea/counties/69",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 350,
"y": 340,
"wires": [
[
"bf36dd6349fe905f"
]
]
},
{
"id": "bf36dd6349fe905f",
"type": "function",
"z": "bbc343252cb25eac",
"name": "Extract Data",
"func": "const data = msg.payload;\n\n// Extract relevant information\nconst pollenRisks = data?.risks;\n\n// Create separate messages for each pollenName\nconst messages = pollenRisks.map(risk => {\n let levelNumber = 0; // Default to 0 if level is unknown\n switch (risk.level) {\n case 0:\n case 1:\n case 2:\n case 3:\n levelNumber = risk.level;\n break;\n }\n return {\n topic: `pollen/${risk.pollenName}`, // Topic is unique for each pollenName\n payload: levelNumber\n };\n});\n\n// Output all messages\nfor (const message of messages) {\n node.send({ payload: message });\n}",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 530,
"y": 340,
"wires": [
[
"ebb744a52f2d0284"
]
]
},
{
"id": "7552d67540a2d961",
"type": "mqtt out",
"z": "bbc343252cb25eac",
"name": "Urticacées",
"topic": "gladys/master/device/mqtt:pollens/feature/mqtt:urticacees/state",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "0ee77e0f90aa9681",
"x": 1260,
"y": 20,
"wires": []
},
{
"id": "738b03c93b31f727",
"type": "mqtt out",
"z": "bbc343252cb25eac",
"name": "Tilleul",
"topic": "gladys/master/device/mqtt:pollens/feature/mqtt:tilleul/state",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "0ee77e0f90aa9681",
"x": 1250,
"y": 60,
"wires": []
},
{
"id": "a12343f669e4f8ce",
"type": "mqtt out",
"z": "bbc343252cb25eac",
"name": "Saule",
"topic": "gladys/master/device/mqtt:pollens/feature/mqtt:saule/state",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "0ee77e0f90aa9681",
"x": 1240,
"y": 100,
"wires": []
},
{
"id": "dc592ae8bba8cef2",
"type": "mqtt out",
"z": "bbc343252cb25eac",
"name": "Platane",
"topic": "gladys/master/device/mqtt:pollens/feature/mqtt:platane/state",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "0ee77e0f90aa9681",
"x": 1240,
"y": 140,
"wires": []
},
{
"id": "30f2ee8f4b0b53bf",
"type": "mqtt out",
"z": "bbc343252cb25eac",
"name": "Plantain",
"topic": "gladys/master/device/mqtt:pollens/feature/mqtt:plantain/state",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "0ee77e0f90aa9681",
"x": 1240,
"y": 180,
"wires": []
},
{
"id": "24a47cf2553c0f7c",
"type": "mqtt out",
"z": "bbc343252cb25eac",
"name": "Peuplier",
"topic": "gladys/master/device/mqtt:pollens/feature/mqtt:peuplier/state",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "0ee77e0f90aa9681",
"x": 1230,
"y": 220,
"wires": []
},
{
"id": "bc93d0fd53439b94",
"type": "mqtt out",
"z": "bbc343252cb25eac",
"name": "Oseille",
"topic": "gladys/master/device/mqtt:pollens/feature/mqtt:oseille/state",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "0ee77e0f90aa9681",
"x": 1230,
"y": 260,
"wires": []
},
{
"id": "6832327866bc04d4",
"type": "mqtt out",
"z": "bbc343252cb25eac",
"name": "Olivier",
"topic": "gladys/master/device/mqtt:pollens/feature/mqtt:olivier/state",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "0ee77e0f90aa9681",
"x": 1230,
"y": 300,
"wires": []
},
{
"id": "e2fced2c1228b5b3",
"type": "mqtt out",
"z": "bbc343252cb25eac",
"name": "Noisetier",
"topic": "gladys/master/device/mqtt:pollens/feature/mqtt:noisetier/state",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "0ee77e0f90aa9681",
"x": 1230,
"y": 340,
"wires": []
},
{
"id": "c9e8b061faf6b7ab",
"type": "mqtt out",
"z": "bbc343252cb25eac",
"name": "Graminées",
"topic": "gladys/master/device/mqtt:pollens/feature/mqtt:graminees/state",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "0ee77e0f90aa9681",
"x": 1240,
"y": 380,
"wires": []
},
{
"id": "68afc7734f581758",
"type": "mqtt out",
"z": "bbc343252cb25eac",
"name": "Frêne",
"topic": "gladys/master/device/mqtt:pollens/feature/mqtt:frene/state",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "0ee77e0f90aa9681",
"x": 1220,
"y": 420,
"wires": []
},
{
"id": "92ad5dd377dc541f",
"type": "mqtt out",
"z": "bbc343252cb25eac",
"name": "Cupressacées",
"topic": "gladys/master/device/mqtt:pollens/feature/mqtt:cupressacees/state",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "0ee77e0f90aa9681",
"x": 1250,
"y": 460,
"wires": []
},
{
"id": "939b222b7f7c1e9e",
"type": "mqtt out",
"z": "bbc343252cb25eac",
"name": "Chêne",
"topic": "gladys/master/device/mqtt:pollens/feature/mqtt:chene/state",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "0ee77e0f90aa9681",
"x": 1230,
"y": 500,
"wires": []
},
{
"id": "e67e604f59541e3c",
"type": "mqtt out",
"z": "bbc343252cb25eac",
"name": "Châtaignier",
"topic": "gladys/master/device/mqtt:pollens/feature/mqtt:chataignier/state",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "0ee77e0f90aa9681",
"x": 1250,
"y": 540,
"wires": []
},
{
"id": "4ade92344aec1398",
"type": "mqtt out",
"z": "bbc343252cb25eac",
"name": "Charme",
"topic": "gladys/master/device/mqtt:pollens/feature/mqtt:charme/state",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "0ee77e0f90aa9681",
"x": 1230,
"y": 580,
"wires": []
},
{
"id": "9d07f4044c43f4ca",
"type": "mqtt out",
"z": "bbc343252cb25eac",
"name": "Bouleau",
"topic": "gladys/master/device/mqtt:pollens/feature/mqtt:bouleau/state",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "0ee77e0f90aa9681",
"x": 1230,
"y": 620,
"wires": []
},
{
"id": "c52ccb37cc771e50",
"type": "mqtt out",
"z": "bbc343252cb25eac",
"name": "Aulne",
"topic": "gladys/master/device/mqtt:pollens/feature/mqtt:aulne/state",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "0ee77e0f90aa9681",
"x": 1220,
"y": 660,
"wires": []
},
{
"id": "63ebd22212600817",
"type": "mqtt out",
"z": "bbc343252cb25eac",
"name": "Armoise",
"topic": "gladys/master/device/mqtt:pollens/feature/mqtt:armoise/state",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "0ee77e0f90aa9681",
"x": 1230,
"y": 700,
"wires": []
},
{
"id": "b5014ef4d4b78031",
"type": "mqtt out",
"z": "bbc343252cb25eac",
"name": "Ambroisies",
"topic": "gladys/master/device/mqtt:pollens/feature/mqtt:ambroisies/state",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "0ee77e0f90aa9681",
"x": 1230,
"y": 740,
"wires": []
},
{
"id": "ebb744a52f2d0284",
"type": "switch",
"z": "bbc343252cb25eac",
"name": "",
"property": "payload.topic",
"propertyType": "msg",
"rules": [
{
"t": "cont",
"v": "Urticacées",
"vt": "str"
},
{
"t": "cont",
"v": "Tilleul",
"vt": "str"
},
{
"t": "cont",
"v": "Saule",
"vt": "str"
},
{
"t": "cont",
"v": "Platane",
"vt": "str"
},
{
"t": "cont",
"v": "Plantain",
"vt": "str"
},
{
"t": "cont",
"v": "Peuplier",
"vt": "str"
},
{
"t": "cont",
"v": "Oseille",
"vt": "str"
},
{
"t": "cont",
"v": "Olivier",
"vt": "str"
},
{
"t": "cont",
"v": "Noisetier",
"vt": "str"
},
{
"t": "cont",
"v": "Graminées",
"vt": "str"
},
{
"t": "cont",
"v": "Frêne",
"vt": "str"
},
{
"t": "cont",
"v": "Cupressacées",
"vt": "str"
},
{
"t": "cont",
"v": "Chêne",
"vt": "str"
},
{
"t": "cont",
"v": "Châtaignier",
"vt": "str"
},
{
"t": "cont",
"v": "Charme",
"vt": "str"
},
{
"t": "cont",
"v": "Bouleau",
"vt": "str"
},
{
"t": "cont",
"v": "Aulne",
"vt": "str"
},
{
"t": "cont",
"v": "Armoise",
"vt": "str"
},
{
"t": "cont",
"v": "Ambroisies",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 19,
"x": 710,
"y": 340,
"wires": [
[
"8d0adde0aff95a13"
],
[
"45b3b282ee5c7f5b"
],
[
"141cd61cf70552dc"
],
[
"0c8d638c799564f0"
],
[
"a76f02d65b5b251b"
],
[
"ab7ba6214628bc23"
],
[
"4b764b9864485c4c"
],
[
"96b42f8a867b2fc6"
],
[
"2f2dad2bd71e80f9"
],
[
"552335c84c6fe8df"
],
[
"26e08c68dc2065bb"
],
[
"60bdf90b83076df1"
],
[
"caec8f89d4738303"
],
[
"6be8143442f0a2eb"
],
[
"e43acc2af6e9fe96"
],
[
"5d402663ddcf3d59"
],
[
"2c3f0316affb6ae7"
],
[
"19c57cc67447e518"
],
[
"e48d51016db99b89"
]
]
},
{
"id": "141cd61cf70552dc",
"type": "function",
"z": "bbc343252cb25eac",
"name": "Extraction valeur",
"func": "const topic = msg.payload.topic;\nconst payload = msg.payload.payload;\nmsg.topic = topic;\nmsg.payload = payload;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 990,
"y": 100,
"wires": [
[
"a12343f669e4f8ce"
]
]
},
{
"id": "45b3b282ee5c7f5b",
"type": "function",
"z": "bbc343252cb25eac",
"name": "Extraction valeur",
"func": "const topic = msg.payload.topic;\nconst payload = msg.payload.payload;\nmsg.topic = topic;\nmsg.payload = payload;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 990,
"y": 60,
"wires": [
[
"738b03c93b31f727"
]
]
},
{
"id": "8d0adde0aff95a13",
"type": "function",
"z": "bbc343252cb25eac",
"name": "Extraction valeur",
"func": "const topic = msg.payload.topic;\nconst payload = msg.payload.payload;\nmsg.topic = topic;\nmsg.payload = payload;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 990,
"y": 20,
"wires": [
[
"7552d67540a2d961"
]
]
},
{
"id": "0c8d638c799564f0",
"type": "function",
"z": "bbc343252cb25eac",
"name": "Extraction valeur",
"func": "const topic = msg.payload.topic;\nconst payload = msg.payload.payload;\nmsg.topic = topic;\nmsg.payload = payload;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 990,
"y": 140,
"wires": [
[
"dc592ae8bba8cef2"
]
]
},
{
"id": "a76f02d65b5b251b",
"type": "function",
"z": "bbc343252cb25eac",
"name": "Extraction valeur",
"func": "const topic = msg.payload.topic;\nconst payload = msg.payload.payload;\nmsg.topic = topic;\nmsg.payload = payload;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 990,
"y": 180,
"wires": [
[
"30f2ee8f4b0b53bf"
]
]
},
{
"id": "ab7ba6214628bc23",
"type": "function",
"z": "bbc343252cb25eac",
"name": "Extraction valeur",
"func": "const topic = msg.payload.topic;\nconst payload = msg.payload.payload;\nmsg.topic = topic;\nmsg.payload = payload;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 990,
"y": 220,
"wires": [
[
"24a47cf2553c0f7c"
]
]
},
{
"id": "4b764b9864485c4c",
"type": "function",
"z": "bbc343252cb25eac",
"name": "Extraction valeur",
"func": "const topic = msg.payload.topic;\nconst payload = msg.payload.payload;\nmsg.topic = topic;\nmsg.payload = payload;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 990,
"y": 260,
"wires": [
[
"bc93d0fd53439b94"
]
]
},
{
"id": "96b42f8a867b2fc6",
"type": "function",
"z": "bbc343252cb25eac",
"name": "Extraction valeur",
"func": "const topic = msg.payload.topic;\nconst payload = msg.payload.payload;\nmsg.topic = topic;\nmsg.payload = payload;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 990,
"y": 300,
"wires": [
[
"6832327866bc04d4"
]
]
},
{
"id": "2f2dad2bd71e80f9",
"type": "function",
"z": "bbc343252cb25eac",
"name": "Extraction valeur",
"func": "const topic = msg.payload.topic;\nconst payload = msg.payload.payload;\nmsg.topic = topic;\nmsg.payload = payload;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 990,
"y": 340,
"wires": [
[
"e2fced2c1228b5b3"
]
]
},
{
"id": "552335c84c6fe8df",
"type": "function",
"z": "bbc343252cb25eac",
"name": "Extraction valeur",
"func": "const topic = msg.payload.topic;\nconst payload = msg.payload.payload;\nmsg.topic = topic;\nmsg.payload = payload;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 990,
"y": 380,
"wires": [
[
"c9e8b061faf6b7ab"
]
]
},
{
"id": "26e08c68dc2065bb",
"type": "function",
"z": "bbc343252cb25eac",
"name": "Extraction valeur",
"func": "const topic = msg.payload.topic;\nconst payload = msg.payload.payload;\nmsg.topic = topic;\nmsg.payload = payload;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 990,
"y": 420,
"wires": [
[
"68afc7734f581758"
]
]
},
{
"id": "60bdf90b83076df1",
"type": "function",
"z": "bbc343252cb25eac",
"name": "Extraction valeur",
"func": "const topic = msg.payload.topic;\nconst payload = msg.payload.payload;\nmsg.topic = topic;\nmsg.payload = payload;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 990,
"y": 460,
"wires": [
[
"92ad5dd377dc541f"
]
]
},
{
"id": "caec8f89d4738303",
"type": "function",
"z": "bbc343252cb25eac",
"name": "Extraction valeur",
"func": "const topic = msg.payload.topic;\nconst payload = msg.payload.payload;\nmsg.topic = topic;\nmsg.payload = payload;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 990,
"y": 500,
"wires": [
[
"939b222b7f7c1e9e"
]
]
},
{
"id": "6be8143442f0a2eb",
"type": "function",
"z": "bbc343252cb25eac",
"name": "Extraction valeur",
"func": "const topic = msg.payload.topic;\nconst payload = msg.payload.payload;\nmsg.topic = topic;\nmsg.payload = payload;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 990,
"y": 540,
"wires": [
[
"e67e604f59541e3c"
]
]
},
{
"id": "e43acc2af6e9fe96",
"type": "function",
"z": "bbc343252cb25eac",
"name": "Extraction valeur",
"func": "const topic = msg.payload.topic;\nconst payload = msg.payload.payload;\nmsg.topic = topic;\nmsg.payload = payload;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 990,
"y": 580,
"wires": [
[
"4ade92344aec1398"
]
]
},
{
"id": "5d402663ddcf3d59",
"type": "function",
"z": "bbc343252cb25eac",
"name": "Extraction valeur",
"func": "const topic = msg.payload.topic;\nconst payload = msg.payload.payload;\nmsg.topic = topic;\nmsg.payload = payload;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 990,
"y": 620,
"wires": [
[
"9d07f4044c43f4ca"
]
]
},
{
"id": "2c3f0316affb6ae7",
"type": "function",
"z": "bbc343252cb25eac",
"name": "Extraction valeur",
"func": "const topic = msg.payload.topic;\nconst payload = msg.payload.payload;\nmsg.topic = topic;\nmsg.payload = payload;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 990,
"y": 660,
"wires": [
[
"c52ccb37cc771e50"
]
]
},
{
"id": "19c57cc67447e518",
"type": "function",
"z": "bbc343252cb25eac",
"name": "Extraction valeur",
"func": "const topic = msg.payload.topic;\nconst payload = msg.payload.payload;\nmsg.topic = topic;\nmsg.payload = payload;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 990,
"y": 700,
"wires": [
[
"63ebd22212600817"
]
]
},
{
"id": "e48d51016db99b89",
"type": "function",
"z": "bbc343252cb25eac",
"name": "Extraction valeur",
"func": "const topic = msg.payload.topic;\nconst payload = msg.payload.payload;\nmsg.topic = topic;\nmsg.payload = payload;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 990,
"y": 740,
"wires": [
[
"b5014ef4d4b78031"
]
]
},
{
"id": "6e9a8b6333516061",
"type": "cronplus",
"z": "bbc343252cb25eac",
"name": "Cron",
"outputField": "payload",
"timeZone": "",
"storeName": "",
"commandResponseMsgOutput": "output1",
"defaultLocation": "",
"defaultLocationType": "default",
"outputs": 1,
"options": [
{
"name": "schedule1",
"topic": "topic1",
"payloadType": "default",
"payload": "",
"expressionType": "cron",
"expression": "0 0 07 * * *",
"location": "",
"offset": "0",
"solarType": "all",
"solarEvents": "sunrise,sunset"
}
],
"x": 190,
"y": 340,
"wires": [
[
"7ac575237abb4457",
"aa3e0879.49a3d8"
]
]
},
{
"id": "4e5ac12b.2d8a4c",
"type": "catch",
"z": "bbc343252cb25eac",
"name": "Erreurs",
"scope": null,
"uncaught": false,
"x": 170,
"y": 240,
"wires": [
[
"29c9f07e.2920d6"
]
]
},
{
"id": "29c9f07e.2920d6",
"type": "e-mail",
"z": "bbc343252cb25eac",
"server": "monserveuremail",
"port": "465",
"authtype": "BASIC",
"saslformat": false,
"token": "oauth2Response.access_token",
"secure": true,
"tls": true,
"name": "monadresse@email.fr",
"dname": "Mail",
"x": 320,
"y": 240,
"wires": []
},
{
"id": "aa3e0879.49a3d8",
"type": "function",
"z": "bbc343252cb25eac",
"name": "Get Current Date & Time",
"func": "// Récupérer la date et l'heure actuelles pour Paris\nvar currentDate = new Date();\n\n// Calculer le décalage horaire pour Paris (en minutes)\nvar offsetParis = 120; // Décalage horaire pour Paris (UTC+2) en minutes\n\n// Ajouter le décalage horaire de Paris à la date actuelle\ncurrentDate.setMinutes(currentDate.getMinutes() + offsetParis);\n\n// Récupérer les composants de la date et de l'heure\nvar day = (\"0\" + currentDate.getDate()).slice(-2);\nvar month = (\"0\" + (currentDate.getMonth() + 1)).slice(-2);\nvar year = currentDate.getFullYear();\nvar hours = (\"0\" + currentDate.getHours()).slice(-2);\nvar minutes = (\"0\" + currentDate.getMinutes()).slice(-2);\n\n// Concaténer les composants pour obtenir le format souhaité\nvar formattedDate = day + \"/\" + month + \"/\" + year + \" \" + hours + \":\" + minutes;\n\n// Créer un objet de réponse\nvar msg = {\n payload: formattedDate\n};\n\n// Envoyer le message de sortie\nreturn msg;\n",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1010,
"y": 780,
"wires": [
[
"8bec17071380c5a3"
]
]
},
{
"id": "8bec17071380c5a3",
"type": "mqtt out",
"z": "bbc343252cb25eac",
"name": "Date/Heure",
"topic": "gladys/master/device/mqtt:pollens/feature/mqtt:pollens-date-maj/text",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "0ee77e0f90aa9681",
"x": 1230,
"y": 780,
"wires": []
},
{
"id": "0ee77e0f90aa9681",
"type": "mqtt-broker",
"name": "Gladys",
"broker": "mqtt://192.168.xx.xx",
"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": ""
}
]
Bien penser à modifier le numéro de votre département dans le noeud « Api Request »
Et également l’adresse IP de votre broker MQTT
Voici l’appareil MQTT avec les fonctionnalités :
Si vous avez des questions/remarques, n’hésitez pas à m’en faire part
Changelog à venir :
- Aucun (A vos commentaires )
Edit 13/05/2024 :
- Modification des types de fonctionnalités en niveau de risque avec le sortie de la version de Gladys 4.41.0
Edit 15/05/2024 :
- Ajout de la date et heure de mise à jour