Mini-Tuto Liaison MQTT IPX800-V5 Node-red (sur Home-Assistant)

Allez dans l’onglet « Système »
image
Cliquez sur « MQTT »
image
Parametrer comme suit, avec pour « Serveur: " l’ip du broker mosquito, en « Client ID » le nom que vous voudrez (j’ai mis ici IPX800_V5-1 c’est important pour les paramétrage des Topic dans Node-red)


Ensuite on va dans l’onglet « Liens »
image
Puis dans le sous-onglet « OBJETS » et on clique sur « MQTT Publish »

et « Ajouter MQTT publish »

Cela crée un objet « Publish » nommé « TOPIC PUB N° » on clique sur « Edition »
On le paramètre comme ci-dessous
image
Le « Nom: » c’est le nom que l’on retrouves dans l’Api-Deck de GCE et pointe vers le nom du « Relais 1 » si on édite ce nom dans l’IPX il se met à jour dans l’Api-Deck (il sera le même pour les appels API et http je suppose) « URL » correspond à « Client-ID » paramétré dans « Système » « MQTT » (on peut aussi mettre directement la valeur _id soit pour le relais 1 : 65536 etc, comme cela quel que soit le nom donné à l’instance du relais 1on est tranquille !)
On active « JSON » et on met en clé la même valeur que le nom

Ensuite on va créer l’objet « Suscribe ». On clique sur « MQTT suscribe » puis « Ajouter MQTT suscribe » et « Edition »

Cela crée un objet « Suscribe » nommé « TOPIC SUB N° » on clique sur « Edition »
On le paramètre comme ci-dessous,
image
en se référant à l’Api-Deck

On clique sur l’onglet à gauche « Dasboard »
image
puis « Ajouter widget »
image
puis « Edition »
image
On sélectionne « Contrôle » « Bouton poussoir » et « Valider »

On paramètre comme suit

On ajoute un autre widget paramétré comme suit avec cette fois un contrôle « Matrice de voyant »
image
Maintenant on va crée les liens en cliquant à gauche sur l’onglet « Liens »
image
Puis le « + » à gauche du » [IPX]Relay cmd1"

puis à gauche sur « MQTT Suscribe » qu’on fait glisser sur la zone pointillée
on paramètre comme suit
image
On obtient
image
On clique sur « Etat Relais » et « + » à droite de « [IPX]Relay State 1 »

puis à gauche sur « MQTT Publish » qu’on fait glisser sur la zone pointillée
on paramètre comme suit
image
Ça y est on a fait toute la partie « IPX800V5 » on va attaquer la partie NodeRed…après une bonne nuit :sleeping: !
Mais voila déjà le flow à importer dans node-red de « Home-assistant » (avec un broker Mosquito) :wink:

