[Lexique de Flows]

Allumage et extinction auto du magic mirror :

[{"id":"2e76b6cc.a0a5ea","type":"bigssh","z":"c9dbdadf.080f58","name":"MM off","commandLine":"vcgencmd display_power 0","commandArgs":"","minError":1,"minWarning":1,"noStdin":false,"format":"","payloadIsArg":false,"myssh":"cff5f578.b112d8","x":570,"y":940,"wires":[[],[],[]]},{"id":"c29d6e19.ab422","type":"delay","z":"c9dbdadf.080f58","name":"5 min -> off","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":410,"y":940,"wires":[["2e76b6cc.a0a5ea"]]},{"id":"d33ba86c.99c7b8","type":"bigssh","z":"c9dbdadf.080f58","name":"MM on","commandLine":"vcgencmd display_power 1","commandArgs":"","minError":1,"minWarning":1,"noStdin":false,"format":"","payloadIsArg":false,"myssh":"cff5f578.b112d8","x":250,"y":940,"wires":[["c29d6e19.ab422"],[],[]]},{"id":"e05d5002.0f276","type":"deconz-input","z":"c9dbdadf.080f58","name":"Pres salon","server":"2fc8d530.641c4a","device":"00:15:8d:00:01:6c:2c:c8-01-0406","device_name":"Pres Salon : ZHAPresence","topic":"","state":"presence","output":"always","outputAtStartup":true,"x":100,"y":940,"wires":[["d33ba86c.99c7b8"],[]]},{"id":"cff5f578.b112d8","type":"SSH_Credentials","z":"","host":"192.168.100.55","port":"22","userlabel":"pi@192.168.100.55"},{"id":"2fc8d530.641c4a","type":"deconz-server","z":0,"name":"vm deconz","ip":"192.168.100.6","port":"801","apikey":"EE419321E6","ws_port":"445","secure":false,"polling":"15"}]

Comparer et récupérer son ip publique :

