Skip to content

Instantly share code, notes, and snippets.

@infosmick
Created December 22, 2016 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save infosmick/287778ed97468460a069bade8391d7f8 to your computer and use it in GitHub Desktop.
Save infosmick/287778ed97468460a069bade8391d7f8 to your computer and use it in GitHub Desktop.
Smick_001_console_v2

This flow builds a dashboard console to interact with Smick through MQTT feed. You can send commands on Smick input feed and receive answers or events from Smick output feed. It also contains an input node link to allow other flows sending commands and an output node link to direct responses / events received to other streams. Finally sent messages and replies / received events are listed on debug tab using debug nodes.

[
{
"id": "19c12462.66b3bc",
"type": "mqtt out",
"z": "35add6f9.6f79aa",
"name": "smick command",
"topic": "borot/feeds/I3300460880",
"qos": "0",
"retain": "true",
"broker": "2b829d41.9896e2",
"x": 1040,
"y": 260,
"wires": []
},
{
"id": "c4845dca.f1ada",
"type": "debug",
"z": "35add6f9.6f79aa",
"name": "debug command",
"active": true,
"console": "false",
"complete": "payload",
"x": 850,
"y": 200,
"wires": []
},
{
"id": "9d66070d.ef1148",
"type": "ui_text_input",
"z": "35add6f9.6f79aa",
"name": "",
"label": "command",
"group": "3d9d3a1b.1d4626",
"order": 1,
"width": "0",
"height": "0",
"passthru": true,
"mode": "text",
"delay": "0",
"topic": "",
"x": 660,
"y": 260,
"wires": [
[
"19c12462.66b3bc",
"c4845dca.f1ada"
]
]
},
{
"id": "189e33a8.68461c",
"type": "ui_text",
"z": "35add6f9.6f79aa",
"group": "3d9d3a1b.1d4626",
"order": 2,
"width": "0",
"height": "0",
"name": "",
"label": "response/event",
"format": "{{msg.payload}}",
"layout": "col-center",
"x": 680,
"y": 560,
"wires": []
},
{
"id": "b2782229.91ed3",
"type": "mqtt in",
"z": "35add6f9.6f79aa",
"name": "smick event",
"topic": "borot/feeds/O3300460880",
"qos": "0",
"broker": "2b829d41.9896e2",
"x": 170,
"y": 560,
"wires": [
[
"189e33a8.68461c",
"e25d39ab.fd0ba8",
"290027bd.4e4828",
"ef58ae73.272f"
]
]
},
{
"id": "d00f3010.4b85b",
"type": "link in",
"z": "35add6f9.6f79aa",
"name": "command",
"links": [
"5f462c.328339d4",
"76792d1c.717924",
"82283593.256f98",
"82435511.10dbd8",
"b844a46a.517bf8",
"d025d81e.e6dcd8",
"411cecf.b196714"
],
"x": 335,
"y": 260,
"wires": [
[
"9d66070d.ef1148"
]
]
},
{
"id": "e25d39ab.fd0ba8",
"type": "debug",
"z": "35add6f9.6f79aa",
"name": "debug event",
"active": true,
"console": "false",
"complete": "payload",
"x": 870,
"y": 500,
"wires": []
},
{
"id": "7d4ffb9e.d199a4",
"type": "comment",
"z": "35add6f9.6f79aa",
"name": "dashboard",
"info": "",
"x": 660,
"y": 100,
"wires": []
},
{
"id": "b134654e.8ec2e8",
"type": "comment",
"z": "35add6f9.6f79aa",
"name": "mqtt in",
"info": "",
"x": 150,
"y": 100,
"wires": []
},
{
"id": "97d5933b.f5e57",
"type": "comment",
"z": "35add6f9.6f79aa",
"name": "mqtt out",
"info": "",
"x": 1030,
"y": 100,
"wires": []
},
{
"id": "9e65531e.5158e",
"type": "comment",
"z": "35add6f9.6f79aa",
"name": "link",
"info": "",
"x": 310,
"y": 100,
"wires": []
},
{
"id": "809a9c53.5adfb",
"type": "comment",
"z": "35add6f9.6f79aa",
"name": "debug",
"info": "",
"x": 840,
"y": 100,
"wires": []
},
{
"id": "4f78e14f.22524",
"type": "comment",
"z": "35add6f9.6f79aa",
"name": "Licence & History",
"info": "Package : Smick v.1\nModule : console\nAuthor : Curci\nLicence : (CC) BY-NC-SA\n\nThis work is licensed under a Creative Commons \nAttribution-NonCommercial-ShareAlike \n4.0 International License.\n\nHistory\n\nDate Author Description\n2016.12.17 Curci genesis",
"x": 340,
"y": 40,
"wires": []
},
{
"id": "3cadbe22.6eb532",
"type": "comment",
"z": "35add6f9.6f79aa",
"name": "Description",
"info": "Questo flusso costruisce un cruscotto console per interagire con smick tramite feed mqtt.\nSi possono inviare comandi sul feed di input di smick e ricevere risposte o eventi dal feed di output di smick.\nContiene inoltre un nodo link di input per consentire ad altri flussi l'invio di comandi e un nodo link di output per smistare risposte/eventi ricevuti ad altri flussi.\nInfine i messaggi inviati e le risposte / eventi ricevuti sono elencati su debug tab mediante nodi debug.\n\n\nThis flow builds a dashboard console to interact with Smick through MQTT feed.\nYou can send commands on Smick input feed and receive answers or events from Smick output feed.\nIt also contains an input node link to allow other flows sending commands and an output node link to direct responses / events received to other streams.\nFinally sent messages and replies / received events are listed on debug tab using debug nodes.\n\n",
"x": 160,
"y": 40,
"wires": []
},
{
"id": "fe3932ad.58c69",
"type": "comment",
"z": "35add6f9.6f79aa",
"name": "BOM",
"info": "Bill Of Material\n\nHardware:\n\n 1 Human internet terminal (PC, tablet or smartphone) connected to the internet\n 1 Smick Wi-Fi connected to the internet\n\nHW Connections:\n\n None.\n\nFlow Connections:\n\n None\n\nAccount:\n\n Wi-Fi credentials\n MQTT broker\n FRED\n",
"x": 490,
"y": 40,
"wires": []
},
{
"id": "65c026c0.fda4e8",
"type": "ui_toast",
"z": "35add6f9.6f79aa",
"position": "bottom right",
"displayTime": "3",
"name": "conn/disc notification",
"x": 680,
"y": 680,
"wires": []
},
{
"id": "f227495f.309fd8",
"type": "ui_text",
"z": "35add6f9.6f79aa",
"group": "a9a923ec.3a3fa",
"order": 1,
"width": 0,
"height": 0,
"name": "State",
"label": "",
"format": "{{msg.payload}}",
"layout": "col-center",
"x": 690,
"y": 740,
"wires": []
},
{
"id": "76d5ef63.be81d",
"type": "change",
"z": "35add6f9.6f79aa",
"name": "Event to msg",
"rules": [
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "DISC",
"fromt": "str",
"to": "Disconnected",
"tot": "str"
},
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "CONN",
"fromt": "str",
"to": "Connected",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 330,
"y": 680,
"wires": [
[
"65c026c0.fda4e8",
"75d0abe2.e4fe04"
]
]
},
{
"id": "290027bd.4e4828",
"type": "link out",
"z": "35add6f9.6f79aa",
"name": "response_event",
"links": [
"4a2e69f2.1bb9e8",
"b4d0698e.ffcdc8",
"c8f76d6f.f022e",
"e6305255.f5035"
],
"x": 335,
"y": 400,
"wires": []
},
{
"id": "ef58ae73.272f",
"type": "switch",
"z": "35add6f9.6f79aa",
"name": "parse",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "regex",
"v": "CONN|DISC",
"vt": "str",
"case": true
},
{
"t": "else"
}
],
"checkall": "false",
"outputs": 2,
"x": 170,
"y": 720,
"wires": [
[
"76d5ef63.be81d"
],
[]
]
},
{
"id": "925e41a1.df9c7",
"type": "change",
"z": "35add6f9.6f79aa",
"name": "Event to msg",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Connected",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 330,
"y": 780,
"wires": [
[]
]
},
{
"id": "ee30ac4c.23d9f",
"type": "comment",
"z": "35add6f9.6f79aa",
"name": "parsing",
"info": "",
"x": 470,
"y": 100,
"wires": []
},
{
"id": "75d0abe2.e4fe04",
"type": "function",
"z": "35add6f9.6f79aa",
"name": "state msg",
"func": "function timeDate(tz) {\n var d = new Date(Date.now()+tz*3600000);\n\n return d.getUTCHours() + \":\" +\n format00(d.getUTCMinutes()) + \":\" +\n format00(d.getUTCSeconds()) + \" \" +\n d.getUTCDate()\t+\"/\" +\n (d.getUTCMonth()+1) + \"/\" +\n d.getUTCFullYear();\n}\n\nfunction format00(n) {\n if (n<10) return \"0\"+n; else return n;\n}\n\nmsg.payload+=\" at \"+ timeDate(1);\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 520,
"y": 740,
"wires": [
[
"f227495f.309fd8"
]
]
},
{
"id": "2b829d41.9896e2",
"type": "mqtt-broker",
"z": "",
"broker": "io.adafruit.com",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": true,
"keepalive": "60",
"cleansession": true,
"willTopic": "",
"willQos": "0",
"willPayload": "",
"birthTopic": "",
"birthQos": "0",
"birthPayload": ""
},
{
"id": "3d9d3a1b.1d4626",
"type": "ui_group",
"z": "",
"name": "Console",
"tab": "740a9861.8dce58",
"order": 1,
"disp": true,
"width": "6"
},
{
"id": "a9a923ec.3a3fa",
"type": "ui_group",
"z": "",
"name": "Connection state",
"tab": "740a9861.8dce58",
"order": 2,
"disp": true,
"width": "6"
},
{
"id": "740a9861.8dce58",
"type": "ui_tab",
"z": "",
"name": "Console",
"icon": "dashboard",
"order": 1
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment