Skip to content

Instantly share code, notes, and snippets.

@pastukhov
Created November 12, 2015 12:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pastukhov/bf9814b4c6bffda3c675 to your computer and use it in GitHub Desktop.
Save pastukhov/bf9814b4c6bffda3c675 to your computer and use it in GitHub Desktop.
Z-wave home automation control panel

Complete example of z-wave home automation control panel on base of node-red-contrib-ui

Do not forget to change z-wave UART port and MQTT server address according to your settings. Widgets are hardcoded. To add/change your z-wave nodes controls add/change MQTT listener topic as zwave/events/value/changed|added/nodeid/commandclass/instance/index

[
{
"id":"d9df72fd.26209",
"type":"zwave-controller",
"port":"/dev/ttyS2",
"driverattempts":"3",
"pollinterval":"500"
},
{
"id":"61a9a3b5.9e565c",
"type":"subflow",
"name":"F to C",
"info":"",
"in":[
{
"x":44,
"y":63,
"wires":[
{
"id":"382f1da6.c7d0e2"
}
]
}
],
"out":[
{
"x":309,
"y":57,
"wires":[
{
"id":"382f1da6.c7d0e2",
"port":0
}
]
}
]
},
{
"id":"382f1da6.c7d0e2",
"type":"function",
"z":"61a9a3b5.9e565c",
"name":"F to C",
"func":"msg.payload = (Math.round((msg.payload - 32) * 50 / 9)/10)\nreturn msg;",
"outputs":1,
"noerr":0,
"x":158,
"y":60,
"wires":[
[
]
]
},
{
"id":"1e613977.e19ec7",
"type":"subflow",
"name":"dimmer to switch",
"info":"",
"in":[
{
"x":25,
"y":86,
"wires":[
{
"id":"a67b8b4f.598478"
}
]
}
],
"out":[
{
"x":437,
"y":83,
"wires":[
{
"id":"a67b8b4f.598478",
"port":0
}
]
}
]
},
{
"id":"a67b8b4f.598478",
"type":"function",
"z":"1e613977.e19ec7",
"name":"Dimmer value to switch",
"func":"if(msg.payload === 0) {\n msg.payload = false;\n}\nelse {\n msg.payload = true;\n}\nreturn msg;",
"outputs":1,
"noerr":0,
"x":220,
"y":85,
"wires":[
[
]
]
},
{
"id":"41985be7.be67a4",
"type":"subflow",
"name":"currState to payload",
"info":"",
"in":[
{
"x":139,
"y":133,
"wires":[
{
"id":"ded027ca.212fd8"
}
]
}
],
"out":[
{
"x":448,
"y":131,
"wires":[
{
"id":"ded027ca.212fd8",
"port":0
}
]
}
]
},
{
"id":"ded027ca.212fd8",
"type":"function",
"z":"41985be7.be67a4",
"name":"currState to payload",
"func":"msg.payload = JSON.parse(msg.payload)\nvar msg2 = {}\nmsg2.payload = msg.payload.currState;\nreturn msg2;\n\n\n",
"outputs":1,
"noerr":0,
"x":289,
"y":132,
"wires":[
[
]
]
},
{
"id":"48fb8db.fb70474",
"type":"mqtt-broker",
"z":"",
"broker":"test.mosquitto.com",
"port":"8883",
"clientid":"",
"usetls":true,
"verifyservercert":true,
"compatmode":false,
"keepalive":"15",
"cleansession":true,
"willTopic":"",
"willQos":"0",
"willRetain":null,
"willPayload":"",
"birthTopic":"",
"birthQos":"0",
"birthRetain":null,
"birthPayload":""
},
{
"id":"1f2b2b2f.104565",
"type":"ui_text",
"z":"e3b5f6fb.f2d36",
"label":"Температура",
"group":"\"EZMotion+ 3-in-1 Sensor",
"format":"{{value}}",
"x":947.0000610351562,
"y":38,
"wires":[
]
},
{
"id":"5585b218.fcbbcc",
"type":"mqtt in",
"z":"e3b5f6fb.f2d36",
"name":"Temperature from 13 node",
"topic":"zwave/events/value/+/13/49/1/1",
"broker":"48fb8db.fb70474",
"x":118.25003051757812,
"y":45.2500057220459,
"wires":[
[
"cfad292.f3052d8"
]
]
},
{
"id":"27ae15df.e8e49a",
"type":"ui_text",
"z":"e3b5f6fb.f2d36",
"label":"Освещенность",
"group":"\"EZMotion+ 3-in-1 Sensor",
"format":"{{value}}",
"x":939.75,
"y":105.5,
"wires":[
]
},
{
"id":"e6e0b976.076298",
"type":"mqtt in",
"z":"e3b5f6fb.f2d36",
"name":"Luminance from 13 node",
"topic":"zwave/events/value/+/13/49/1/3",
"broker":"48fb8db.fb70474",
"x":113.7500228881836,
"y":101.75,
"wires":[
[
"bd4d61f.f42b2a"
]
]
},
{
"id":"4f339cec.b0cc64",
"type":"ui_slider",
"z":"e3b5f6fb.f2d36",
"label":"Свет в гостинной",
"group":"Гостинная",
"min":0,
"max":"100",
"x":656.75,
"y":167.25,
"wires":[
[
"35134fdd.caecb"
]
]
},
{
"id":"fedea31a.01216",
"type":"mqtt in",
"z":"e3b5f6fb.f2d36",
"name":"Значение диммера в гостинной",
"topic":"zwave/events/value/+/11/38/1/0",
"broker":"48fb8db.fb70474",
"x":140.5,
"y":193.5,
"wires":[
[
"445610d7.bba9f"
]
]
},
{
"id":"35134fdd.caecb",
"type":"function",
"z":"e3b5f6fb.f2d36",
"name":"",
"func":"if (msg.payload.typef === 'boolean') {\n if(msg.payload) {\n msg.payload = 255}\n else {\n msg.payload =0\n }\n}\nvar msg2 = { \n topic : 'zwave/actions/setLevel',\n payload: {\n value : msg.payload,\n nodeid : 11,\n cmdclass:38,\n }\n \n};\nreturn msg2;",
"outputs":1,
"noerr":0,
"x":894.75,
"y":166,
"wires":[
[
"c3c7a5f1.3c3858"
]
]
},
{
"id":"22f26439.dd0d9c",
"type":"ui_switch",
"z":"e3b5f6fb.f2d36",
"label":"Выключатель",
"group":"Гостинная",
"x":651.25,
"y":239.25,
"wires":[
[
"35134fdd.caecb"
]
]
},
{
"id":"445610d7.bba9f",
"type":"subflow:41985be7.be67a4",
"z":"e3b5f6fb.f2d36",
"x":399,
"y":190,
"wires":[
[
"4f339cec.b0cc64",
"67409c6d.98bf64"
]
]
},
{
"id":"67409c6d.98bf64",
"type":"subflow:1e613977.e19ec7",
"z":"e3b5f6fb.f2d36",
"x":403,
"y":261,
"wires":[
[
"22f26439.dd0d9c"
]
]
},
{
"id":"cfad292.f3052d8",
"type":"subflow:41985be7.be67a4",
"z":"e3b5f6fb.f2d36",
"x":364.0000305175781,
"y":44,
"wires":[
[
"c16b2eac.3e94d"
]
]
},
{
"id":"bd4d61f.f42b2a",
"type":"subflow:41985be7.be67a4",
"z":"e3b5f6fb.f2d36",
"x":358.0000305175781,
"y":102,
"wires":[
[
"4c763646.b389c8"
]
]
},
{
"id":"10aab97f.ef5547",
"type":"ui_slider",
"z":"e3b5f6fb.f2d36",
"label":"Свет в прихожей",
"group":"Прихожая",
"min":0,
"max":"100",
"x":639.75,
"y":305,
"wires":[
[
"63ab8983.9c5478"
]
]
},
{
"id":"a84dfde0.57b2",
"type":"mqtt in",
"z":"e3b5f6fb.f2d36",
"name":"Значение диммера в гостинной",
"topic":"zwave/events/value/+/9/38/1/0",
"broker":"48fb8db.fb70474",
"x":132.5,
"y":320.25,
"wires":[
[
"e1b2ee7e.1e4d1"
]
]
},
{
"id":"63ab8983.9c5478",
"type":"function",
"z":"e3b5f6fb.f2d36",
"name":"",
"func":"if (msg.payload.typef === 'boolean') {\n if(msg.payload) {\n msg.payload = 255}\n else {\n msg.payload =0\n }\n}\nvar msg2 = { \n topic : 'zwave/actions/setLevel',\n payload: {\n value : msg.payload,\n nodeid : 9,\n cmdclass:38,\n }\n \n};\nreturn msg2;",
"outputs":1,
"noerr":0,
"x":877.75,
"y":303.75,
"wires":[
[
"c3c7a5f1.3c3858"
]
]
},
{
"id":"c3c7a5f1.3c3858",
"type":"mqtt out",
"z":"e3b5f6fb.f2d36",
"name":"",
"topic":"",
"qos":"",
"retain":"",
"broker":"48fb8db.fb70474",
"x":1085.75,
"y":368.5,
"wires":[
]
},
{
"id":"a4eded6b.5b121",
"type":"ui_switch",
"z":"e3b5f6fb.f2d36",
"label":"Выключатель",
"group":"Прихожая",
"x":643.25,
"y":390,
"wires":[
[
"63ab8983.9c5478"
]
]
},
{
"id":"e1b2ee7e.1e4d1",
"type":"subflow:41985be7.be67a4",
"z":"e3b5f6fb.f2d36",
"x":389,
"y":322.75,
"wires":[
[
"10aab97f.ef5547",
"d3db379b.2c24c8"
]
]
},
{
"id":"d3db379b.2c24c8",
"type":"subflow:1e613977.e19ec7",
"z":"e3b5f6fb.f2d36",
"x":393,
"y":387.75,
"wires":[
[
"a4eded6b.5b121"
]
]
},
{
"id":"e55777da.1aa888",
"type":"ui_slider",
"z":"e3b5f6fb.f2d36",
"label":"Свет в спальне",
"group":"Спальня",
"min":0,
"max":"100",
"x":639.75,
"y":475,
"wires":[
[
"4f38431c.b0c7bc"
]
]
},
{
"id":"60701380.9f8fec",
"type":"mqtt in",
"z":"e3b5f6fb.f2d36",
"name":"Значение диммера в гостинной",
"topic":"zwave/events/value/+/14/38/1/0",
"broker":"48fb8db.fb70474",
"x":132.5,
"y":490.25,
"wires":[
[
"9fada206.60526"
]
]
},
{
"id":"4f38431c.b0c7bc",
"type":"function",
"z":"e3b5f6fb.f2d36",
"name":"",
"func":"if (msg.payload.typef === 'boolean') {\n if(msg.payload) {\n msg.payload = 255}\n else {\n msg.payload =0\n }\n}\nvar msg2 = { \n topic : 'zwave/actions/setLevel',\n payload: {\n value : msg.payload,\n nodeid : 14,\n cmdclass:38,\n }\n \n};\nreturn msg2;",
"outputs":1,
"noerr":0,
"x":877.75,
"y":473.75,
"wires":[
[
"c3c7a5f1.3c3858"
]
]
},
{
"id":"bf1b51b7.40e4b",
"type":"ui_switch",
"z":"e3b5f6fb.f2d36",
"label":"Выключатель",
"group":"Спальня",
"x":643.25,
"y":560,
"wires":[
[
"4f38431c.b0c7bc"
]
]
},
{
"id":"9fada206.60526",
"type":"subflow:41985be7.be67a4",
"z":"e3b5f6fb.f2d36",
"x":389,
"y":492.75,
"wires":[
[
"e55777da.1aa888",
"1ee9028e.e116fd"
]
]
},
{
"id":"1ee9028e.e116fd",
"type":"subflow:1e613977.e19ec7",
"z":"e3b5f6fb.f2d36",
"x":393,
"y":557.75,
"wires":[
[
"bf1b51b7.40e4b"
]
]
},
{
"id":"c16b2eac.3e94d",
"type":"subflow:61a9a3b5.9e565c",
"z":"e3b5f6fb.f2d36",
"x":558,
"y":45,
"wires":[
[
"76cb7299.89348c"
]
]
},
{
"id":"6c5f3c20.93a0c4",
"type":"ui_switch",
"z":"e3b5f6fb.f2d36",
"label":"Свет в Аквариуме",
"group":" Аквариум",
"x":657,
"y":614,
"wires":[
[
"9e54edef.61ab1"
]
]
},
{
"id":"c008c374.3ff74",
"type":"mqtt in",
"z":"e3b5f6fb.f2d36",
"name":"Статус света в аквариуме",
"topic":"zwave/events/value/+/2/37/1/0",
"broker":"48fb8db.fb70474",
"x":125,
"y":617,
"wires":[
[
"d1408c7e.2ebf7"
]
]
},
{
"id":"d1408c7e.2ebf7",
"type":"subflow:41985be7.be67a4",
"z":"e3b5f6fb.f2d36",
"x":393,
"y":616,
"wires":[
[
"6c5f3c20.93a0c4"
]
]
},
{
"id":"9e54edef.61ab1",
"type":"function",
"z":"e3b5f6fb.f2d36",
"name":"",
"func":"msg.payload = { nodeid : 2 };\n\nif(msg.payload) {\n msg.topic = 'switchOn';\n}\nelse {\n msg.topic = 'switchOff';\n}\n\nreturn msg;",
"outputs":1,
"noerr":0,
"x":878,
"y":578,
"wires":[
[
"c3c7a5f1.3c3858"
]
]
},
{
"id":"39a95647.c656aa",
"type":"ui_switch",
"z":"e3b5f6fb.f2d36",
"label":"Розетка",
"group":"Кухня",
"x":616,
"y":672,
"wires":[
[
"40f78c84.bf0874"
]
]
},
{
"id":"282dd957.d7d226",
"type":"mqtt in",
"z":"e3b5f6fb.f2d36",
"name":"Статус розетки на кухне",
"topic":"zwave/events/value/+/8/37/1/0",
"broker":"48fb8db.fb70474",
"x":124,
"y":674,
"wires":[
[
"a133455a.5eccb8"
]
]
},
{
"id":"a133455a.5eccb8",
"type":"subflow:41985be7.be67a4",
"z":"e3b5f6fb.f2d36",
"x":391,
"y":671,
"wires":[
[
"39a95647.c656aa"
]
]
},
{
"id":"40f78c84.bf0874",
"type":"function",
"z":"e3b5f6fb.f2d36",
"name":"",
"func":"msg.payload = { nodeid : 8 };\n\nif(msg.payload) {\n msg.topic = 'switchOn';\n}\n else {\n msg.topic = 'switchOff';\n }\n\nreturn msg;",
"outputs":1,
"noerr":0,
"x":876,
"y":673,
"wires":[
[
"c3c7a5f1.3c3858"
]
]
},
{
"id":"76cb7299.89348c",
"type":"function",
"z":"e3b5f6fb.f2d36",
"name":"+ °C",
"func":"msg.payload += ' °C';\nreturn msg;",
"outputs":1,
"noerr":0,
"x":702,
"y":43,
"wires":[
[
"1f2b2b2f.104565"
]
]
},
{
"id":"4c763646.b389c8",
"type":"function",
"z":"e3b5f6fb.f2d36",
"name":"+ lm",
"func":"msg.payload += ' %';\nreturn msg;",
"outputs":1,
"noerr":0,
"x":698,
"y":105,
"wires":[
[
"27ae15df.e8e49a"
]
]
},
{
"id":"58d1f677.a72e08",
"type":"ui_toast",
"z":"e3b5f6fb.f2d36",
"name":"События",
"x":603,
"y":734,
"wires":[
]
},
{
"id":"64d7256c.9b28dc",
"type":"mqtt in",
"z":"e3b5f6fb.f2d36",
"name":"",
"topic":"zwave/events/value/changed/#",
"broker":"48fb8db.fb70474",
"x":145,
"y":738,
"wires":[
[
"36d1a454.c92e5c"
]
]
},
{
"id":"36d1a454.c92e5c",
"type":"function",
"z":"e3b5f6fb.f2d36",
"name":"",
"func":"msg.payload = JSON.parse(msg.payload);\nmsg.payload = 'Value on ' + msg.payload.value.value_id + ' changed at ' + Date();\nreturn msg;",
"outputs":1,
"noerr":0,
"x":400,
"y":736,
"wires":[
[
"58d1f677.a72e08"
]
]
},
{
"id":"cf8cbb90.307348",
"type":"zwave-in",
"z":"e3b5f6fb.f2d36",
"name":"z-wave listener",
"controller":"d9df72fd.26209",
"x":107,
"y":827,
"wires":[
[
"e0e13360.1f1ed"
]
]
},
{
"id":"853c4ac2.7ac3b8",
"type":"mqtt out",
"z":"e3b5f6fb.f2d36",
"name":"publish value to topic 'zwave/events/value/' + value_id",
"topic":"",
"qos":"",
"retain":"true",
"broker":"48fb8db.fb70474",
"x":668,
"y":827,
"wires":[
]
},
{
"id":"e0e13360.1f1ed",
"type":"function",
"z":"e3b5f6fb.f2d36",
"name":"zwave value adapter",
"func":"if (msg.topic.indexOf(\"value\") !=-1){\n msg.topic = 'zwave/events/' + msg.topic.replace('zwave: ','').replace(/ /,'/') + '/' + msg.payload.value.value_id.replace(/-/g,'/');\n return msg;\n}\n",
"outputs":"1",
"noerr":0,
"x":329,
"y":830,
"wires":[
[
"853c4ac2.7ac3b8"
]
]
}
]
@MartinSokolov15
Copy link

Have you try this with Xbee/Zigbee ?

@pastukhov
Copy link
Author

No. It's z-wave only and quiet outdate. But you can use it as source to make your own dash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment