10-05-2022, 06:17 PM
Voici le code utilisé dans la démo "https://youtu.be/DhYyicJD-Fo"
"Accès aux batteries Pylontech et ensuite démo lecture des données la domotique sous Nodered"
Disponible soit en clair ci-dessous ou alors en fichier à télécharger directement
"Accès aux batteries Pylontech et ensuite démo lecture des données la domotique sous Nodered"
Disponible soit en clair ci-dessous ou alors en fichier à télécharger directement
Code :
[
{
"id": "c3961ef2ba359cf4",
"type": "tab",
"label": "démo",
"disabled": false,
"info": "",
"env": []
},
{
"id": "8ea84dee3f010158",
"type": "ui_template",
"z": "c3961ef2ba359cf4",
"group": "16353272e83592ac",
"name": "",
"order": 5,
"width": 15,
"height": 10,
"format": "\n<!--<pre><code id=\"shell\" class=\"language-bash bash\" ng-bind=\"msg.payload\"></code></pre>-->\n<pre><code id=\"shell\" class=\"language-bash bash\"></code></pre>\n\n<script>\n $(document).ready(function() {\n $('#shell').each(function(i, e) {hljs.highlightElement(e)});\n }); \n</script>\n\n\n<script>\n(function(scope) {\n scope.$watch('msg', function(msg) {\n if (msg) {\n debugger\n $(\"#shell\").text(msg.payload);\n $('#shell').each(function(i, e) {hljs.highlightElement(e)});\n //$(\"#shell\").scrollTop(function() { return this.scrollHeight; });\n $(\"#shell\").closest(\".nr-dashboard-template\").scrollTop(function() { return this.scrollHeight; });\n }\n });\n})(scope);\n</script>",
"storeOutMessages": true,
"fwdInMessages": true,
"resendOnRefresh": true,
"templateScope": "local",
"className": "",
"x": 720,
"y": 100,
"wires": [
[]
]
},
{
"id": "99256957e388dfee",
"type": "function",
"z": "c3961ef2ba359cf4",
"name": "",
"func": "if(!msg.payload) return;\n\nconst MAXLINES = 200;\nlet data = context.get(\"data\") || [];\nif(msg.topic==\"clear\") {\n data = [];\n} else {\n const lines = msg.payload.split(\"\\n\");\n data.push(...lines);\n data = data.slice(-MAXLINES);\n}\ncontext.set(\"data\", data);\nmsg.payload = data.join(\"\\n\");\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 560,
"y": 100,
"wires": [
[
"8ea84dee3f010158"
]
]
},
{
"id": "eed933e69c164694",
"type": "inject",
"z": "c3961ef2ba359cf4",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": "1",
"topic": "",
"payload": "coucou",
"payloadType": "str",
"x": 360,
"y": 100,
"wires": [
[
"99256957e388dfee"
]
]
},
{
"id": "0b01bbdcfd3549e9",
"type": "inject",
"z": "c3961ef2ba359cf4",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": "2",
"topic": "",
"payload": "coucou2",
"payloadType": "str",
"x": 388,
"y": 139,
"wires": [
[
"99256957e388dfee"
]
]
},
{
"id": "6001b1b3aa334b33",
"type": "inject",
"z": "c3961ef2ba359cf4",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": "3",
"topic": "",
"payload": "coucou3",
"payloadType": "str",
"x": 420,
"y": 180,
"wires": [
[
"99256957e388dfee"
]
]
},
{
"id": "16353272e83592ac",
"type": "ui_group",
"name": "display",
"tab": "2a33392ec021348e",
"order": 1,
"disp": true,
"width": "15",
"collapse": false,
"className": ""
},
{
"id": "2a33392ec021348e",
"type": "ui_tab",
"name": "Display",
"icon": "dashboard",
"order": 9,
"disabled": false,
"hidden": false
}
]
Jean-Luc