diff --git a/.devcontainer/nodered/flows.json b/.devcontainer/nodered/flows.json index d7a2d64..bf9208f 100644 --- a/.devcontainer/nodered/flows.json +++ b/.devcontainer/nodered/flows.json @@ -1,4 +1,576 @@ [ + { + "id": "41526b8c80d5a5f7", + "type": "tab", + "label": "Flux 1", + "disabled": false, + "info": "", + "env": [] + }, + { + "id": "2a8407e428af559f", + "type": "group", + "z": "41526b8c80d5a5f7", + "name": "Min", + "style": { + "label": true + }, + "nodes": [ + "4b979855487fc0b1", + "3f74047aefdac05f", + "d2388fac5fea8d03", + "ba3afa8b6ed20d2b" + ], + "x": 314, + "y": 859, + "w": 552, + "h": 122 + }, + { + "id": "5ebff09bebc9865a", + "type": "group", + "z": "41526b8c80d5a5f7", + "name": "Low", + "style": { + "label": true + }, + "nodes": [ + "74df0c43c72c39fa", + "f9f217f841405293", + "0410cff39c4521c5", + "08379faee7b95178" + ], + "x": 314, + "y": 999, + "w": 552, + "h": 122 + }, + { + "id": "12ed9a9e97b00f80", + "type": "group", + "z": "41526b8c80d5a5f7", + "name": "High", + "style": { + "label": true + }, + "nodes": [ + "0a64cd6407eb9beb", + "74ee6826173e5cff", + "ba844710a3cd418f", + "01aa1516d332fbdb" + ], + "x": 314, + "y": 1139, + "w": 552, + "h": 122 + }, + { + "id": "cc2c8bd885d00eb5", + "type": "group", + "z": "41526b8c80d5a5f7", + "name": "Max", + "style": { + "label": true + }, + "nodes": [ + "b5dc1ebb90703c45", + "220ae50ebb21ef39", + "2af8b2907370f976", + "cb789bc9c5a12562" + ], + "x": 314, + "y": 1279, + "w": 552, + "h": 122 + }, + { + "id": "627a082dc43aa9d0", + "type": "mqtt in", + "z": "41526b8c80d5a5f7", + "name": "", + "topic": "geii/telemetry", + "qos": "2", + "datatype": "auto-detect", + "broker": "16928f30f5e1270e", + "nl": false, + "rap": true, + "rh": 0, + "inputs": 0, + "x": 90, + "y": 880, + "wires": [ + [ + "e6bbd953a6bc5b52", + "2e2332cd3bc7aba0", + "96e0876107bdfb89", + "7054bc345a349ff8", + "4eb0e47e1c97983f", + "eceee7354caa4397", + "1ba681875b5ebc3a", + "3f74047aefdac05f", + "f9f217f841405293", + "74ee6826173e5cff", + "220ae50ebb21ef39", + "df9ea9412cfc8a6d" + ] + ] + }, + { + "id": "e6bbd953a6bc5b52", + "type": "ui-gauge", + "z": "41526b8c80d5a5f7", + "name": "", + "group": "d7c1d71a4dcf42ce", + "order": 7, + "value": "$round(payload.entree,1)", + "valueType": "jsonata", + "width": 3, + "height": 3, + "gtype": "gauge-half", + "gstyle": "needle", + "title": "Entrée", + "alwaysShowTitle": false, + "floatingTitlePosition": "top-left", + "units": "units", + "icon": "", + "prefix": "", + "suffix": "", + "segments": [ + { + "from": "0", + "color": "#5cd65c", + "text": "", + "textType": "label" + }, + { + "from": "75", + "color": "#f8e45c", + "text": "", + "textType": "label" + }, + { + "from": "150", + "color": "#c061cb", + "text": "", + "textType": "label" + }, + { + "from": "225", + "color": "#ffa348", + "text": "", + "textType": "label" + } + ], + "min": 0, + "max": "300", + "sizeThickness": 16, + "sizeGap": 4, + "sizeKeyThickness": 8, + "styleRounded": true, + "styleGlow": false, + "className": "", + "x": 370, + "y": 720, + "wires": [ + [] + ] + }, + { + "id": "2e2332cd3bc7aba0", + "type": "ui-gauge", + "z": "41526b8c80d5a5f7", + "name": "", + "group": "d7c1d71a4dcf42ce", + "order": 6, + "value": "$round(payload.sortie,1)", + "valueType": "jsonata", + "width": 3, + "height": 3, + "gtype": "gauge-half", + "gstyle": "needle", + "title": "Sortie", + "alwaysShowTitle": false, + "floatingTitlePosition": "top-left", + "units": "units", + "icon": "", + "prefix": "", + "suffix": "", + "segments": [ + { + "from": "0", + "color": "#5cd65c", + "text": "", + "textType": "label" + }, + { + "from": "90", + "color": "#ffc800", + "text": "", + "textType": "label" + }, + { + "from": "120", + "color": "#ff8040", + "text": "", + "textType": "label" + }, + { + "from": "150", + "color": "#ea5353", + "text": "", + "textType": "label" + }, + { + "from": "180", + "color": "#000000", + "text": "", + "textType": "label" + } + ], + "min": 0, + "max": "220", + "sizeThickness": 16, + "sizeGap": 4, + "sizeKeyThickness": 8, + "styleRounded": true, + "styleGlow": false, + "className": "", + "x": 370, + "y": 760, + "wires": [ + [] + ] + }, + { + "id": "f4d17ca934f62db0", + "type": "ui-progress", + "z": "41526b8c80d5a5f7", + "group": "d7c1d71a4dcf42ce", + "name": "", + "label": "Tank level", + "order": 1, + "width": 0, + "height": 0, + "color": "", + "className": "", + "x": 760, + "y": 680, + "wires": [] + }, + { + "id": "96e0876107bdfb89", + "type": "change", + "z": "41526b8c80d5a5f7", + "name": "", + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "payload.tank", + "tot": "msg" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 410, + "y": 680, + "wires": [ + [ + "9145a0e552810586" + ] + ] + }, + { + "id": "9145a0e552810586", + "type": "range", + "z": "41526b8c80d5a5f7", + "minin": "0", + "maxin": "10", + "minout": "0", + "maxout": "100", + "action": "scale", + "round": false, + "property": "payload", + "name": "", + "x": 600, + "y": 680, + "wires": [ + [ + "f4d17ca934f62db0" + ] + ] + }, + { + "id": "7054bc345a349ff8", + "type": "ui-gauge", + "z": "41526b8c80d5a5f7", + "name": "", + "group": "5628ce0b7dc12431", + "order": 1, + "value": "$round(payload.pompe1,1)", + "valueType": "jsonata", + "width": 3, + "height": 3, + "gtype": "gauge-half", + "gstyle": "needle", + "title": "Pompe1", + "alwaysShowTitle": false, + "floatingTitlePosition": "top-left", + "units": "units", + "icon": "", + "prefix": "", + "suffix": "", + "segments": [ + { + "from": "0", + "color": "#ffc800", + "text": "", + "textType": "label" + }, + { + "from": "65", + "color": "#5bd75b", + "text": "", + "textType": "label" + } + ], + "min": 0, + "max": "80", + "sizeThickness": 16, + "sizeGap": 4, + "sizeKeyThickness": 8, + "styleRounded": true, + "styleGlow": false, + "className": "", + "x": 360, + "y": 1440, + "wires": [ + [] + ] + }, + { + "id": "1ba681875b5ebc3a", + "type": "ui-gauge", + "z": "41526b8c80d5a5f7", + "name": "", + "group": "5628ce0b7dc12431", + "order": 6, + "value": "$round(payload.pompe4,1)", + "valueType": "jsonata", + "width": 3, + "height": 3, + "gtype": "gauge-half", + "gstyle": "needle", + "title": "Pompe 4", + "alwaysShowTitle": false, + "floatingTitlePosition": "top-left", + "units": "units", + "icon": "", + "prefix": "", + "suffix": "", + "segments": [ + { + "from": "0", + "color": "#ffc800", + "text": "", + "textType": "label" + }, + { + "from": "65", + "color": "#5cd65c", + "text": "", + "textType": "label" + } + ], + "min": 0, + "max": "80", + "sizeThickness": 16, + "sizeGap": 4, + "sizeKeyThickness": 8, + "styleRounded": true, + "styleGlow": false, + "className": "", + "x": 360, + "y": 1560, + "wires": [ + [] + ] + }, + { + "id": "eceee7354caa4397", + "type": "ui-gauge", + "z": "41526b8c80d5a5f7", + "name": "", + "group": "5628ce0b7dc12431", + "order": 5, + "value": "$round(payload.pompe3,1)", + "valueType": "jsonata", + "width": 3, + "height": 3, + "gtype": "gauge-half", + "gstyle": "needle", + "title": "Pompe 3", + "alwaysShowTitle": false, + "floatingTitlePosition": "top-left", + "units": "units", + "icon": "", + "prefix": "", + "suffix": "", + "segments": [ + { + "from": "0", + "color": "#ffc800", + "text": "", + "textType": "label" + }, + { + "from": "65", + "color": "#5cd65c", + "text": "", + "textType": "label" + } + ], + "min": 0, + "max": "80", + "sizeThickness": 16, + "sizeGap": 4, + "sizeKeyThickness": 8, + "styleRounded": true, + "styleGlow": false, + "className": "", + "x": 360, + "y": 1520, + "wires": [ + [] + ] + }, + { + "id": "4eb0e47e1c97983f", + "type": "ui-gauge", + "z": "41526b8c80d5a5f7", + "name": "", + "group": "5628ce0b7dc12431", + "order": 2, + "value": "$round(payload.pompe2,1)", + "valueType": "jsonata", + "width": 3, + "height": 3, + "gtype": "gauge-half", + "gstyle": "needle", + "title": "Pompe 2", + "alwaysShowTitle": false, + "floatingTitlePosition": "top-left", + "units": "units", + "icon": "", + "prefix": "", + "suffix": "", + "segments": [ + { + "from": "0", + "color": "#ffc800", + "text": "", + "textType": "label" + }, + { + "from": "65", + "color": "#5cd65c", + "text": "", + "textType": "label" + } + ], + "min": 0, + "max": "80", + "sizeThickness": 16, + "sizeGap": 4, + "sizeKeyThickness": 8, + "styleRounded": true, + "styleGlow": false, + "className": "", + "x": 360, + "y": 1480, + "wires": [ + [] + ] + }, + { + "id": "4b979855487fc0b1", + "type": "ui-text", + "z": "41526b8c80d5a5f7", + "g": "2a8407e428af559f", + "group": "d7c1d71a4dcf42ce", + "order": 2, + "width": "2", + "height": "1", + "name": "", + "label": "min", + "format": "{{msg.payload}}", + "layout": "row-left", + "style": false, + "font": "", + "fontSize": 16, + "color": "#717171", + "wrapText": false, + "className": "", + "value": "payload", + "valueType": "msg", + "x": 790, + "y": 920, + "wires": [] + }, + { + "id": "74df0c43c72c39fa", + "type": "ui-text", + "z": "41526b8c80d5a5f7", + "g": "5ebff09bebc9865a", + "group": "d7c1d71a4dcf42ce", + "order": 3, + "width": "1", + "height": "1", + "name": "", + "label": "low", + "format": "{{msg.payload}}", + "layout": "row-center", + "style": false, + "font": "", + "fontSize": 16, + "color": "#717171", + "wrapText": false, + "className": "", + "value": "payload", + "valueType": "msg", + "x": 790, + "y": 1060, + "wires": [] + }, + { + "id": "0a64cd6407eb9beb", + "type": "ui-text", + "z": "41526b8c80d5a5f7", + "g": "12ed9a9e97b00f80", + "group": "d7c1d71a4dcf42ce", + "order": 4, + "width": "1", + "height": "1", + "name": "", + "label": "high", + "format": "{{msg.payload}}", + "layout": "row-center", + "style": false, + "font": "", + "fontSize": 16, + "color": "#717171", + "wrapText": false, + "className": "", + "value": "payload", + "valueType": "msg", + "x": 790, + "y": 1200, + "wires": [] + }, { "id": "b5dc1ebb90703c45", "type": "ui-text", @@ -20,10 +592,1095 @@ "className": "", "value": "payload", "valueType": "msg", - "x": 850, - "y": 700, + "x": 790, + "y": 1340, "wires": [] }, + { + "id": "3f74047aefdac05f", + "type": "switch", + "z": "41526b8c80d5a5f7", + "g": "2a8407e428af559f", + "name": "", + "property": "payload.min", + "propertyType": "msg", + "rules": [ + { + "t": "eq", + "v": "0", + "vt": "num" + }, + { + "t": "eq", + "v": "1", + "vt": "num" + } + ], + "checkall": "false", + "repair": false, + "outputs": 2, + "x": 400, + "y": 920, + "wires": [ + [ + "d2388fac5fea8d03" + ], + [ + "ba3afa8b6ed20d2b" + ] + ] + }, + { + "id": "d2388fac5fea8d03", + "type": "change", + "z": "41526b8c80d5a5f7", + "g": "2a8407e428af559f", + "name": "", + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "🔴", + "tot": "str" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 590, + "y": 900, + "wires": [ + [ + "4b979855487fc0b1" + ] + ] + }, + { + "id": "ba3afa8b6ed20d2b", + "type": "change", + "z": "41526b8c80d5a5f7", + "g": "2a8407e428af559f", + "name": "", + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "🟢", + "tot": "str" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 590, + "y": 940, + "wires": [ + [ + "4b979855487fc0b1" + ] + ] + }, + { + "id": "f9f217f841405293", + "type": "switch", + "z": "41526b8c80d5a5f7", + "g": "5ebff09bebc9865a", + "name": "", + "property": "payload.low", + "propertyType": "msg", + "rules": [ + { + "t": "eq", + "v": "0", + "vt": "num" + }, + { + "t": "eq", + "v": "1", + "vt": "num" + } + ], + "checkall": "false", + "repair": false, + "outputs": 2, + "x": 400, + "y": 1060, + "wires": [ + [ + "0410cff39c4521c5" + ], + [ + "08379faee7b95178" + ] + ] + }, + { + "id": "74ee6826173e5cff", + "type": "switch", + "z": "41526b8c80d5a5f7", + "g": "12ed9a9e97b00f80", + "name": "", + "property": "payload.high", + "propertyType": "msg", + "rules": [ + { + "t": "eq", + "v": "0", + "vt": "num" + }, + { + "t": "eq", + "v": "1", + "vt": "num" + } + ], + "checkall": "false", + "repair": false, + "outputs": 2, + "x": 400, + "y": 1200, + "wires": [ + [ + "ba844710a3cd418f" + ], + [ + "01aa1516d332fbdb" + ] + ] + }, + { + "id": "220ae50ebb21ef39", + "type": "switch", + "z": "41526b8c80d5a5f7", + "g": "cc2c8bd885d00eb5", + "name": "", + "property": "payload.max", + "propertyType": "msg", + "rules": [ + { + "t": "eq", + "v": "0", + "vt": "num" + }, + { + "t": "eq", + "v": "1", + "vt": "num" + } + ], + "checkall": "false", + "repair": false, + "outputs": 2, + "x": 400, + "y": 1340, + "wires": [ + [ + "2af8b2907370f976" + ], + [ + "cb789bc9c5a12562" + ] + ] + }, + { + "id": "0410cff39c4521c5", + "type": "change", + "z": "41526b8c80d5a5f7", + "g": "5ebff09bebc9865a", + "name": "", + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "🔴", + "tot": "str" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 590, + "y": 1040, + "wires": [ + [ + "74df0c43c72c39fa" + ] + ] + }, + { + "id": "08379faee7b95178", + "type": "change", + "z": "41526b8c80d5a5f7", + "g": "5ebff09bebc9865a", + "name": "", + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "🟢", + "tot": "str" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 590, + "y": 1080, + "wires": [ + [ + "74df0c43c72c39fa" + ] + ] + }, + { + "id": "ba844710a3cd418f", + "type": "change", + "z": "41526b8c80d5a5f7", + "g": "12ed9a9e97b00f80", + "name": "", + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "🔴", + "tot": "str" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 590, + "y": 1180, + "wires": [ + [ + "0a64cd6407eb9beb" + ] + ] + }, + { + "id": "01aa1516d332fbdb", + "type": "change", + "z": "41526b8c80d5a5f7", + "g": "12ed9a9e97b00f80", + "name": "", + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "🟢", + "tot": "str" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 590, + "y": 1220, + "wires": [ + [ + "0a64cd6407eb9beb" + ] + ] + }, + { + "id": "2af8b2907370f976", + "type": "change", + "z": "41526b8c80d5a5f7", + "g": "cc2c8bd885d00eb5", + "name": "", + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "🔴", + "tot": "str" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 590, + "y": 1320, + "wires": [ + [ + "b5dc1ebb90703c45" + ] + ] + }, + { + "id": "cb789bc9c5a12562", + "type": "change", + "z": "41526b8c80d5a5f7", + "g": "cc2c8bd885d00eb5", + "name": "", + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "🟢", + "tot": "str" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 590, + "y": 1360, + "wires": [ + [ + "b5dc1ebb90703c45" + ] + ] + }, + { + "id": "d8111b0a27868d58", + "type": "ui-button", + "z": "41526b8c80d5a5f7", + "group": "5628ce0b7dc12431", + "name": "", + "label": "Pompe 1", + "order": 3, + "width": "3", + "height": "1", + "emulateClick": false, + "tooltip": "", + "color": "", + "bgcolor": "", + "className": "", + "icon": "water-pump", + "iconPosition": "left", + "payload": "pompe1", + "payloadType": "flow", + "topic": "topic", + "topicType": "msg", + "buttonColor": "", + "textColor": "", + "iconColor": "", + "enableClick": true, + "enablePointerdown": false, + "pointerdownPayload": "", + "pointerdownPayloadType": "str", + "enablePointerup": false, + "pointerupPayload": "", + "pointerupPayloadType": "str", + "x": 80, + "y": 140, + "wires": [ + [ + "cb616566c48a3741" + ] + ] + }, + { + "id": "0d27cf86f5545bf6", + "type": "ui-button", + "z": "41526b8c80d5a5f7", + "group": "5628ce0b7dc12431", + "name": "", + "label": "Pompe 2", + "order": 4, + "width": "3", + "height": "1", + "emulateClick": false, + "tooltip": "", + "color": "", + "bgcolor": "", + "className": "", + "icon": "water-pump", + "iconPosition": "left", + "payload": "pompe2", + "payloadType": "flow", + "topic": "topic", + "topicType": "msg", + "buttonColor": "", + "textColor": "", + "iconColor": "", + "enableClick": true, + "enablePointerdown": false, + "pointerdownPayload": "", + "pointerdownPayloadType": "str", + "enablePointerup": false, + "pointerupPayload": "", + "pointerupPayloadType": "str", + "x": 80, + "y": 240, + "wires": [ + [ + "407b6739e5aea132" + ] + ] + }, + { + "id": "26a3b450d5b336de", + "type": "ui-button", + "z": "41526b8c80d5a5f7", + "group": "5628ce0b7dc12431", + "name": "", + "label": "Pompe 3", + "order": 7, + "width": "3", + "height": "1", + "emulateClick": false, + "tooltip": "", + "color": "", + "bgcolor": "", + "className": "", + "icon": "water-pump", + "iconPosition": "left", + "payload": "pompe3", + "payloadType": "flow", + "topic": "topic", + "topicType": "msg", + "buttonColor": "", + "textColor": "", + "iconColor": "", + "enableClick": true, + "enablePointerdown": false, + "pointerdownPayload": "", + "pointerdownPayloadType": "str", + "enablePointerup": false, + "pointerupPayload": "", + "pointerupPayloadType": "str", + "x": 80, + "y": 340, + "wires": [ + [ + "218de437422e4bcb" + ] + ] + }, + { + "id": "7debce7bf128d572", + "type": "ui-button", + "z": "41526b8c80d5a5f7", + "group": "5628ce0b7dc12431", + "name": "", + "label": "Pompe 4", + "order": 8, + "width": "3", + "height": "1", + "emulateClick": false, + "tooltip": "", + "color": "", + "bgcolor": "", + "className": "", + "icon": "water-pump", + "iconPosition": "left", + "payload": "pompe4", + "payloadType": "flow", + "topic": "topic", + "topicType": "msg", + "buttonColor": "", + "textColor": "", + "iconColor": "", + "enableClick": true, + "enablePointerdown": false, + "pointerdownPayload": "", + "pointerdownPayloadType": "str", + "enablePointerup": false, + "pointerupPayload": "", + "pointerupPayloadType": "str", + "x": 80, + "y": 440, + "wires": [ + [ + "3a5567adc392b412" + ] + ] + }, + { + "id": "816849e6aacc27a5", + "type": "mqtt out", + "z": "41526b8c80d5a5f7", + "name": "", + "topic": "geii/ordre", + "qos": "", + "retain": "", + "respTopic": "", + "contentType": "", + "userProps": "", + "correl": "", + "expiry": "", + "broker": "16928f30f5e1270e", + "x": 1220, + "y": 180, + "wires": [] + }, + { + "id": "df9ea9412cfc8a6d", + "type": "ui-chart", + "z": "41526b8c80d5a5f7", + "group": "d7c1d71a4dcf42ce", + "name": "", + "label": "chart", + "order": 8, + "chartType": "area", + "category": "topic", + "categoryType": "msg", + "xAxisLabel": "", + "xAxisProperty": "", + "xAxisPropertyType": "timestamp", + "xAxisType": "time", + "xAxisFormat": "", + "xAxisFormatType": "auto", + "xmin": "", + "xmax": "", + "yAxisLabel": "", + "yAxisProperty": "payload.tank", + "yAxisPropertyType": "msg", + "ymin": "0", + "ymax": "10", + "bins": 10, + "action": "append", + "stackSeries": false, + "pointShape": "false", + "pointRadius": "1", + "showLegend": false, + "removeOlder": "10", + "removeOlderUnit": "60", + "removeOlderPoints": "500", + "colors": [ + "#6fc1ff", + "#ff0000", + "#ff7f0e", + "#2ca02c", + "#a347e1", + "#d62728", + "#ff9896", + "#9467bd", + "#c5b0d5" + ], + "textColor": [ + "#666666" + ], + "textColorDefault": true, + "gridColor": [ + "#e5e5e5" + ], + "gridColorDefault": true, + "width": 6, + "height": 8, + "className": "", + "interpolation": "linear", + "x": 370, + "y": 820, + "wires": [ + [] + ] + }, + { + "id": "7653f9228ee48df4", + "type": "inject", + "z": "41526b8c80d5a5f7", + "name": "", + "props": [ + { + "p": "payload" + } + ], + "repeat": "", + "crontab": "", + "once": true, + "onceDelay": 0.1, + "topic": "", + "payload": "", + "payloadType": "date", + "x": 110, + "y": 40, + "wires": [ + [ + "78db38a5773aa5b1" + ] + ] + }, + { + "id": "78db38a5773aa5b1", + "type": "change", + "z": "41526b8c80d5a5f7", + "name": "reset", + "rules": [ + { + "t": "set", + "p": "pompe1", + "pt": "flow", + "to": "false", + "tot": "bool" + }, + { + "t": "set", + "p": "pompe2", + "pt": "flow", + "to": "false", + "tot": "bool" + }, + { + "t": "set", + "p": "pompe3", + "pt": "flow", + "to": "false", + "tot": "bool" + }, + { + "t": "set", + "p": "pompe4", + "pt": "flow", + "to": "false", + "tot": "bool" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 350, + "y": 40, + "wires": [ + [ + "6b61f244c10aa952" + ] + ] + }, + { + "id": "dcc55b882421b380", + "type": "debug", + "z": "41526b8c80d5a5f7", + "name": "debug 1", + "active": false, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "statusVal": "", + "statusType": "auto", + "x": 1220, + "y": 140, + "wires": [] + }, + { + "id": "6b61f244c10aa952", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "envoi", + "func": "let pompe1 = flow.get(\"pompe1\") || 0;\nlet pompe2 = flow.get(\"pompe2\") || 0;\nlet pompe3 = flow.get(\"pompe3\") || 0;\nlet pompe4 = flow.get(\"pompe4\") || 0;\n\nmsg.payload = { \n \"p1\": pompe1, \n \"p2\": pompe2, \n \"p3\": pompe3, \n \"p4\": pompe4 \n}\n\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1050, + "y": 180, + "wires": [ + [ + "dcc55b882421b380", + "816849e6aacc27a5" + ] + ] + }, + { + "id": "cb616566c48a3741", + "type": "switch", + "z": "41526b8c80d5a5f7", + "name": "", + "property": "payload", + "propertyType": "msg", + "rules": [ + { + "t": "eq", + "v": "0", + "vt": "num" + }, + { + "t": "eq", + "v": "1", + "vt": "num" + } + ], + "checkall": "false", + "repair": false, + "outputs": 2, + "x": 240, + "y": 140, + "wires": [ + [ + "da2a7a2acdb7b131" + ], + [ + "62ae4a9526d6832a" + ] + ] + }, + { + "id": "da2a7a2acdb7b131", + "type": "change", + "z": "41526b8c80d5a5f7", + "name": "", + "rules": [ + { + "t": "set", + "p": "pompe1", + "pt": "flow", + "to": "true", + "tot": "bool" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 430, + "y": 120, + "wires": [ + [ + "6b61f244c10aa952" + ] + ] + }, + { + "id": "62ae4a9526d6832a", + "type": "change", + "z": "41526b8c80d5a5f7", + "name": "", + "rules": [ + { + "t": "set", + "p": "pompe1", + "pt": "flow", + "to": "false", + "tot": "bool" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 430, + "y": 160, + "wires": [ + [ + "6b61f244c10aa952" + ] + ] + }, + { + "id": "407b6739e5aea132", + "type": "switch", + "z": "41526b8c80d5a5f7", + "name": "", + "property": "payload", + "propertyType": "msg", + "rules": [ + { + "t": "eq", + "v": "0", + "vt": "num" + }, + { + "t": "eq", + "v": "1", + "vt": "num" + } + ], + "checkall": "false", + "repair": false, + "outputs": 2, + "x": 240, + "y": 240, + "wires": [ + [ + "eacfe1ad3822796e" + ], + [ + "07e2e3660f90d768" + ] + ] + }, + { + "id": "eacfe1ad3822796e", + "type": "change", + "z": "41526b8c80d5a5f7", + "name": "", + "rules": [ + { + "t": "set", + "p": "pompe2", + "pt": "flow", + "to": "true", + "tot": "bool" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 430, + "y": 220, + "wires": [ + [ + "6b61f244c10aa952" + ] + ] + }, + { + "id": "07e2e3660f90d768", + "type": "change", + "z": "41526b8c80d5a5f7", + "name": "", + "rules": [ + { + "t": "set", + "p": "pompe2", + "pt": "flow", + "to": "false", + "tot": "bool" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 430, + "y": 260, + "wires": [ + [ + "6b61f244c10aa952" + ] + ] + }, + { + "id": "218de437422e4bcb", + "type": "switch", + "z": "41526b8c80d5a5f7", + "name": "", + "property": "payload", + "propertyType": "msg", + "rules": [ + { + "t": "eq", + "v": "0", + "vt": "num" + }, + { + "t": "eq", + "v": "1", + "vt": "num" + } + ], + "checkall": "false", + "repair": false, + "outputs": 2, + "x": 240, + "y": 340, + "wires": [ + [ + "3fb196dda7c351fe" + ], + [ + "6035f642902545aa" + ] + ] + }, + { + "id": "3fb196dda7c351fe", + "type": "change", + "z": "41526b8c80d5a5f7", + "name": "", + "rules": [ + { + "t": "set", + "p": "pompe3", + "pt": "flow", + "to": "true", + "tot": "bool" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 430, + "y": 320, + "wires": [ + [ + "6b61f244c10aa952" + ] + ] + }, + { + "id": "6035f642902545aa", + "type": "change", + "z": "41526b8c80d5a5f7", + "name": "", + "rules": [ + { + "t": "set", + "p": "pompe3", + "pt": "flow", + "to": "false", + "tot": "bool" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 430, + "y": 360, + "wires": [ + [ + "6b61f244c10aa952" + ] + ] + }, + { + "id": "3a5567adc392b412", + "type": "switch", + "z": "41526b8c80d5a5f7", + "name": "", + "property": "payload", + "propertyType": "msg", + "rules": [ + { + "t": "eq", + "v": "0", + "vt": "num" + }, + { + "t": "eq", + "v": "1", + "vt": "num" + } + ], + "checkall": "false", + "repair": false, + "outputs": 2, + "x": 240, + "y": 440, + "wires": [ + [ + "66cbcaabc4a84628" + ], + [ + "0695dffe28ca6f3b" + ] + ] + }, + { + "id": "66cbcaabc4a84628", + "type": "change", + "z": "41526b8c80d5a5f7", + "name": "", + "rules": [ + { + "t": "set", + "p": "pompe4", + "pt": "flow", + "to": "true", + "tot": "bool" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 430, + "y": 420, + "wires": [ + [ + "6b61f244c10aa952" + ] + ] + }, + { + "id": "0695dffe28ca6f3b", + "type": "change", + "z": "41526b8c80d5a5f7", + "name": "", + "rules": [ + { + "t": "set", + "p": "pompe4", + "pt": "flow", + "to": "false", + "tot": "bool" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 430, + "y": 460, + "wires": [ + [ + "6b61f244c10aa952" + ] + ] + }, + { + "id": "16928f30f5e1270e", + "type": "mqtt-broker", + "name": "", + "broker": "rabbitmq", + "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": "" + }, { "id": "d7c1d71a4dcf42ce", "type": "ui-group", @@ -38,6 +1695,20 @@ "disabled": "false", "groupType": "default" }, + { + "id": "5628ce0b7dc12431", + "type": "ui-group", + "name": "Pompes", + "page": "5e9c1f56ed1b2af5", + "width": 6, + "height": 1, + "order": 2, + "showTitle": true, + "className": "", + "visible": "true", + "disabled": "false", + "groupType": "default" + }, { "id": "5e9c1f56ed1b2af5", "type": "ui-page", @@ -114,7 +1785,7 @@ } }, { - "id": "d55adf124e9ef5ad", + "id": "3aa3b265b1fd10c7", "type": "global-config", "env": [], "modules": { diff --git a/main.cpp b/main.cpp index c5f3964..088d48d 100644 --- a/main.cpp +++ b/main.cpp @@ -33,7 +33,7 @@ using json = nlohmann::json; // Constantes de fonctionnement #define LEVEL_MIN 2 -#define FLOW_PER_PUMP 150 +#define FLOW_PER_PUMP 75 /* Configuration MQTT */ const std::string ADDRESS = "tcp://rabbitmq:1883"; @@ -48,7 +48,7 @@ unsigned short pompe1, pompe2, pompe3, pompe4; // bouton des pompes 0 (arrêt) / unsigned short pompe1_old, pompe2_old, pompe3_old, pompe4_old; unsigned short sensor_max, sensor_high, sensor_low, sensor_min; -float TankInitalValue = 7; +float TankInitalValue = 5; // Réception des messages MQTT // ************************************************************ @@ -57,6 +57,7 @@ public: void message_arrived(mqtt::const_message_ptr msg) override { std::string payload = msg->to_string(); + /* if (payload == "p1") { pompe1 = !pompe1; } else if (payload == "p2") { @@ -66,6 +67,24 @@ public: } else if (payload == "p4") { pompe4 = !pompe4; } + */ + + try { + json j = json::parse(payload); + + // Ne rien faire si l'objet JSON est vide + if (j.empty()) return; + + if (j.contains("p1")) pompe1 = j["p1"].get() != 0; + if (j.contains("p2")) pompe2 = j["p2"].get() != 0; + if (j.contains("p3")) pompe3 = j["p3"].get() != 0; + if (j.contains("p4")) pompe4 = j["p4"].get() != 0; + + std::cout << "Pompes : " << pompe1 << " " << pompe2 << " " << pompe3 << " " << pompe4 << std::endl; + } + catch (const json::parse_error& e) { + std::cerr << "Erreur JSON : " << e.what() << "\n"; + } } }; // ************************************************************ @@ -196,8 +215,8 @@ void ProcessInitValues() _digital[OUT_FLOW_OUT_AMPLITUDE].dvalue = 100.0; _digital[OUT_LEVEL_MIN].dvalue = LEVEL_MIN; - _digital[OUT_LEVEL_LOW].dvalue = 6; - _digital[OUT_LEVEL_HIGH].dvalue = 7; + _digital[OUT_LEVEL_LOW].dvalue = 4.3; + _digital[OUT_LEVEL_HIGH].dvalue = 6.1; _digital[OUT_LEVEL_MAX].dvalue = 9.5; _digital[IN_FLOW_OUT].dvalue = 100.0; @@ -249,9 +268,9 @@ double ProcessMoteur(int i) void ProcessException() { if (t_elapsed > 30) { - _digital[OUT_PUMP_1].mode = 0; + //_digital[OUT_PUMP_1].mode = 0; } else if (t_elapsed > 15) { - _digital[IN_SENSOR_LOW].mode = 0; + //_digital[IN_SENSOR_LOW].mode = 0; } } @@ -265,8 +284,8 @@ void Process() // ***** FLOW OUT if (_digital[IN_TANK_LEVEL].dvalue > 1.0) { - //_digital[IN_FLOW_OUT].dvalue = SimulConsoSinusoidale(t); - _digital[IN_FLOW_OUT].dvalue = SimulConsoBrown(_digital[IN_FLOW_OUT].dvalue); + _digital[IN_FLOW_OUT].dvalue = SimulConsoSinusoidale(t); + //_digital[IN_FLOW_OUT].dvalue = SimulConsoBrown(_digital[IN_FLOW_OUT].dvalue); } else {