Skip to content

Instantly share code, notes, and snippets.

@infosmick
Created December 22, 2016 13:52
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/322c46ff16ffb6a03f223314557340c8 to your computer and use it in GitHub Desktop.
Save infosmick/322c46ff16ffb6a03f223314557340c8 to your computer and use it in GitHub Desktop.
Smick_001_console_v3

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": 960,
"y": 260,
"wires": []
},
{
"id": "c4845dca.f1ada",
"type": "debug",
"z": "35add6f9.6f79aa",
"name": "debug command",
"active": true,
"console": "false",
"complete": "payload",
"x": 960,
"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": 580,
"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": 960,
"y": 540,
"wires": []
},
{
"id": "b2782229.91ed3",
"type": "mqtt in",
"z": "35add6f9.6f79aa",
"name": "smick response/event",
"topic": "borot/feeds/O3300460880",
"qos": "0",
"broker": "2b829d41.9896e2",
"x": 200,
"y": 540,
"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": 275,
"y": 260,
"wires": [
[
"9d66070d.ef1148"
]
]
},
{
"id": "e25d39ab.fd0ba8",
"type": "debug",
"z": "35add6f9.6f79aa",
"name": "debug event",
"active": true,
"console": "false",
"complete": "payload",
"x": 950,
"y": 480,
"wires": []
},
{
"id": "65c026c0.fda4e8",
"type": "ui_toast",
"z": "35add6f9.6f79aa",
"position": "bottom right",
"displayTime": "3",
"name": "conn/disc notification",
"x": 980,
"y": 680,
"wires": []
},
{
"id": "f227495f.309fd8",
"type": "ui_text",
"z": "35add6f9.6f79aa",
"group": "3d9d3a1b.1d4626",
"order": 3,
"width": 0,
"height": 0,
"name": "state",
"label": "Connection state",
"format": "{{msg.payload}}",
"layout": "col-center",
"x": 930,
"y": 600,
"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": 570,
"y": 640,
"wires": [
[
"75d0abe2.e4fe04"
]
]
},
{
"id": "290027bd.4e4828",
"type": "link out",
"z": "35add6f9.6f79aa",
"name": "response_event",
"links": [
"4a2e69f2.1bb9e8",
"b4d0698e.ffcdc8",
"c8f76d6f.f022e",
"e6305255.f5035"
],
"x": 895,
"y": 380,
"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
}
],
"checkall": "false",
"outputs": 1,
"x": 410,
"y": 640,
"wires": [
[
"76d5ef63.be81d"
]
]
},
{
"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": 740,
"y": 640,
"wires": [
[
"f227495f.309fd8",
"65c026c0.fda4e8"
]
]
},
{
"id": "dc4e3932.268d58",
"type": "comment",
"z": "35add6f9.6f79aa",
"name": "Description",
"info": "Smick_001_console\n_______________________________________________________________________________\nPackage : 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\n_______________________________________________________________________________\n\nDescription\n\nQuesto 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_______________________________________________________________________________\n\nBill 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": 120,
"y": 60,
"wires": []
},
{
"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": "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