Skip to content

Instantly share code, notes, and snippets.

@infosmick
Created December 26, 2016 20:02
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/793dc71db62662d6e45e5d57ed460711 to your computer and use it in GitHub Desktop.
Save infosmick/793dc71db62662d6e45e5d57ed460711 to your computer and use it in GitHub Desktop.
Smick_004_button_v8

Digital button D3

[
{
"id": "cb252ff.0027dd",
"type": "subflow",
"name": "Smick status",
"info": "Detect Smick connection status.",
"in": [
{
"x": 320,
"y": 460,
"wires": [
{
"id": "5420ceb4.ac018"
}
]
}
],
"out": [
{
"x": 760,
"y": 400,
"wires": [
{
"id": "4bf018ec.09c848",
"port": 0
}
]
}
]
},
{
"id": "bceacaa7.47fc78",
"type": "ui_text",
"z": "cb252ff.0027dd",
"group": "f4652c38.539e6",
"order": 0,
"width": 0,
"height": 0,
"name": "",
"label": "status: ",
"format": "{{msg.payload}}",
"layout": "row-center",
"x": 830,
"y": 460,
"wires": []
},
{
"id": "5420ceb4.ac018",
"type": "switch",
"z": "cb252ff.0027dd",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "DISC",
"vt": "str"
},
{
"t": "else"
}
],
"checkall": "true",
"outputs": 2,
"x": 450,
"y": 460,
"wires": [
[
"a223a590.72dbf8",
"4bf018ec.09c848"
],
[
"59f39fd5.4b1f5"
]
]
},
{
"id": "a223a590.72dbf8",
"type": "change",
"z": "cb252ff.0027dd",
"name": "disconnected",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "disconnected",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 650,
"y": 460,
"wires": [
[
"bceacaa7.47fc78"
]
]
},
{
"id": "59f39fd5.4b1f5",
"type": "change",
"z": "cb252ff.0027dd",
"name": "connected",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "connected",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 650,
"y": 520,
"wires": [
[
"bceacaa7.47fc78"
]
]
},
{
"id": "4bf018ec.09c848",
"type": "change",
"z": "cb252ff.0027dd",
"name": "PING",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "PING",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 630,
"y": 400,
"wires": [
[]
]
},
{
"id": "f4652c38.539e6",
"type": "ui_group",
"z": "",
"name": "console",
"tab": "9c0e486b.51b0c8",
"order": 1,
"disp": true,
"width": "6"
},
{
"id": "9c0e486b.51b0c8",
"type": "ui_tab",
"z": "",
"name": "Console",
"icon": "dashboard",
"order": 1
},
{
"id": "8c17b331.cd1c7",
"type": "subflow",
"name": "Smick event",
"info": "Receive command responses or events from Smick.",
"in": [],
"out": [
{
"x": 660,
"y": 180,
"wires": [
{
"id": "1db2fb61.81a135",
"port": 0
}
]
}
]
},
{
"id": "9e9bef70.383b9",
"type": "ui_text",
"z": "8c17b331.cd1c7",
"group": "f4652c38.539e6",
"order": 2,
"width": "0",
"height": "0",
"name": "",
"label": "response/event",
"format": "{{msg.payload}}",
"layout": "col-center",
"x": 460,
"y": 240,
"wires": []
},
{
"id": "1db2fb61.81a135",
"type": "mqtt in",
"z": "8c17b331.cd1c7",
"name": "mqtt res/eve",
"topic": "borot/feeds/O3300460880",
"qos": "0",
"broker": "f1f7b732.115e58",
"x": 210,
"y": 180,
"wires": [
[
"9e9bef70.383b9",
"c9ca8862.893398"
]
]
},
{
"id": "c9ca8862.893398",
"type": "debug",
"z": "8c17b331.cd1c7",
"name": "response/event",
"active": true,
"console": "false",
"complete": "payload",
"x": 460,
"y": 120,
"wires": []
},
{
"id": "f4652c38.539e6",
"type": "ui_group",
"z": "",
"name": "console",
"tab": "9c0e486b.51b0c8",
"order": 1,
"disp": true,
"width": "6"
},
{
"id": "f1f7b732.115e58",
"type": "mqtt-broker",
"z": "",
"broker": "io.adafruit.com",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": true,
"keepalive": "300",
"cleansession": true,
"willTopic": "",
"willQos": "0",
"willPayload": "",
"birthTopic": "",
"birthQos": "0",
"birthPayload": ""
},
{
"id": "9c0e486b.51b0c8",
"type": "ui_tab",
"z": "",
"name": "Console",
"icon": "dashboard",
"order": 1
},
{
"id": "227e1b69.92def4",
"type": "subflow",
"name": "Smick command",
"info": "Send commands to Smick.",
"in": [
{
"x": 160,
"y": 120,
"wires": [
{
"id": "7b0b44fa.5ea32c"
}
]
}
],
"out": []
},
{
"id": "175720.d53688e",
"type": "mqtt out",
"z": "227e1b69.92def4",
"name": "smick cmd",
"topic": "borot/feeds/I3300460880",
"qos": "0",
"retain": "true",
"broker": "f1f7b732.115e58",
"x": 610,
"y": 160,
"wires": []
},
{
"id": "1408ce46.5b1292",
"type": "debug",
"z": "227e1b69.92def4",
"name": "command",
"active": true,
"console": "false",
"complete": "payload",
"x": 600,
"y": 80,
"wires": []
},
{
"id": "7b0b44fa.5ea32c",
"type": "ui_text_input",
"z": "227e1b69.92def4",
"name": "",
"label": "command",
"group": "f4652c38.539e6",
"order": 1,
"width": "0",
"height": "0",
"passthru": true,
"mode": "text",
"delay": "0",
"topic": "",
"x": 360,
"y": 120,
"wires": [
[
"175720.d53688e",
"1408ce46.5b1292"
]
]
},
{
"id": "f9226ee3.6cc58",
"type": "comment",
"z": "227e1b69.92def4",
"name": "Description",
"info": "Smick_001_console_v4\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.26 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 flows.\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 router\n MQTT broker\n FRED\n",
"x": 140,
"y": 40,
"wires": []
},
{
"id": "f1f7b732.115e58",
"type": "mqtt-broker",
"z": "",
"broker": "io.adafruit.com",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": true,
"keepalive": "300",
"cleansession": true,
"willTopic": "",
"willQos": "0",
"willPayload": "",
"birthTopic": "",
"birthQos": "0",
"birthPayload": ""
},
{
"id": "f4652c38.539e6",
"type": "ui_group",
"z": "",
"name": "console",
"tab": "9c0e486b.51b0c8",
"order": 1,
"disp": true,
"width": "6"
},
{
"id": "9c0e486b.51b0c8",
"type": "ui_tab",
"z": "",
"name": "Console",
"icon": "dashboard",
"order": 1
},
{
"id": "595fac32.0e1834",
"type": "subflow:227e1b69.92def4",
"z": "4913b9c6.f83e88",
"x": 1100,
"y": 340,
"wires": []
},
{
"id": "9d0cc56c.2cac98",
"type": "subflow:8c17b331.cd1c7",
"z": "4913b9c6.f83e88",
"x": 130,
"y": 340,
"wires": [
[
"8d1c78c2.cec9b8",
"1e044ae2.090ee5"
]
]
},
{
"id": "8d1c78c2.cec9b8",
"type": "subflow:cb252ff.0027dd",
"z": "4913b9c6.f83e88",
"x": 390,
"y": 340,
"wires": [
[
"595fac32.0e1834"
]
]
},
{
"id": "145352da.415a9d",
"type": "ui_switch",
"z": "4913b9c6.f83e88",
"name": "off/on",
"label": "off/on",
"group": "2fb4e76.9ec5c18",
"order": 0,
"width": 0,
"height": 0,
"passthru": true,
"topic": "",
"style": "",
"onvalue": "LED=1",
"onvalueType": "str",
"onicon": "",
"oncolor": "",
"offvalue": "LED=0",
"offvalueType": "str",
"officon": "",
"offcolor": "",
"x": 370,
"y": 100,
"wires": [
[
"595fac32.0e1834"
]
]
},
{
"id": "abf7be6f.84a3c",
"type": "ui_button",
"z": "4913b9c6.f83e88",
"name": "off",
"group": "2fb4e76.9ec5c18",
"order": 0,
"width": "3",
"height": "1",
"label": "off",
"color": "",
"icon": "",
"payload": "D3=0",
"payloadType": "str",
"topic": "",
"x": 370,
"y": 160,
"wires": [
[
"595fac32.0e1834"
]
]
},
{
"id": "b6cb664a.7e5c48",
"type": "ui_button",
"z": "4913b9c6.f83e88",
"name": "on",
"group": "2fb4e76.9ec5c18",
"order": 0,
"width": "3",
"height": "1",
"label": "on",
"color": "",
"icon": "",
"payload": "D3=0;D3=1",
"payloadType": "str",
"topic": "",
"x": 370,
"y": 220,
"wires": [
[
"595fac32.0e1834"
]
]
},
{
"id": "9ea37929.b1e6b8",
"type": "ui_slider",
"z": "4913b9c6.f83e88",
"name": "",
"label": "analogic",
"group": "9b895ead.8e0b9",
"order": 0,
"width": 0,
"height": 0,
"passthru": true,
"topic": "",
"min": 0,
"max": "1023",
"step": "10",
"x": 380,
"y": 280,
"wires": [
[
"34e289b4.1150a6"
]
]
},
{
"id": "34e289b4.1150a6",
"type": "function",
"z": "4913b9c6.f83e88",
"name": "D3=n",
"func": "\nmsg.payload=\"D3=\"+msg.payload\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 530,
"y": 280,
"wires": [
[
"595fac32.0e1834"
]
]
},
{
"id": "5dd05f78.759f3",
"type": "trigger",
"z": "4913b9c6.f83e88",
"op1": "LED=1",
"op2": "LED=0",
"op1type": "str",
"op2type": "str",
"duration": "3",
"extend": false,
"units": "s",
"reset": "",
"name": "led on 5sec",
"x": 590,
"y": 760,
"wires": [
[
"595fac32.0e1834"
]
]
},
{
"id": "10dd847e.0b60bc",
"type": "function",
"z": "4913b9c6.f83e88",
"name": "setup",
"func": "\nmsg.payload=\"click==d3=0\";\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 450,
"y": 620,
"wires": [
[
"715a9ee0.f0026"
]
]
},
{
"id": "1d6090f6.3810bf",
"type": "ui_gauge",
"z": "4913b9c6.f83e88",
"name": "Button",
"group": "9488c7a0.65a508",
"order": 2,
"width": "2",
"height": "2",
"gtype": "donut",
"title": "",
"label": "click",
"format": "{{value}}",
"min": 0,
"max": "1",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"x": 810,
"y": 860,
"wires": []
},
{
"id": "c077af9f.b1d4",
"type": "ui_chart",
"z": "4913b9c6.f83e88",
"name": "click",
"group": "9488c7a0.65a508",
"order": 3,
"width": 0,
"height": 0,
"label": "",
"chartType": "line",
"legend": "false",
"xformat": "%H:%M:%S",
"interpolate": "step-after",
"nodata": "push switch",
"ymin": "0",
"ymax": "1",
"removeOlder": "10",
"removeOlderUnit": "60",
"x": 810,
"y": 920,
"wires": [
[],
[]
]
},
{
"id": "ba176ccf.0829d",
"type": "trigger",
"z": "4913b9c6.f83e88",
"op1": "1",
"op2": "0",
"op1type": "str",
"op2type": "str",
"duration": "3",
"extend": true,
"units": "s",
"reset": "",
"name": "",
"x": 580,
"y": 880,
"wires": [
[
"1d6090f6.3810bf",
"c077af9f.b1d4"
]
]
},
{
"id": "bb81477c.c915a8",
"type": "comment",
"z": "4913b9c6.f83e88",
"name": "actions on actuators",
"info": "",
"x": 610,
"y": 700,
"wires": []
},
{
"id": "6ee5f848.1a5268",
"type": "comment",
"z": "4913b9c6.f83e88",
"name": "actions on dashboard",
"info": "",
"x": 620,
"y": 820,
"wires": []
},
{
"id": "2bc2e927.e23946",
"type": "e-mail",
"z": "4913b9c6.f83e88",
"server": "smtp.gmail.com",
"port": "465",
"name": "infosmick@gmail.com",
"dname": "mail",
"x": 790,
"y": 1000,
"wires": []
},
{
"id": "e42ade52.5ae61",
"type": "twitter out",
"z": "4913b9c6.f83e88",
"twitter": "",
"name": "tweet",
"x": 790,
"y": 1080,
"wires": []
},
{
"id": "2f1b34a3.80b4ac",
"type": "comment",
"z": "4913b9c6.f83e88",
"name": "actions on social",
"info": "",
"x": 600,
"y": 980,
"wires": []
},
{
"id": "747cc7c.0d3cd38",
"type": "function",
"z": "4913b9c6.f83e88",
"name": "alarm msg",
"func": "function timeDate(tz) {\n var d = new Date(Date.now()+tz*3600000);\n\n return d.getUTCHours() + \":\" +\n d.getUTCMinutes() + \":\" +\n d.getUTCSeconds() + \" \" +\n d.getUTCDate()\t+\"/\" +\n (d.getUTCMonth()+1) + \"/\" +\n d.getUTCFullYear();\n}\n\nmsg.payload=\"alarm from Smick at \" +\n timeDate(1);\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 590,
"y": 1040,
"wires": [
[
"21643b7a.39bdf4"
]
]
},
{
"id": "21643b7a.39bdf4",
"type": "debug",
"z": "4913b9c6.f83e88",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 810,
"y": 1160,
"wires": []
},
{
"id": "45acf18.6e86f1",
"type": "comment",
"z": "4913b9c6.f83e88",
"name": "enable/disable",
"info": "",
"x": 600,
"y": 560,
"wires": []
},
{
"id": "715a9ee0.f0026",
"type": "ui_switch",
"z": "4913b9c6.f83e88",
"name": "",
"label": "button enable",
"group": "9488c7a0.65a508",
"order": 1,
"width": 0,
"height": 0,
"passthru": true,
"topic": "",
"style": "",
"onvalue": "click==d3=0",
"onvalueType": "str",
"onicon": "",
"oncolor": "",
"offvalue": "click==null",
"offvalueType": "str",
"officon": "",
"offcolor": "",
"x": 600,
"y": 620,
"wires": [
[
"595fac32.0e1834"
]
]
},
{
"id": "1e044ae2.090ee5",
"type": "switch",
"z": "4913b9c6.f83e88",
"name": "parse",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "cont",
"v": "CONN",
"vt": "str"
},
{
"t": "cont",
"v": "CLICK",
"vt": "str"
}
],
"checkall": "false",
"outputs": 2,
"x": 290,
"y": 880,
"wires": [
[
"10dd847e.0b60bc"
],
[
"5dd05f78.759f3",
"ba176ccf.0829d",
"747cc7c.0d3cd38"
]
]
},
{
"id": "dc034ee5.b2f",
"type": "ui_button",
"z": "4913b9c6.f83e88",
"name": "reset",
"group": "f4652c38.539e6",
"order": 0,
"width": "0",
"height": "0",
"label": "reset",
"color": "",
"icon": "",
"payload": "RESET",
"payloadType": "str",
"topic": "",
"x": 370,
"y": 40,
"wires": [
[
"595fac32.0e1834"
]
]
},
{
"id": "2fb4e76.9ec5c18",
"type": "ui_group",
"z": "",
"name": "digital output",
"tab": "b0130d37.f74d9",
"order": 1,
"disp": true,
"width": "6"
},
{
"id": "9b895ead.8e0b9",
"type": "ui_group",
"z": "",
"name": "analogic output",
"tab": "b0130d37.f74d9",
"order": 2,
"disp": true,
"width": "6"
},
{
"id": "9488c7a0.65a508",
"type": "ui_group",
"z": "",
"name": "Button",
"tab": "8bcc9ed2.24e07",
"order": 1,
"disp": false,
"width": "6"
},
{
"id": "f4652c38.539e6",
"type": "ui_group",
"z": "",
"name": "console",
"tab": "9c0e486b.51b0c8",
"order": 1,
"disp": true,
"width": "6"
},
{
"id": "b0130d37.f74d9",
"type": "ui_tab",
"z": "",
"name": "LED",
"icon": "dashboard",
"order": 2
},
{
"id": "8bcc9ed2.24e07",
"type": "ui_tab",
"z": "",
"name": "Button",
"icon": "dashboard",
"order": 3
},
{
"id": "9c0e486b.51b0c8",
"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