[{"id":"4389e526.76b52c","type":"inject","z":"c9dbdadf.080f58","name":"Get IP","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"21600","crontab":"","once":false,"onceDelay":"","topic":"ip","payload":"eth0","payloadType":"str","x":120,"y":1020,"wires":[["5b62a74f.f61b28"]]},{"id":"bf4382cf.90aee","type":"function","z":"c9dbdadf.080f58","name":"Compare IP","func":"context.lastip = context.lastip || 'initial';\nvar currentip = msg.payload;\n\nif (context.lastip == 'initial') {\ncontext.lastip = currentip;\n}\nelse if (context.lastip != currentip) {\nmsg.payload = \"My current IP is \"+currentip;\ncontext.lastip = currentip;\nreturn msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":810,"y":1000,"wires":[[]]},{"id":"5b62a74f.f61b28","type":"exec","z":"c9dbdadf.080f58","command":"wget -qO- http://bot.whatismyipaddress.com/ ; echo","addpay":false,"append":"","useSpawn":"","timer":"","name":"Call IP - whatismyipaddress.com","x":323,"y":1019.5,"wires":[["73f26530.3272ec"],[],[]]},{"id":"73f26530.3272ec","type":"switch","z":"c9dbdadf.080f58","name":"Integrity check","property":"payload","propertyType":"msg","rules":[{"t":"regex","v":"\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b","vt":"str","case":false},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":569,"y":1006.5,"wires":[["bf4382cf.90aee"],[]]}]

Template Node-Video :

[{"id":"6d054402.bae15c","type":"tab","label":"template","disabled":false,"info":""},{"id":"357aacf3.bb1a1c","type":"template","z":"6d054402.bae15c","name":"html template","field":"payload","fieldType":"msg","format":"html","syntax":"mustache","template":"\n<table border=\"1\" width=\"500px\">\n    \n    \n    <thead>\n        <tr>\n            <th colspan=\"3\">Messages</th>\n        </tr>\n    </thead>\n    \n    \n    <tr>\n        <th class=\"red\">Message</th>\n        <th class=\"yellow\">Topic</th>\n        <th class=\"blue\" width=\"150\">Time & Date</th>\n\n    </tr>\n    {{#payload}}\n        <tr class=\"\">\n            <td>{{msg}}</td> \n            <td>{{topic}}</td>   \n            <td width=\"150\">{{time}}</td>\n        </tr>\n    {{/payload}}\n</table>\n<h4>Total Messages={{total}}</h4>\n","output":"str","x":300,"y":200,"wires":[["cd697280.7892e8"]]},{"id":"cd697280.7892e8","type":"ui_template","z":"6d054402.bae15c","group":"4a93a592.39efec","name":"Scrolling Messages","order":0,"width":0,"height":0,"format":"\n<style>\n    \n.red\n{\n    background-color:red;\n}\n.yellow\n{\n    background-color:yellow;\n}\n.blue\n{\n    background-color:blue;\n}\n</style>\n<div ng-bind-html=\"msg.payload\"  style=\"width:550px;height:400px\">\n\n</div>","storeOutMessages":false,"fwdInMessages":false,"templateScope":"local","x":470,"y":280,"wires":[[]]},{"id":"1bef68be.08f577","type":"inject","z":"6d054402.bae15c","name":"","topic":"test","payload":"Test Message","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":40,"wires":[["70471bb6.892d64"]]},{"id":"189fecce.8c76bb","type":"debug","z":"6d054402.bae15c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":450,"y":60,"wires":[]},{"id":"70471bb6.892d64","type":"function","z":"6d054402.bae15c","name":"Display Messages","func":"var data=context.get('data')    [];\nvar count=context.get('count');\n\nvar payload=msg.payload;\nvar topic=msg.topic\nif(count==undefined)\n{\n    count=0;\n}\nvar d= new Date();\ncount+=1;\nnow=d.getTime();\nvar s= new Date(now);\nvar mtime=s.getDate()+\"/\"+(s.getMonth()+1)+\"/\" +s.getFullYear()+ \"- \"+ s.getHours() +\":\"+s.getMinutes()+\":\"+s.getSeconds();\nvar mdata={};\n\nmdata.msg=payload.slice(0,30) +\"   \"+ count;\nmdata.time=mtime;\ndata.push(mdata);\nnode.log(\"data \" + data.length);\nif(data.length>10)\n{\n    data.shift();\n}\nif(topic==\"reset\")\n{\ndata=[];\nnode.log(data)\ncount=0;\n}\n\ncontext.set('count',count);\ncontext.set('data',data);\nmsg1={};\n\nmsg1[\"payload\"]=data;\nmsg1.topic=topic;\nmsg1.total=count;\n\nreturn msg1;","outputs":1,"noerr":0,"x":250,"y":120,"wires":[["357aacf3.bb1a1c","189fecce.8c76bb"]]},{"id":"80e0d7eb.2d341","type":"inject","z":"6d054402.bae15c","name":"reset","topic":"reset","payload":"true","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":260,"wires":[["70471bb6.892d64"]]},{"id":"4a93a592.39efec","type":"ui_group","z":"","name":"Test Messages","tab":"c4971399.f6246","disp":true,"width":"12","collapse":false},{"id":"c4971399.f6246","type":"ui_tab","z":"","name":"Demo","icon":"dashboard"}]

Node-Red Join Node:

[{"id":"12188245.461fa6","type":"join","z":"3bd5749e.e1f54c","name":"","mode":"auto","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":",","joinerType":"str","accumulate":false,"timeout":"5","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":330,"y":240,"wires":[["cd1b8a0d.5012d"]]},{"id":"7c8d8943.b849f","type":"change","z":"3bd5749e.e1f54c","name":"","rules":[{"t":"set","p":"note","pt":"msg","to":"from split to join","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":180,"wires":[["12188245.461fa6"]]},{"id":"8dad3092.3faba8","type":"inject","z":"3bd5749e.e1f54c","name":"","topic":"sensors/s1","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":220,"wires":[["12188245.461fa6"]]},{"id":"8f496164.648608","type":"inject","z":"3bd5749e.e1f54c","name":"","topic":"sensors/s2","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":380,"wires":[["12188245.461fa6"]]},{"id":"d61fa349.109cd","type":"inject","z":"3bd5749e.e1f54c","name":"","topic":"sensors/s3","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":500,"wires":[["12188245.461fa6"]]},{"id":"cd1b8a0d.5012d","type":"debug","z":"3bd5749e.e1f54c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":370,"y":340,"wires":[]},{"id":"678cf82e.667b","type":"inject","z":"3bd5749e.e1f54c","name":"","topic":"sensors/s1","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":260,"wires":[["12188245.461fa6"]]},{"id":"6cfb8141.b71698","type":"inject","z":"3bd5749e.e1f54c","name":"","topic":"sensors/s2","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":320,"wires":[["12188245.461fa6"]]},{"id":"298b9682.f8151a","type":"inject","z":"3bd5749e.e1f54c","name":"","topic":"sensors/s3","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":440,"wires":[["12188245.461fa6"]]},{"id":"1ada4439.795e24","type":"inject","z":"3bd5749e.e1f54c","name":"Trigger object","topic":"","payload":"2","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":140,"wires":[["f576cb78.b505b8"]]},{"id":"84fa84e7.7ee948","type":"inject","z":"3bd5749e.e1f54c","name":"Trigger Array","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":80,"wires":[["f576cb78.b505b8"]]},{"id":"4f62c158.f72ef8","type":"inject","z":"3bd5749e.e1f54c","name":"","topic":"","payload":"a/b/c","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":20,"wires":[["f576cb78.b505b8"]]},{"id":"f576cb78.b505b8","type":"function","z":"3bd5749e.e1f54c","name":"array/objects","func":"if (msg.payload==1)\nmsg.payload=[\"test1\",\"test2\",\"test3\"];\nif (msg.payload==2)\nmsg.payload={\"m1\":1,\"m2\":2,\"m3\":3};\n\nreturn msg;","outputs":1,"noerr":0,"x":270,"y":40,"wires":[["510026d2.ea302"]]},{"id":"510026d2.ea302","type":"split","z":"3bd5749e.e1f54c","name":"","splt":"/","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"key","x":310,"y":100,"wires":[["7c8d8943.b849f"]]},{"id":"9ad22841.dee42","type":"debug","z":"3bd5749e.e1f54c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":460,"y":140,"wires":[]}]

Node-Red Split Node:

[{"id":"511abca2.114c34","type":"split","z":"36594091.9c77b","name":"","splt":"/","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"key","x":290,"y":200,"wires":[["898a2137.27e898"]]},{"id":"e0ccef54.67ff4","type":"inject","z":"36594091.9c77b","name":"Trigger Array","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":100,"wires":[["14501dde.5df062"]]},{"id":"14501dde.5df062","type":"function","z":"36594091.9c77b","name":"array/objects","func":"if (msg.payload==1)\nmsg.payload=[\"test1\",\"test2\",\"test3\"];\nif (msg.payload==2)\nmsg.payload={\"m1\":1,\"m2\":2,\"m3\":3};\n\nreturn msg;","outputs":1,"noerr":0,"x":270,"y":60,"wires":[["511abca2.114c34"]]},{"id":"898a2137.27e898","type":"debug","z":"36594091.9c77b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":410,"y":120,"wires":[]},{"id":"c06c0641.045b48","type":"inject","z":"36594091.9c77b","name":"Trigger object","topic":"","payload":"2","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":160,"wires":[["14501dde.5df062"]]},{"id":"ce50ea2d.d9e548","type":"inject","z":"36594091.9c77b","name":"","topic":"","payload":"a/b/c","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":40,"wires":[["14501dde.5df062"]]},{"id":"38402fb3.1b519","type":"mqtt in","z":"36594091.9c77b","name":"","topic":"sensors/house/status","qos":"2","broker":"d2b9a9a5.812e58","x":120,"y":320,"wires":[["e69491a6.2f43d8"]]},{"id":"30943bbd.d5ea34","type":"split","z":"36594091.9c77b","name":"","splt":",","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"key","x":350,"y":440,"wires":[["69e28bf5.580afc"]]},{"id":"45bc768c.5ede2","type":"debug","z":"36594091.9c77b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":390,"y":320,"wires":[]},{"id":"c41ffe4.2b0e6","type":"mqtt out","z":"36594091.9c77b","name":"","topic":"","qos":"0","retain":"","broker":"d2b9a9a5.812e58","x":370,"y":520,"wires":[]},{"id":"e69491a6.2f43d8","type":"json","z":"36594091.9c77b","name":"","property":"payload","action":"","pretty":false,"x":130,"y":440,"wires":[["30943bbd.d5ea34"]]},{"id":"69e28bf5.580afc","type":"change","z":"36594091.9c77b","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"\"sensors/status/\" & key","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":150,"y":520,"wires":[["c41ffe4.2b0e6","45bc768c.5ede2"]]},{"id":"e0263c6f.ff92d8","type":"inject","z":"36594091.9c77b","name":"","topic":"sensors/house/status","payload":"{\"door\":\"open\",\"light1\":\"off\",\"temp\":21}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":620,"wires":[["c41ffe4.2b0e6"]]},{"id":"d2b9a9a5.812e58","type":"mqtt-broker","z":"","name":"","broker":"192.168.1.157","port":"1883","clientid":"testmqtt","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""}]

Check Batteries :

[{"id":"40af4456.39688c","type":"comment","z":"c9dbdadf.080f58","name":"Check Batteries ____________________________________________________","info":"","x":1320,"y":820,"wires":[]},{"id":"d0eb02db.7a3be","type":"inject","z":"c9dbdadf.080f58","name":"18:00","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 18 * * *","once":false,"onceDelay":"8","topic":"","payload":"","payloadType":"date","x":1090,"y":880,"wires":[["ba5b15ac.4792e8"]]},{"id":"ba5b15ac.4792e8","type":"ha-get-entities","z":"c9dbdadf.080f58","server":"d6c87e34.afcee","name":"","rules":[{"property":"attributes.device_class","logic":"is","value":"battery","valueType":"str"},{"property":"attributes.unit_of_measurement","logic":"is","value":"%","valueType":"str"}],"output_type":"array","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":1250,"y":880,"wires":[["3395e4b3.17f77c"]]},{"id":"3395e4b3.17f77c","type":"function","z":"c9dbdadf.080f58","name":"if < 100% and remove phone","func":"state_ok = 99;\nstate_warning = 15;\nstate_low = 65;\n\nexclude = [\n    \"sensor.oneplus_a6010_battery_level\",\n    \"sensor.oneplus_a5000_battery_level\"\n];\n\ninput = msg.payload;\nmessage = \"\";\n\nfor(let id in input) {\n    if (input[id].state <= state_ok && exclude.includes(input[id].entity_id) === false) {\n        name = input[id].attributes.friendly_name;\n        state = input[id].state;\n        if (parseInt(state) <= state_warning) {\n            // < 15%\n            message = message+\"> :red_envelope: \"+name+\" : \"+state+\"%\\n\";\n        }else if (parseInt(state) <= state_low) {\n            // < 30%\n            message = message+\"> :small_orange_diamond: \"+name+\" : \"+state+\"%\\n\";\n        }else{\n            // OK\n            message = message+\"> :battery: \"+name+\" : \"+state+\"%\\n\";\n        }\n    }\n}\n\nif (message !== \"\" ) {\n    msg.message = message;\n    return msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1490,"y":880,"wires":[["5da8d69a.c71aa8"]]},{"id":"d6c87e34.afcee","type":"server","z":"","name":"Home Assistant ip","legacy":false,"addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
1 J'aime

Il y a moyen d’avoir une explication des différents flows :pleading_face: :pray:?

Ce qu’ils font/vérifient, afin d’associer les explications avec les nœuds.

Merci.

Node-Red Join Node: ??

Node-Red Split Node: ??

Template Node-Video : ??

Node-Red Join Node : https://cookbook.nodered.org/basic/join-streams

Node-Red Split Node : https://discourse.nodered.org/t/split-the-string-into-separate-values/2818

Template Node-Video : https://www.youtube.com/watch?v=7S57bPBe_G8

1 J'aime