Skip to content

Instantly share code, notes, and snippets.

@infosmick
Created December 19, 2016 19:48
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/e5945271543c62673460c9f8b5c00dcb to your computer and use it in GitHub Desktop.
Save infosmick/e5945271543c62673460c9f8b5c00dcb to your computer and use it in GitHub Desktop.
Smick_004_button

This flow shows how to configure Smick to generate a CLICK event each time you press the button switch connected. The event configuration is performed at power of Smick generating the event CONN. When you press the button generates Smick the CLICK event that is recognized to accomplish three tasks:

  • Action on Smick
  • Notification on the dashboard
  • Send an alarm message on e-mail and twitter.
[
{
"id": "b844a46a.517bf8",
"type": "link out",
"z": "43b92460.43099c",
"name": "command",
"links": [
"d00f3010.4b85b"
],
"x": 995,
"y": 280,
"wires": []
},
{
"id": "ca352d98.ec7ee",
"type": "trigger",
"z": "43b92460.43099c",
"op1": "d8=0",
"op2": "d8=1",
"op1type": "str",
"op2type": "str",
"duration": "3",
"extend": false,
"units": "s",
"reset": "",
"name": "led on 5sec",
"x": 610,
"y": 280,
"wires": [
[
"b844a46a.517bf8"
]
]
},
{
"id": "693188c.3068078",
"type": "function",
"z": "43b92460.43099c",
"name": "setup",
"func": "\nmsg.payload=\"click==d3=0\";\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 450,
"y": 220,
"wires": [
[
"7ca22f45.002db"
]
]
},
{
"id": "73ec4db8.253c34",
"type": "ui_gauge",
"z": "43b92460.43099c",
"name": "Button",
"group": "96729c5e.264ec",
"order": 1,
"width": 0,
"height": 0,
"gtype": "donut",
"title": "",
"label": "click",
"format": "{{value}}",
"min": 0,
"max": "1",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"x": 810,
"y": 420,
"wires": []
},
{
"id": "21501a44.0f51f6",
"type": "ui_chart",
"z": "43b92460.43099c",
"name": "click",
"group": "96729c5e.264ec",
"order": 2,
"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": 480,
"wires": [
[],
[]
]
},
{
"id": "845f1095.1313a",
"type": "trigger",
"z": "43b92460.43099c",
"op1": "1",
"op2": "0",
"op1type": "str",
"op2type": "str",
"duration": "3",
"extend": true,
"units": "s",
"reset": "",
"name": "",
"x": 580,
"y": 440,
"wires": [
[
"73ec4db8.253c34",
"21501a44.0f51f6"
]
]
},
{
"id": "774179d7.7c4aa8",
"type": "comment",
"z": "43b92460.43099c",
"name": "actions on actuators",
"info": "",
"x": 610,
"y": 140,
"wires": []
},
{
"id": "fe6222d2.fd27d",
"type": "comment",
"z": "43b92460.43099c",
"name": "actions on dashboard",
"info": "",
"x": 620,
"y": 380,
"wires": []
},
{
"id": "a62e314.68d61d",
"type": "e-mail",
"z": "43b92460.43099c",
"server": "smtp.gmail.com",
"port": "465",
"name": "infosmick@gmail.com",
"dname": "mail",
"x": 790,
"y": 560,
"wires": []
},
{
"id": "431e8a2a.fb3594",
"type": "twitter out",
"z": "43b92460.43099c",
"twitter": "",
"name": "tweet",
"x": 790,
"y": 640,
"wires": []
},
{
"id": "2f98cc74.3b1624",
"type": "comment",
"z": "43b92460.43099c",
"name": "actions on social",
"info": "",
"x": 600,
"y": 540,
"wires": []
},
{
"id": "519e2505.fb4bec",
"type": "function",
"z": "43b92460.43099c",
"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": 600,
"wires": [
[
"e4cf3287.65c7a"
]
]
},
{
"id": "bf85c3a8.c0ddb",
"type": "comment",
"z": "43b92460.43099c",
"name": "digital input",
"info": "",
"x": 250,
"y": 160,
"wires": []
},
{
"id": "d03c930f.15d4a",
"type": "comment",
"z": "43b92460.43099c",
"name": "Description",
"info": "Questo flusso mostra come configurare smick per generare un evento CLICK ogni volta che si preme il puslante collegato.\nLa configurazione dell'evento è eseguita all'accensione di smick che genera l'evento CONN. \nQuando si preme il pulsante smick genera l'evento CLICK che viene riconosciuto per compiere tre attività:\n- azione su smick\n- notifica su cruscotto\n- invio messaggio di allarme su e-mail e twitter.\n\n\nThis flow shows how to configure Smick to generate a CLICK event each time you press the button switch connected.\nThe event configuration is performed at power of Smick generating the event CONN. \nWhen you press the button generates Smick the CLICK event that is recognized to accomplish three tasks:\n- Action on Smick\n- Notification on the dashboard\n- Send an alarm message on e-mail and twitter.\n",
"x": 150,
"y": 40,
"wires": []
},
{
"id": "3593bc93.78e1a4",
"type": "comment",
"z": "43b92460.43099c",
"name": "Licence & History",
"info": "Package : Smick v.1\nModule : LED - digital output\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": 320,
"y": 40,
"wires": []
},
{
"id": "690addf8.a76594",
"type": "comment",
"z": "43b92460.43099c",
"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 1 LED connected to smick \n 1 micro button switch\n\nHW Connections:\n\n Device pin Smick pin\n LED + 3.3V\n LED - D8\n Switch 1 D3\n Switch 2 GND\n\nFlow Connections:\n\n Smick_001_console\n\nAccount:\n\n Wi-Fi credentials\n MQTT broker\n FRED\n E-mail\n Twitter\n",
"x": 470,
"y": 40,
"wires": []
},
{
"id": "caa7774e.470c58",
"type": "link in",
"z": "43b92460.43099c",
"name": "click",
"links": [
"8c8bbf9c.21941"
],
"x": 295,
"y": 220,
"wires": [
[
"693188c.3068078"
]
]
},
{
"id": "af5a309d.8ed97",
"type": "link in",
"z": "43b92460.43099c",
"name": "click",
"links": [
"be745a2f.44cee8"
],
"x": 295,
"y": 440,
"wires": [
[
"ca352d98.ec7ee",
"845f1095.1313a",
"519e2505.fb4bec"
]
]
},
{
"id": "e4cf3287.65c7a",
"type": "debug",
"z": "43b92460.43099c",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 810,
"y": 720,
"wires": []
},
{
"id": "ab2b777e.f734a8",
"type": "comment",
"z": "43b92460.43099c",
"name": "enable/disable",
"info": "",
"x": 880,
"y": 160,
"wires": []
},
{
"id": "7ca22f45.002db",
"type": "ui_switch",
"z": "43b92460.43099c",
"name": "",
"label": "button enable",
"group": "96729c5e.264ec",
"order": 0,
"width": 0,
"height": 0,
"passthru": true,
"topic": "",
"style": "",
"onvalue": "click==d3=0",
"onvalueType": "str",
"onicon": "",
"oncolor": "",
"offvalue": "click==null",
"offvalueType": "str",
"officon": "",
"offcolor": "",
"x": 820,
"y": 220,
"wires": [
[
"b844a46a.517bf8"
]
]
},
{
"id": "96729c5e.264ec",
"type": "ui_group",
"z": "",
"name": "Button",
"tab": "ad0a83de.40b3a",
"order": 1,
"disp": false,
"width": "6"
},
{
"id": "ad0a83de.40b3a",
"type": "ui_tab",
"z": "",
"name": "Button",
"icon": "dashboard",
"order": 3
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment