From 1739ea921bab1e372b1c43e1c721d0367f17d8e1 Mon Sep 17 00:00:00 2001 From: "e.medina" Date: Fri, 9 Jan 2026 10:59:47 +0100 Subject: [PATCH] Interrupteurs --- .devcontainer/nodered/flows.json | 1050 ++++++++++++++++++++++++++---- AutomForArduino.cpp | 21 +- main.cpp | 5 - main.hpp | 2 - 4 files changed, 951 insertions(+), 127 deletions(-) diff --git a/.devcontainer/nodered/flows.json b/.devcontainer/nodered/flows.json index ddbbf6d..6e67f88 100644 --- a/.devcontainer/nodered/flows.json +++ b/.devcontainer/nodered/flows.json @@ -14,45 +14,6 @@ "group": "5fe915fcd26e78ae", "name": "", "label": "B0", - "order": 2, - "width": 0, - "height": 0, - "emulateClick": false, - "tooltip": "", - "color": "", - "bgcolor": "", - "className": "", - "icon": "", - "iconPosition": "left", - "payload": "", - "payloadType": "str", - "topic": "topic", - "topicType": "msg", - "buttonColor": "", - "textColor": "", - "iconColor": "", - "enableClick": true, - "enablePointerdown": false, - "pointerdownPayload": "", - "pointerdownPayloadType": "str", - "enablePointerup": false, - "pointerupPayload": "", - "pointerupPayloadType": "str", - "x": 130, - "y": 320, - "wires": [ - [ - "6444617c166984e0" - ] - ] - }, - { - "id": "9dcd1bf2a25f7371", - "type": "ui-button", - "z": "41526b8c80d5a5f7", - "group": "5fe915fcd26e78ae", - "name": "", - "label": "B1", "order": 3, "width": 0, "height": 0, @@ -77,21 +38,21 @@ "enablePointerup": false, "pointerupPayload": "", "pointerupPayloadType": "str", - "x": 130, - "y": 360, + "x": 690, + "y": 680, "wires": [ [ - "4ee747c8012c58a1" + "40cd3b8ab614429e" ] ] }, { - "id": "143358afb510246e", + "id": "9dcd1bf2a25f7371", "type": "ui-button", "z": "41526b8c80d5a5f7", "group": "5fe915fcd26e78ae", "name": "", - "label": "B2", + "label": "B1", "order": 4, "width": 0, "height": 0, @@ -116,21 +77,21 @@ "enablePointerup": false, "pointerupPayload": "", "pointerupPayloadType": "str", - "x": 130, - "y": 400, + "x": 690, + "y": 720, "wires": [ [ - "d966ba0d813b7cb7" + "4ee747c8012c58a1" ] ] }, { - "id": "e863fe498c528076", + "id": "143358afb510246e", "type": "ui-button", "z": "41526b8c80d5a5f7", "group": "5fe915fcd26e78ae", "name": "", - "label": "B3", + "label": "B2", "order": 5, "width": 0, "height": 0, @@ -155,8 +116,47 @@ "enablePointerup": false, "pointerupPayload": "", "pointerupPayloadType": "str", - "x": 130, - "y": 440, + "x": 690, + "y": 760, + "wires": [ + [ + "d966ba0d813b7cb7" + ] + ] + }, + { + "id": "e863fe498c528076", + "type": "ui-button", + "z": "41526b8c80d5a5f7", + "group": "5fe915fcd26e78ae", + "name": "", + "label": "B3", + "order": 6, + "width": 0, + "height": 0, + "emulateClick": false, + "tooltip": "", + "color": "", + "bgcolor": "", + "className": "", + "icon": "", + "iconPosition": "left", + "payload": "", + "payloadType": "str", + "topic": "topic", + "topicType": "msg", + "buttonColor": "", + "textColor": "", + "iconColor": "", + "enableClick": true, + "enablePointerdown": false, + "pointerdownPayload": "", + "pointerdownPayloadType": "str", + "enablePointerup": false, + "pointerupPayload": "", + "pointerupPayloadType": "str", + "x": 690, + "y": 800, "wires": [ [ "501355b0c82cae08" @@ -177,8 +177,8 @@ "correl": "", "expiry": "", "broker": "5bf949eb0a1b50a7", - "x": 730, - "y": 120, + "x": 1930, + "y": 100, "wires": [] }, { @@ -212,8 +212,8 @@ "enablePointerup": false, "pointerupPayload": "", "pointerupPayloadType": "str", - "x": 140, - "y": 260, + "x": 700, + "y": 500, "wires": [ [ "3e0c75aae8971dca" @@ -225,15 +225,15 @@ "type": "function", "z": "41526b8c80d5a5f7", "name": "format mqtt", - "func": "let marche = Number(flow.get(\"marche\") || 0);\nlet b0 = Number(flow.get(\"b0\") || 0);\nlet b1 = Number(flow.get(\"b1\") || 0);\nlet b2 = Number(flow.get(\"b2\") || 0);\nlet b3 = Number(flow.get(\"b3\") || 0);\nlet b4 = Number(flow.get(\"b4\") || 0);\nlet b5 = Number(flow.get(\"b5\") || 0);\nlet b6 = Number(flow.get(\"b6\") || 0);\nlet b7 = Number(flow.get(\"b7\") || 0);\n\nmsg.payload = {\n \"marche\": marche,\n \"b0\": b0,\n \"b1\": b1,\n \"b2\": b2,\n \"b3\": b3,\n \"b4\": b4,\n \"b5\": b5,\n \"b6\": b6,\n \"b7\": b7\n};\n\nreturn msg;", + "func": "let marche = Number(flow.get(\"marche\") || 0);\nlet arret = Number(flow.get(\"arret\") || 0);\nlet b0 = Number(flow.get(\"b0\") || 0);\nlet b1 = Number(flow.get(\"b1\") || 0);\nlet b2 = Number(flow.get(\"b2\") || 0);\nlet b3 = Number(flow.get(\"b3\") || 0);\nlet b4 = Number(flow.get(\"b4\") || 0);\nlet b5 = Number(flow.get(\"b5\") || 0);\nlet b6 = Number(flow.get(\"b6\") || 0);\nlet b7 = Number(flow.get(\"b7\") || 0);\n\nmsg.payload = {\n \"marche\": marche,\n \"arret\": arret,\n \"b0\": b0,\n \"b1\": b1,\n \"b2\": b2,\n \"b3\": b3,\n \"b4\": b4,\n \"b5\": b5,\n \"b6\": b6,\n \"b7\": b7\n};\n\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 570, - "y": 120, + "x": 510, + "y": 40, "wires": [ [ "04e097a5c78127cb" @@ -261,7 +261,8 @@ "y": 40, "wires": [ [ - "869aedf62de05359" + "869aedf62de05359", + "e52bad35a9e3303a" ] ] }, @@ -270,38 +271,18 @@ "type": "function", "z": "41526b8c80d5a5f7", "name": "set marche", - "func": "flow.set(\"marche\", !Number(flow.get(\"marche\")));\n\nreturn msg;", + "func": "msg.payload = {\n \"marche\": 1\n};\n\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 310, - "y": 260, + "x": 870, + "y": 500, "wires": [ [ - "0ca8f4a10a6048af" - ] - ] - }, - { - "id": "6444617c166984e0", - "type": "function", - "z": "41526b8c80d5a5f7", - "name": "set b0", - "func": "flow.set(\"b0\", !Number(flow.get(\"b0\")));\n\nreturn msg;", - "outputs": 1, - "timeout": 0, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 290, - "y": 320, - "wires": [ - [ - "0ca8f4a10a6048af" + "bf55b8bf4a7aaf10" ] ] }, @@ -309,19 +290,19 @@ "id": "4ee747c8012c58a1", "type": "function", "z": "41526b8c80d5a5f7", - "name": "set b1", - "func": "flow.set(\"b1\", !Number(flow.get(\"b1\")));\n\nreturn msg;", + "name": "send b1", + "func": "msg.payload = {\n \"b1\": 1\n};\n\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 290, - "y": 360, + "x": 860, + "y": 720, "wires": [ [ - "0ca8f4a10a6048af" + "bf55b8bf4a7aaf10" ] ] }, @@ -329,19 +310,19 @@ "id": "d966ba0d813b7cb7", "type": "function", "z": "41526b8c80d5a5f7", - "name": "set b2", - "func": "flow.set(\"b2\", !Number(flow.get(\"b2\")));\n\nreturn msg;", + "name": "send b2", + "func": "msg.payload = {\n \"b2\": 1\n};\n\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 290, - "y": 400, + "x": 860, + "y": 760, "wires": [ [ - "0ca8f4a10a6048af" + "bf55b8bf4a7aaf10" ] ] }, @@ -350,18 +331,18 @@ "type": "function", "z": "41526b8c80d5a5f7", "name": "set b3", - "func": "flow.set(\"b3\", !Number(flow.get(\"b3\")));\n\nreturn msg;", + "func": "msg.payload = {\n \"b3\": 1\n};\n\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 290, - "y": 440, + "x": 850, + "y": 800, "wires": [ [ - "0ca8f4a10a6048af" + "bf55b8bf4a7aaf10" ] ] }, @@ -379,7 +360,7 @@ "rh": 0, "inputs": 0, "x": 130, - "y": 580, + "y": 1140, "wires": [ [ "9ef1bb67f51b254c" @@ -407,7 +388,7 @@ "value": "payload", "valueType": "msg", "x": 870, - "y": 520, + "y": 1080, "wires": [] }, { @@ -431,7 +412,7 @@ "value": "payload", "valueType": "msg", "x": 870, - "y": 560, + "y": 1120, "wires": [] }, { @@ -455,7 +436,7 @@ "value": "payload", "valueType": "msg", "x": 870, - "y": 600, + "y": 1160, "wires": [] }, { @@ -463,7 +444,7 @@ "type": "function", "z": "41526b8c80d5a5f7", "name": "function 1", - "func": "flow.set(\"s0\", !Number(msg.payload.s0));\nflow.set(\"s1\", !Number(msg.payload.s1));\nflow.set(\"s2\", !Number(msg.payload.s2));\nflow.set(\"s3\", !Number(msg.payload.s3));\nflow.set(\"s4\", !Number(msg.payload.s4));\nflow.set(\"s5\", !Number(msg.payload.s5));\nflow.set(\"s6\", !Number(msg.payload.s6));\nflow.set(\"s7\", !Number(msg.payload.s7));\n\nreturn msg;", + "func": "flow.set(\"s0\", Number(msg.payload.s0));\nflow.set(\"s1\", Number(msg.payload.s1));\nflow.set(\"s2\", Number(msg.payload.s2));\nflow.set(\"s3\", Number(msg.payload.s3));\nflow.set(\"s4\", Number(msg.payload.s4));\nflow.set(\"s5\", Number(msg.payload.s5));\nflow.set(\"s6\", Number(msg.payload.s6));\nflow.set(\"s7\", Number(msg.payload.s7));\n\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, @@ -471,7 +452,7 @@ "finalize": "", "libs": [], "x": 380, - "y": 580, + "y": 1140, "wires": [ [ "9dad44eccec1d282", @@ -498,7 +479,7 @@ "finalize": "", "libs": [], "x": 690, - "y": 520, + "y": 1080, "wires": [ [ "309cae1a9bcc718b" @@ -518,7 +499,7 @@ "finalize": "", "libs": [], "x": 690, - "y": 560, + "y": 1120, "wires": [ [ "6bd900b695c3a793" @@ -538,7 +519,7 @@ "finalize": "", "libs": [], "x": 690, - "y": 600, + "y": 1160, "wires": [ [ "cdc7f0e7741ad210" @@ -566,7 +547,7 @@ "value": "payload", "valueType": "msg", "x": 870, - "y": 640, + "y": 1200, "wires": [] }, { @@ -590,7 +571,7 @@ "value": "payload", "valueType": "msg", "x": 870, - "y": 680, + "y": 1240, "wires": [] }, { @@ -614,7 +595,7 @@ "value": "payload", "valueType": "msg", "x": 870, - "y": 720, + "y": 1280, "wires": [] }, { @@ -638,7 +619,7 @@ "value": "payload", "valueType": "msg", "x": 870, - "y": 760, + "y": 1320, "wires": [] }, { @@ -662,7 +643,7 @@ "value": "payload", "valueType": "msg", "x": 870, - "y": 800, + "y": 1360, "wires": [] }, { @@ -678,7 +659,7 @@ "finalize": "", "libs": [], "x": 690, - "y": 640, + "y": 1200, "wires": [ [ "6172598e36ec2754" @@ -698,7 +679,7 @@ "finalize": "", "libs": [], "x": 690, - "y": 680, + "y": 1240, "wires": [ [ "7b808775687a1e80" @@ -718,7 +699,7 @@ "finalize": "", "libs": [], "x": 690, - "y": 720, + "y": 1280, "wires": [ [ "5e969524f2d7ac83" @@ -738,7 +719,7 @@ "finalize": "", "libs": [], "x": 690, - "y": 760, + "y": 1320, "wires": [ [ "f832017038053787" @@ -758,7 +739,7 @@ "finalize": "", "libs": [], "x": 690, - "y": 800, + "y": 1360, "wires": [ [ "a85963dd6d125a42" @@ -785,6 +766,825 @@ ] ] }, + { + "id": "e13f6855fb2ae6e5", + "type": "ui-button", + "z": "41526b8c80d5a5f7", + "group": "5fe915fcd26e78ae", + "name": "", + "label": "B4", + "order": 7, + "width": 0, + "height": 0, + "emulateClick": false, + "tooltip": "", + "color": "", + "bgcolor": "", + "className": "", + "icon": "", + "iconPosition": "left", + "payload": "", + "payloadType": "str", + "topic": "topic", + "topicType": "msg", + "buttonColor": "", + "textColor": "", + "iconColor": "", + "enableClick": true, + "enablePointerdown": false, + "pointerdownPayload": "", + "pointerdownPayloadType": "str", + "enablePointerup": false, + "pointerupPayload": "", + "pointerupPayloadType": "str", + "x": 690, + "y": 840, + "wires": [ + [ + "6b074a32f2f70f5f" + ] + ] + }, + { + "id": "23c475d0fb3faedb", + "type": "ui-button", + "z": "41526b8c80d5a5f7", + "group": "5fe915fcd26e78ae", + "name": "", + "label": "B5", + "order": 8, + "width": 0, + "height": 0, + "emulateClick": false, + "tooltip": "", + "color": "", + "bgcolor": "", + "className": "", + "icon": "", + "iconPosition": "left", + "payload": "", + "payloadType": "str", + "topic": "topic", + "topicType": "msg", + "buttonColor": "", + "textColor": "", + "iconColor": "", + "enableClick": true, + "enablePointerdown": false, + "pointerdownPayload": "", + "pointerdownPayloadType": "str", + "enablePointerup": false, + "pointerupPayload": "", + "pointerupPayloadType": "str", + "x": 690, + "y": 880, + "wires": [ + [ + "13525a762ac7e327" + ] + ] + }, + { + "id": "e9da3426111867c2", + "type": "ui-button", + "z": "41526b8c80d5a5f7", + "group": "5fe915fcd26e78ae", + "name": "", + "label": "B6", + "order": 9, + "width": 0, + "height": 0, + "emulateClick": false, + "tooltip": "", + "color": "", + "bgcolor": "", + "className": "", + "icon": "", + "iconPosition": "left", + "payload": "", + "payloadType": "str", + "topic": "topic", + "topicType": "msg", + "buttonColor": "", + "textColor": "", + "iconColor": "", + "enableClick": true, + "enablePointerdown": false, + "pointerdownPayload": "", + "pointerdownPayloadType": "str", + "enablePointerup": false, + "pointerupPayload": "", + "pointerupPayloadType": "str", + "x": 690, + "y": 920, + "wires": [ + [ + "501a187ca9d5dc4e" + ] + ] + }, + { + "id": "887889076242a450", + "type": "ui-button", + "z": "41526b8c80d5a5f7", + "group": "5fe915fcd26e78ae", + "name": "", + "label": "B7", + "order": 10, + "width": 0, + "height": 0, + "emulateClick": false, + "tooltip": "", + "color": "", + "bgcolor": "", + "className": "", + "icon": "", + "iconPosition": "left", + "payload": "", + "payloadType": "str", + "topic": "topic", + "topicType": "msg", + "buttonColor": "", + "textColor": "", + "iconColor": "", + "enableClick": true, + "enablePointerdown": false, + "pointerdownPayload": "", + "pointerdownPayloadType": "str", + "enablePointerup": false, + "pointerupPayload": "", + "pointerupPayloadType": "str", + "x": 690, + "y": 960, + "wires": [ + [ + "9d0587a99be6ccac" + ] + ] + }, + { + "id": "6b074a32f2f70f5f", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "set b4", + "func": "msg.payload = {\n \"b4\": 1\n};\n\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 850, + "y": 840, + "wires": [ + [ + "bf55b8bf4a7aaf10" + ] + ] + }, + { + "id": "13525a762ac7e327", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "set b5", + "func": "msg.payload = {\n \"b5\": 1\n};\n\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 850, + "y": 880, + "wires": [ + [ + "bf55b8bf4a7aaf10" + ] + ] + }, + { + "id": "501a187ca9d5dc4e", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "set b6", + "func": "msg.payload = {\n \"b6\": 1\n};\n\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 850, + "y": 920, + "wires": [ + [ + "bf55b8bf4a7aaf10" + ] + ] + }, + { + "id": "f1c934fc513b2bc7", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "set i0", + "func": "flow.set(\"i0\", msg.payload);\nmsg.payload = {};\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 870, + "y": 140, + "wires": [ + [ + "bf55b8bf4a7aaf10" + ] + ] + }, + { + "id": "ac96af9d69f69372", + "type": "ui-switch", + "z": "41526b8c80d5a5f7", + "name": "", + "label": "I0", + "group": "00ea85a0e0b38df3", + "order": 1, + "width": 0, + "height": 0, + "passthru": false, + "decouple": false, + "topic": "topic", + "topicType": "msg", + "style": "", + "className": "", + "layout": "row-spread", + "clickableArea": "switch", + "onvalue": "true", + "onvalueType": "bool", + "onicon": "", + "oncolor": "", + "offvalue": "false", + "offvalueType": "bool", + "officon": "", + "offcolor": "", + "x": 710, + "y": 140, + "wires": [ + [ + "f1c934fc513b2bc7" + ] + ] + }, + { + "id": "d64b5ceb51e6356d", + "type": "ui-button", + "z": "41526b8c80d5a5f7", + "group": "5fe915fcd26e78ae", + "name": "", + "label": "ARRET", + "order": 2, + "width": 0, + "height": 0, + "emulateClick": false, + "tooltip": "", + "color": "", + "bgcolor": "", + "className": "", + "icon": "", + "iconPosition": "left", + "payload": "", + "payloadType": "str", + "topic": "topic", + "topicType": "msg", + "buttonColor": "", + "textColor": "", + "iconColor": "", + "enableClick": true, + "enablePointerdown": false, + "pointerdownPayload": "", + "pointerdownPayloadType": "str", + "enablePointerup": false, + "pointerupPayload": "", + "pointerupPayloadType": "str", + "x": 700, + "y": 540, + "wires": [ + [ + "6144c03f7e61ad75" + ] + ] + }, + { + "id": "40cd3b8ab614429e", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "send b0", + "func": "msg.payload = {\n \"b0\": 1\n};\n\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 860, + "y": 680, + "wires": [ + [ + "bf55b8bf4a7aaf10" + ] + ] + }, + { + "id": "bf55b8bf4a7aaf10", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "format mqtt", + "func": "let i0 = Number(flow.get(\"i0\") || 0);\nlet i1 = Number(flow.get(\"i1\") || 0);\nlet i2 = Number(flow.get(\"i2\") || 0);\nlet i3 = Number(flow.get(\"i3\") || 0);\nlet i4 = Number(flow.get(\"i4\") || 0);\nlet i5 = Number(flow.get(\"i5\") || 0);\nlet i6 = Number(flow.get(\"i6\") || 0);\nlet i7 = Number(flow.get(\"i7\") || 0);\n\nif (typeof msg.payload[\"arret\"] === 'undefined') msg.payload[\"arret\"] = 1;\nif (typeof msg.payload[\"marche\"] === 'undefined') msg.payload[\"marche\"] = 0;\n\nif (typeof msg.payload[\"b0\"] === 'undefined') msg.payload[\"b0\"] = 0;\nif (typeof msg.payload[\"b1\"] === 'undefined') msg.payload[\"b1\"] = 0;\nif (typeof msg.payload[\"b2\"] === 'undefined') msg.payload[\"b2\"] = 0;\nif (typeof msg.payload[\"b3\"] === 'undefined') msg.payload[\"b3\"] = 0;\nif (typeof msg.payload[\"b4\"] === 'undefined') msg.payload[\"b4\"] = 0;\nif (typeof msg.payload[\"b5\"] === 'undefined') msg.payload[\"b5\"] = 0;\nif (typeof msg.payload[\"b6\"] === 'undefined') msg.payload[\"b6\"] = 0;\nif (typeof msg.payload[\"b7\"] === 'undefined') msg.payload[\"b7\"] = 0;\n\nmsg.payload[\"i0\"] = i0;\nmsg.payload[\"i1\"] = i1;\nmsg.payload[\"i2\"] = i2;\nmsg.payload[\"i3\"] = i3;\nmsg.payload[\"i4\"] = i4;\nmsg.payload[\"i5\"] = i5;\nmsg.payload[\"i6\"] = i6;\nmsg.payload[\"i7\"] = i7;\n\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1430, + "y": 500, + "wires": [ + [ + "04e097a5c78127cb", + "2eb8008f157e3905" + ] + ] + }, + { + "id": "9d0587a99be6ccac", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "set b7", + "func": "msg.payload = {\n \"b7\": 1\n};\n\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 850, + "y": 960, + "wires": [ + [ + "bf55b8bf4a7aaf10" + ] + ] + }, + { + "id": "057f5330eb0243b5", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "set i0", + "func": "flow.set(\"i1\", msg.payload);\nmsg.payload = {};\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 870, + "y": 180, + "wires": [ + [ + "bf55b8bf4a7aaf10" + ] + ] + }, + { + "id": "a2dd41c333e61095", + "type": "ui-switch", + "z": "41526b8c80d5a5f7", + "name": "", + "label": "I1", + "group": "00ea85a0e0b38df3", + "order": 2, + "width": 0, + "height": 0, + "passthru": false, + "decouple": false, + "topic": "topic", + "topicType": "msg", + "style": "", + "className": "", + "layout": "row-spread", + "clickableArea": "switch", + "onvalue": "true", + "onvalueType": "bool", + "onicon": "", + "oncolor": "", + "offvalue": "false", + "offvalueType": "bool", + "officon": "", + "offcolor": "", + "x": 710, + "y": 180, + "wires": [ + [ + "057f5330eb0243b5" + ] + ] + }, + { + "id": "ed8a7b695f241e17", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "set i0", + "func": "flow.set(\"i2\", msg.payload);\nmsg.payload = {};\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 870, + "y": 220, + "wires": [ + [ + "bf55b8bf4a7aaf10" + ] + ] + }, + { + "id": "7fa06bb9fc6290c2", + "type": "ui-switch", + "z": "41526b8c80d5a5f7", + "name": "", + "label": "I2", + "group": "00ea85a0e0b38df3", + "order": 3, + "width": 0, + "height": 0, + "passthru": false, + "decouple": false, + "topic": "topic", + "topicType": "msg", + "style": "", + "className": "", + "layout": "row-spread", + "clickableArea": "switch", + "onvalue": "true", + "onvalueType": "bool", + "onicon": "", + "oncolor": "", + "offvalue": "false", + "offvalueType": "bool", + "officon": "", + "offcolor": "", + "x": 710, + "y": 220, + "wires": [ + [ + "ed8a7b695f241e17" + ] + ] + }, + { + "id": "f7196bb1c9ad7882", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "set i0", + "func": "flow.set(\"i3\", msg.payload);\nmsg.payload = {};\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 870, + "y": 260, + "wires": [ + [ + "bf55b8bf4a7aaf10" + ] + ] + }, + { + "id": "787b142395f2812c", + "type": "ui-switch", + "z": "41526b8c80d5a5f7", + "name": "", + "label": "I3", + "group": "00ea85a0e0b38df3", + "order": 4, + "width": 0, + "height": 0, + "passthru": false, + "decouple": false, + "topic": "topic", + "topicType": "msg", + "style": "", + "className": "", + "layout": "row-spread", + "clickableArea": "switch", + "onvalue": "true", + "onvalueType": "bool", + "onicon": "", + "oncolor": "", + "offvalue": "false", + "offvalueType": "bool", + "officon": "", + "offcolor": "", + "x": 710, + "y": 260, + "wires": [ + [ + "f7196bb1c9ad7882" + ] + ] + }, + { + "id": "a14b6f743fc24f5a", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "set i0", + "func": "flow.set(\"i4\", msg.payload);\nmsg.payload = {};\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 870, + "y": 300, + "wires": [ + [ + "bf55b8bf4a7aaf10" + ] + ] + }, + { + "id": "5e24007ebaf43929", + "type": "ui-switch", + "z": "41526b8c80d5a5f7", + "name": "", + "label": "I4", + "group": "00ea85a0e0b38df3", + "order": 5, + "width": 0, + "height": 0, + "passthru": false, + "decouple": false, + "topic": "topic", + "topicType": "msg", + "style": "", + "className": "", + "layout": "row-spread", + "clickableArea": "switch", + "onvalue": "true", + "onvalueType": "bool", + "onicon": "", + "oncolor": "", + "offvalue": "false", + "offvalueType": "bool", + "officon": "", + "offcolor": "", + "x": 710, + "y": 300, + "wires": [ + [ + "a14b6f743fc24f5a" + ] + ] + }, + { + "id": "3a78dbb26cfb4ced", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "set i0", + "func": "flow.set(\"i5\", msg.payload);\nmsg.payload = {};\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 870, + "y": 340, + "wires": [ + [ + "bf55b8bf4a7aaf10" + ] + ] + }, + { + "id": "3a440beb763d86fb", + "type": "ui-switch", + "z": "41526b8c80d5a5f7", + "name": "", + "label": "I5", + "group": "00ea85a0e0b38df3", + "order": 6, + "width": 0, + "height": 0, + "passthru": false, + "decouple": false, + "topic": "topic", + "topicType": "msg", + "style": "", + "className": "", + "layout": "row-spread", + "clickableArea": "switch", + "onvalue": "true", + "onvalueType": "bool", + "onicon": "", + "oncolor": "", + "offvalue": "false", + "offvalueType": "bool", + "officon": "", + "offcolor": "", + "x": 710, + "y": 340, + "wires": [ + [ + "3a78dbb26cfb4ced" + ] + ] + }, + { + "id": "0da4875391d23ba7", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "set i0", + "func": "flow.set(\"i6\", msg.payload);\nmsg.payload = {};\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 870, + "y": 380, + "wires": [ + [ + "bf55b8bf4a7aaf10" + ] + ] + }, + { + "id": "9a6dbd2385a1e118", + "type": "ui-switch", + "z": "41526b8c80d5a5f7", + "name": "", + "label": "I6", + "group": "00ea85a0e0b38df3", + "order": 7, + "width": 0, + "height": 0, + "passthru": false, + "decouple": false, + "topic": "topic", + "topicType": "msg", + "style": "", + "className": "", + "layout": "row-spread", + "clickableArea": "switch", + "onvalue": "true", + "onvalueType": "bool", + "onicon": "", + "oncolor": "", + "offvalue": "false", + "offvalueType": "bool", + "officon": "", + "offcolor": "", + "x": 710, + "y": 380, + "wires": [ + [ + "0da4875391d23ba7" + ] + ] + }, + { + "id": "6343064ecf3d8a64", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "set i0", + "func": "flow.set(\"i7\", msg.payload);\nmsg.payload = {};\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 870, + "y": 420, + "wires": [ + [ + "bf55b8bf4a7aaf10" + ] + ] + }, + { + "id": "a4bb8403a98d9690", + "type": "ui-switch", + "z": "41526b8c80d5a5f7", + "name": "", + "label": "I7", + "group": "00ea85a0e0b38df3", + "order": 8, + "width": 0, + "height": 0, + "passthru": false, + "decouple": false, + "topic": "topic", + "topicType": "msg", + "style": "", + "className": "", + "layout": "row-spread", + "clickableArea": "switch", + "onvalue": "true", + "onvalueType": "bool", + "onicon": "", + "oncolor": "", + "offvalue": "false", + "offvalueType": "bool", + "officon": "", + "offcolor": "", + "x": 710, + "y": 420, + "wires": [ + [ + "6343064ecf3d8a64" + ] + ] + }, + { + "id": "2eb8008f157e3905", + "type": "debug", + "z": "41526b8c80d5a5f7", + "name": "debug 1", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "statusVal": "", + "statusType": "auto", + "x": 1760, + "y": 500, + "wires": [] + }, + { + "id": "e52bad35a9e3303a", + "type": "change", + "z": "41526b8c80d5a5f7", + "name": "", + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "false", + "tot": "bool" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 350, + "y": 160, + "wires": [ + [ + "ac96af9d69f69372", + "a2dd41c333e61095", + "7fa06bb9fc6290c2", + "a4bb8403a98d9690", + "9a6dbd2385a1e118", + "3a440beb763d86fb", + "5e24007ebaf43929", + "787b142395f2812c" + ] + ] + }, + { + "id": "6144c03f7e61ad75", + "type": "function", + "z": "41526b8c80d5a5f7", + "name": "set arret", + "func": "msg.payload = {\n \"arret\": 0\n};\n\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 860, + "y": 540, + "wires": [ + [ + "bf55b8bf4a7aaf10" + ] + ] + }, { "id": "5fe915fcd26e78ae", "type": "ui-group", @@ -835,7 +1635,21 @@ "type": "ui-group", "name": "Voyants", "page": "bb436fe040268d40", - "width": "3", + "width": "2", + "height": 1, + "order": 3, + "showTitle": true, + "className": "", + "visible": "true", + "disabled": "false", + "groupType": "default" + }, + { + "id": "00ea85a0e0b38df3", + "type": "ui-group", + "name": "Interrupteurs", + "page": "bb436fe040268d40", + "width": "2", "height": 1, "order": 2, "showTitle": true, @@ -920,7 +1734,7 @@ } }, { - "id": "78daa6a123a398db", + "id": "f77ff628addd5fe5", "type": "global-config", "env": [], "modules": { diff --git a/AutomForArduino.cpp b/AutomForArduino.cpp index 31e6304..daf0bbf 100644 --- a/AutomForArduino.cpp +++ b/AutomForArduino.cpp @@ -48,8 +48,10 @@ unsigned long millis() #define OP_ANALOG_WRITE 3 #define OP_PIN_MODE 4 - +int marche = 0; +int arret = 1; int b0, b1, b2, b3, b4, b5, b6, b7; +int i0, i1, i2, i3, i4, i5, i6, i7; int s0, s1, s2, s3, s4, s5, s6, s7; /* ******************************************************** @@ -98,9 +100,15 @@ public: try { json j = json::parse(payload); + marche = 0; arret = 1; + b0 = b1 = b2 = b3 = b4 = b5 = b6 = b7 = 0; + // Ne rien faire si l'objet JSON est vide if (j.empty()) return; + if (j.contains("marche")) marche = j["marche"].get() != 0; + if (j.contains("arret")) arret = j["arret"].get() != 1; + if (j.contains("b0")) b0 = j["b0"].get() != 0; if (j.contains("b1")) b1 = j["b1"].get() != 0; if (j.contains("b2")) b2 = j["b2"].get() != 0; @@ -110,7 +118,16 @@ public: if (j.contains("b6")) b6 = j["b6"].get() != 0; if (j.contains("b7")) b7 = j["b7"].get() != 0; - std::cout << "Pompes : " << b0 << " " << b1 << " " << b2 << " " << b3 << " " << b4 << " " << b5 << " " << b6 << " " << b7 << std::endl; + if (j.contains("i0")) b0 = j["i0"].get() != 0; + if (j.contains("i1")) b1 = j["i1"].get() != 0; + if (j.contains("i2")) b2 = j["i2"].get() != 0; + if (j.contains("i3")) b3 = j["i3"].get() != 0; + if (j.contains("i4")) b4 = j["i4"].get() != 0; + if (j.contains("i5")) b5 = j["i5"].get() != 0; + if (j.contains("i6")) b6 = j["i6"].get() != 0; + if (j.contains("i7")) b7 = j["i7"].get() != 0; + + std::cout << "Pompes : " << marche << " " << arret << " " << b0 << " " << b1 << " " << b2 << " " << b3 << " " << b4 << " " << b5 << " " << b6 << " " << b7 << std::endl; } catch (const json::parse_error& e) { std::cerr << "Erreur JSON : " << e.what() << "\n"; diff --git a/main.cpp b/main.cpp index 3d5aee6..6118324 100644 --- a/main.cpp +++ b/main.cpp @@ -1,13 +1,8 @@ #include "main.hpp" #include "AutomForArduino.cpp" -#undef timeout -#include "mqtt/async_client.h" - int main() { - - mqtt_open(&client); while (1) diff --git a/main.hpp b/main.hpp index e20bd4a..e69de29 100644 --- a/main.hpp +++ b/main.hpp @@ -1,2 +0,0 @@ -#undef timeout -#include "mqtt/async_client.h"