[{"id":"d7b52ad658584def","type":"tab","label":"IPX800_V5","disabled":false,"info":"","env":[]},{"id":"89ca679478a1c70c","type":"debug","z":"d7b52ad658584def","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":510,"y":360,"wires":[]},{"id":"d75e94b705841e6c","type":"inject","z":"d7b52ad658584def","name":"[IPX]Relay cmd 1 = true","props":[{"p":"topic","vt":"str"},{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"IPX800_V5","payload":"{\"[IPX]Relay cmd 1\":true}","payloadType":"str","x":240,"y":120,"wires":[["fd3e64239507545f"]]},{"id":"e18a09ae155d9edb","type":"inject","z":"d7b52ad658584def","name":"[IPX]Relay cmd 1 = false","props":[{"p":"topic","vt":"str"},{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"IPX800_V5","payload":"{\"[IPX]Relay cmd 1\":false}","payloadType":"str","x":250,"y":220,"wires":[["fd3e64239507545f"]]},{"id":"607d92d1e7c8a9ab","type":"mqtt in","z":"d7b52ad658584def","name":"","topic":"IPX800_V5-1","qos":"2","datatype":"auto","broker":"291914c5c9c68f02","nl":false,"rap":true,"rh":0,"inputs":0,"x":210,"y":360,"wires":[["89ca679478a1c70c"]]},{"id":"fd3e64239507545f","type":"mqtt out","z":"d7b52ad658584def","name":"","topic":"IPX800_V5-1","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"291914c5c9c68f02","x":490,"y":160,"wires":[]},{"id":"291914c5c9c68f02","type":"mqtt-broker","name":"mqtt","broker":"192.168.0.199","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]

Ci dessous un flow plus fourni, il faut cliquer sur les 3 barres horizontales dans la partie droite de node-red (sur home-assistant dans mon cas) puis cliquer sur « import »
image
On clique sur « New flow » et on colle dans la zone en rose

[{"id":"e3be7f6c7f5d8711","type":"tab","label":"IPX800_V5-Commande Relais via MQTT","disabled":false,"info":"","env":[]},{"id":"e65edf1a.d0a338","type":"function","z":"e3be7f6c7f5d8711","name":"Affiche Etat Relais","func":"var msg1,msg2,msg3,msg4,msg5,msg6,msg7,msg8;\n\nswitch (msg.payload) {\n  case \"{\\\"[IPX]Relay state 1\\\":true}\":\n    msg1 = {payload:\"on\" };\n    break;\n  case \"{\\\"[IPX]Relay state 1\\\":false}\":\n    msg1 = {payload:\"off\" };\n    break;\n  case \"{\\\"[IPX]Relay state 2\\\":true}\":\n    msg2 = {payload:\"on\" };\n    break;\n  case \"{\\\"[IPX]Relay state 2\\\":false}\":\n    msg2 = {payload:\"off\" };\n    break;  \n  case \"{\\\"[IPX]Relay state 3\\\":true}\":\n    msg3 = {payload:\"on\" };\n    break;\n  case \"{\\\"[IPX]Relay state 3\\\":false}\":\n    msg3 = {payload:\"off\" };\n    break;  \n  case \"{\\\"[IPX]Relay state 4\\\":true}\":\n    msg4 = {payload:\"on\" };\n    break;\n  case \"{\\\"[IPX]Relay state 4\\\":false}\":\n    msg4 = {payload:\"off\" };\n    break;\n  case \"{\\\"[IPX]Relay state 5\\\":true}\":\n    msg5 = {payload:\"on\" };\n    break;\n  case \"{\\\"[IPX]Relay state 5\\\":false}\":\n    msg5 = {payload:\"off\" };\n    break;\n  case \"{\\\"[IPX]Relay state 6\\\":true}\":\n    msg6 = {payload:\"on\" };\n    break;\n  case \"{\\\"[IPX]Relay state 6\\\":false}\":\n    msg6 = {payload:\"off\" };\n    break;\n  case \"{\\\"[IPX]Relay state 7\\\":true}\":\n    msg7 = {payload:\"on\" };\n    break;\n  case \"{\\\"[IPX]Relay state 7\\\":false}\":\n    msg7 = {payload:\"off\" };\n    break;\n  case \"{\\\"[IPX]Relay state 8\\\":true}\":\n    msg8 = {payload:\"on\" };\n    break;\n  case \"{\\\"[IPX]Relay state 8\\\":false}\":\n    msg8 = {payload:\"off\" };\n    break;\n  default:\n    break;\n}\n\nreturn[msg1,msg2,msg3,msg4,msg5,msg6,msg7,msg8];\n","outputs":8,"noerr":0,"initialize":"","finalize":"","libs":[],"x":710,"y":220,"wires":[["7e1d5f6d.19be5"],["26b49fab.110ba8"],["c8b4e6d7.b5b46"],["7ad30c74.14d164"],["ff8f88911dc75bf2"],["8d9f23d264e90c8e"],["7b15722c7137c127"],["ac8faad3c2969aea"]]},{"id":"a8d09b96.1f6588","type":"ui_switch","z":"e3be7f6c7f5d8711","name":"","label":"Relais 1","tooltip":"","group":"df9ed293.78c83","order":2,"width":6,"height":1,"passthru":true,"decouple":"false","topic":"IPX800_V5-1","topicType":"str","style":"","onvalue":"{\"[IPX]Relay cmd 1\":true}","onvalueType":"str","onicon":"","oncolor":"","offvalue":"{\"[IPX]Relay cmd 1\":false}","offvalueType":"str","officon":"","offcolor":"","animate":true,"className":"","x":100,"y":80,"wires":[["c644f17a96da3663"]]},{"id":"e8f82c99.6ec6e8","type":"ui_switch","z":"e3be7f6c7f5d8711","name":"","label":"Relais 2","tooltip":"","group":"df9ed293.78c83","order":4,"width":6,"height":1,"passthru":false,"decouple":"false","topic":"IPX800_V5","topicType":"str","style":"","onvalue":"{\"[IPX]Relay cmd 2\":true};","onvalueType":"str","onicon":"","oncolor":"","offvalue":"{\"[IPX]Relay cmd 2\":false};","offvalueType":"str","officon":"","offcolor":"","animate":true,"className":"","x":100,"y":120,"wires":[["c644f17a96da3663"]]},{"id":"782c9d93.23d61c","type":"ui_switch","z":"e3be7f6c7f5d8711","name":"","label":"Relais 3","tooltip":"","group":"df9ed293.78c83","order":6,"width":6,"height":1,"passthru":false,"decouple":"false","topic":"IPX800_V5","topicType":"str","style":"","onvalue":"{\"[IPX]Relay cmd 3\":true};","onvalueType":"str","onicon":"","oncolor":"","offvalue":"{\"[IPX]Relay cmd 3\":false};","offvalueType":"str","officon":"","offcolor":"","animate":true,"className":"","x":100,"y":160,"wires":[["c644f17a96da3663"]]},{"id":"d7d45164.eb5f18","type":"ui_switch","z":"e3be7f6c7f5d8711","name":"","label":"Relais 4","tooltip":"","group":"df9ed293.78c83","order":8,"width":6,"height":1,"passthru":false,"decouple":"false","topic":"IPX800_V5","topicType":"str","style":"","onvalue":"{\"[IPX]Relay cmd 4\":true};","onvalueType":"str","onicon":"","oncolor":"","offvalue":"{\"[IPX]Relay cmd 4\":false};","offvalueType":"str","officon":"","offcolor":"","animate":true,"className":"","x":100,"y":200,"wires":[["c644f17a96da3663"]]},{"id":"7e1d5f6d.19be5","type":"ui_text","z":"e3be7f6c7f5d8711","group":"df9ed293.78c83","order":3,"width":6,"height":1,"name":" Etat Relais 1","label":" Etat Relais 1","format":"{{msg.payload}}","layout":"row-spread","className":"","x":930,"y":80,"wires":[],"inputLabels":["r1"]},{"id":"26b49fab.110ba8","type":"ui_text","z":"e3be7f6c7f5d8711","group":"df9ed293.78c83","order":5,"width":6,"height":1,"name":" Etat Relais 2","label":" Etat Relais 2","format":"{{msg.payload}}","layout":"row-spread","className":"","x":930,"y":120,"wires":[],"inputLabels":["r2"]},{"id":"c8b4e6d7.b5b46","type":"ui_text","z":"e3be7f6c7f5d8711","group":"df9ed293.78c83","order":7,"width":6,"height":1,"name":" Etat Relais 3","label":" Etat Relais 3","format":"{{msg.payload}}","layout":"row-spread","className":"","x":930,"y":160,"wires":[],"inputLabels":["r3"]},{"id":"7ad30c74.14d164","type":"ui_text","z":"e3be7f6c7f5d8711","group":"df9ed293.78c83","order":9,"width":6,"height":1,"name":" Etat Relais 4","label":" Etat Relais 4","format":"{{msg.payload}}","layout":"row-spread","className":"","x":930,"y":200,"wires":[],"inputLabels":["r4"]},{"id":"5ec26aa03f60a111","type":"ui_switch","z":"e3be7f6c7f5d8711","name":"","label":"Relais 5","tooltip":"","group":"df9ed293.78c83","order":10,"width":6,"height":1,"passthru":true,"decouple":"false","topic":"IPX800_V5","topicType":"str","style":"","onvalue":"{\"[IPX]Relay cmd 5\":true};","onvalueType":"str","onicon":"","oncolor":"","offvalue":"{\"[IPX]Relay cmd 5\":false};","offvalueType":"str","officon":"","offcolor":"","animate":true,"className":"","x":100,"y":240,"wires":[["c644f17a96da3663"]]},{"id":"cbe63d1b95aa083b","type":"ui_switch","z":"e3be7f6c7f5d8711","name":"","label":"Relais 6","tooltip":"","group":"df9ed293.78c83","order":12,"width":6,"height":1,"passthru":false,"decouple":"false","topic":"IPX800_V5","topicType":"str","style":"","onvalue":"{\"[IPX]Relay cmd 6\":true};","onvalueType":"str","onicon":"","oncolor":"","offvalue":"{\"[IPX]Relay cmd 6\":false};","offvalueType":"str","officon":"","offcolor":"","animate":true,"className":"","x":100,"y":280,"wires":[["c644f17a96da3663"]]},{"id":"6ffcf69741608555","type":"ui_switch","z":"e3be7f6c7f5d8711","name":"","label":"Relais 7","tooltip":"","group":"df9ed293.78c83","order":14,"width":6,"height":1,"passthru":false,"decouple":"false","topic":"IPX800_V5","topicType":"str","style":"","onvalue":"{\"[IPX]Relay cmd 7\":true};","onvalueType":"str","onicon":"","oncolor":"","offvalue":"{\"[IPX]Relay cmd 7\":false};","offvalueType":"str","officon":"","offcolor":"","animate":true,"className":"","x":100,"y":320,"wires":[["c644f17a96da3663"]]},{"id":"fa436c0477a8ef01","type":"ui_switch","z":"e3be7f6c7f5d8711","name":"","label":"Relais 8","tooltip":"","group":"df9ed293.78c83","order":16,"width":6,"height":1,"passthru":false,"decouple":"false","topic":"IPX800_V5","topicType":"str","style":"","onvalue":"{\"[IPX]Relay cmd 8\":true};","onvalueType":"str","onicon":"","oncolor":"","offvalue":"{\"[IPX]Relay cmd 8\":false};","offvalueType":"str","officon":"","offcolor":"","animate":true,"className":"","x":100,"y":360,"wires":[["c644f17a96da3663"]]},{"id":"baa30411f5355530","type":"mqtt in","z":"e3be7f6c7f5d8711","name":"IPX800_V5-1","topic":"IPX800_V5-1","qos":"2","datatype":"auto","broker":"291914c5c9c68f02","nl":false,"rap":true,"rh":0,"inputs":0,"x":510,"y":220,"wires":[["e65edf1a.d0a338","b849eb43.c1726","c9516e8c77b8e2de"]]},{"id":"c644f17a96da3663","type":"mqtt out","z":"e3be7f6c7f5d8711","name":"IPX800_V5-1","topic":"IPX800_V5-1","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"291914c5c9c68f02","x":330,"y":220,"wires":[]},{"id":"b849eb43.c1726","type":"ui_text","z":"e3be7f6c7f5d8711","group":"df9ed293.78c83","order":1,"width":0,"height":0,"name":"Notification","label":"Notification","format":"{{msg.payload}}","layout":"row-spread","className":"","x":690,"y":140,"wires":[]},{"id":"ff8f88911dc75bf2","type":"ui_text","z":"e3be7f6c7f5d8711","group":"df9ed293.78c83","order":11,"width":6,"height":1,"name":" Etat Relais 5","label":" Etat Relais 5","format":"{{msg.payload}}","layout":"row-spread","className":"","x":930,"y":240,"wires":[],"inputLabels":["r5"]},{"id":"8d9f23d264e90c8e","type":"ui_text","z":"e3be7f6c7f5d8711","group":"df9ed293.78c83","order":13,"width":6,"height":1,"name":" Etat Relais 6","label":" Etat Relais 6","format":"{{msg.payload}}","layout":"row-spread","className":"","x":930,"y":280,"wires":[],"inputLabels":["r6"]},{"id":"7b15722c7137c127","type":"ui_text","z":"e3be7f6c7f5d8711","group":"df9ed293.78c83","order":15,"width":6,"height":1,"name":" Etat Relais 7","label":" Etat Relais 7","format":"{{msg.payload}}","layout":"row-spread","className":"","x":930,"y":320,"wires":[],"inputLabels":["r7"]},{"id":"ac8faad3c2969aea","type":"ui_text","z":"e3be7f6c7f5d8711","group":"df9ed293.78c83","order":17,"width":6,"height":1,"name":" Etat Relais 8","label":" Etat Relais 8","format":"{{msg.payload}}","layout":"row-spread","className":"","x":930,"y":360,"wires":[],"inputLabels":["r8"]},{"id":"c9516e8c77b8e2de","type":"debug","z":"e3be7f6c7f5d8711","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":690,"y":300,"wires":[]},{"id":"fbe76b57b5945d08","type":"inject","z":"e3be7f6c7f5d8711","name":"[IPX]Relay cmd 1 = true","props":[{"p":"topic","vt":"str"},{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"IPX800_V5-1","payload":"{\"[IPX]Relay cmd 1\":true}","payloadType":"str","x":160,"y":440,"wires":[["c644f17a96da3663"]]},{"id":"260c47e804b60821","type":"inject","z":"e3be7f6c7f5d8711","name":"[IPX]Relay cmd 1 = false","props":[{"p":"topic","vt":"str"},{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"IPX800_V5-1","payload":"{\"[IPX]Relay cmd 1\":false}","payloadType":"str","x":170,"y":480,"wires":[["c644f17a96da3663"]]},{"id":"df9ed293.78c83","type":"ui_group","name":"Relais","tab":"4414d280.f20c4c","order":1,"disp":true,"width":"12","collapse":true,"className":""},{"id":"291914c5c9c68f02","type":"mqtt-broker","name":"mqtt","broker":"192.168.0.199","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""},{"id":"4414d280.f20c4c","type":"ui_tab","name":"IPX800_V5 Dashboard","icon":"dashboard","disabled":false,"hidden":false}]

Vous aurez le flow suivant


En cliquant sur
image
Node-red crée une paghe html avec une IP comme celle-ci « http://192.168.0.245:1880/endpoint/ui/#!/0?socketid=ivu6sf9GhBfkZ3x6AAAg » et bascule dessus

On peut alors activer le relais 1 (les autres n’ont pas de liaison MQTT active à ce stade !) et l’état du relais sera reflété en cliquant directement dans l’IPX sur le widget créé plus haut (cela pourrait être l’état d’un inter sur une entreé digitale pilotant une lampe sur le relais 1). Voila fin du mini tuto si cela peut aider certains tant mieux ! :wink: Il faudra bien sur adapter les IP du serveur Mosquito et de l’IPX dans le tuto ainsi que dans le flow mosquito !

5 « J'aime »

Petite précision, si vous avez du mal a visualiser le dashboard cliquez sur l’icône à droite en forme d’histogramme.

image

Puis la le petit carré avec la flèche (ici entouré en rouge)

image