Example of Bond Bridge Device Control

I was going to do this solution as a custom node, but then considered that over kill once I had this flow established. For those that are not familiar with a bond bridge, it is a WiFi bridge that provides direct control of ceiling fans, fireplaces, motorized blinds, etc.

You could do the same with a Pi or ESP8266 module with the right additional hardware, but the bond bridge fast and easy to use. But I digress. Below is a simple flow to control one fan, using the local bond bridge API (v2) http://docs-local.appbond.com/, which is a REST API.

It is a nice change to see a local API, no vendor web site access or account needed! You do need the device id (for each device), the API token and network name of the bridge that is linked to the device in question. How to get these are illustrated in the API documentation.

Example...

[{"id":"9e526ea2.3e5eb8","type":"switch","z":"6bdb1635.f6c19","name":"Error?","property":"rc.code","propertyType":"msg","rules":[{"t":"gt","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":1150,"y":680,"wires":[["3fb8d5e7.0a36b2"]]},{"id":"3fb8d5e7.0a36b2","type":"debug","z":"6bdb1635.f6c19","name":"Message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1300,"y":680,"wires":[]},{"id":"ee7c36f1.7f604","type":"link in","z":"6bdb1635.f6c19","name":"","links":["cf2f7b0e.749ea","34643b3d.5d358c","3e590422.d68e4c","a44a90e0.a36ea","6172640e.b4508c"],"x":1055,"y":680,"wires":[["9e526ea2.3e5eb8"]]},{"id":"72ebffe3.ca6328","type":"ui_button","z":"6bdb1635.f6c19","name":"Light","group":"da33091b.b4ef78","order":1,"width":0,"height":0,"passthru":false,"label":"Light","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"Light","x":70,"y":900,"wires":[["ec5848a0.8f482"]]},{"id":"962210ca.8017e","type":"exec","z":"6bdb1635.f6c19","command":"","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"Curl","x":1150,"y":740,"wires":[["4f3e077e.39c63"],[],["6172640e.b4508c"]]},{"id":"6172640e.b4508c","type":"link out","z":"6bdb1635.f6c19","name":"","links":["ee7c36f1.7f604"],"x":1255,"y":760,"wires":[]},{"id":"969b04fb.127f78","type":"comment","z":"6bdb1635.f6c19","name":"Casitas","info":"","x":70,"y":600,"wires":[]},{"id":"3ec8e1a0.22e1ce","type":"ui_button","z":"6bdb1635.f6c19","name":"Off","group":"da33091b.b4ef78","order":5,"width":0,"height":0,"passthru":true,"label":"Off","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"Off","x":630,"y":680,"wires":[["5649db3b.82e8f4"]]},{"id":"a0e9eb24.71f5e","type":"ui_button","z":"6bdb1635.f6c19","name":"Reverse","group":"da33091b.b4ef78","order":6,"width":0,"height":0,"passthru":false,"label":"Reverse","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"Reverse","x":640,"y":720,"wires":[["5649db3b.82e8f4"]]},{"id":"cefda8.73260a58","type":"ui_button","z":"6bdb1635.f6c19","name":"Fast","group":"da33091b.b4ef78","order":2,"width":0,"height":0,"passthru":true,"label":"Fast","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"Fast","x":630,"y":560,"wires":[["5649db3b.82e8f4"]]},{"id":"3440d68e.26240a","type":"ui_button","z":"6bdb1635.f6c19","name":"Medium","group":"da33091b.b4ef78","order":3,"width":0,"height":0,"passthru":true,"label":"Medium","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"Medium","x":640,"y":600,"wires":[["5649db3b.82e8f4"]]},{"id":"681e0e2b.3c6e5","type":"ui_button","z":"6bdb1635.f6c19","name":"Slow","group":"da33091b.b4ef78","order":4,"width":0,"height":0,"passthru":true,"label":"Slow","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"Slow","x":630,"y":640,"wires":[["5649db3b.82e8f4"]]},{"id":"3d5a80f8.6f6cd","type":"template","z":"6bdb1635.f6c19","name":"Feature","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"curl -H \"BOND-Token: {{token}}\" -X PUT -i http://{{host}}/v2/devices/{{id}}/actions/{{command}} -d {}\n","output":"str","x":980,"y":740,"wires":[["962210ca.8017e","2bb8246.06738dc"]]},{"id":"f82a0be.5edbf78","type":"inject","z":"6bdb1635.f6c19","name":"Light","props":[{"p":"command","v":"ToggleLight","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":90,"y":860,"wires":[["ec5848a0.8f482"]]},{"id":"4f3e077e.39c63","type":"debug","z":"6bdb1635.f6c19","name":"Message","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1300,"y":720,"wires":[]},{"id":"5b4407c.e454df8","type":"inject","z":"6bdb1635.f6c19","name":"Off","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"Off","x":90,"y":760,"wires":[["a8901b48.1b5118","8d963189.5016a"]]},{"id":"8953cea1.5848b8","type":"inject","z":"6bdb1635.f6c19","name":"Reverse","props":[{"p":"command","v":"ToggleDirection","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":100,"y":800,"wires":[["a8901b48.1b5118"]]},{"id":"c081147d.48f228","type":"inject","z":"6bdb1635.f6c19","name":"Slow","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Slow","x":90,"y":720,"wires":[["a8901b48.1b5118"]]},{"id":"ac03785e.22c398","type":"inject","z":"6bdb1635.f6c19","name":"Medium","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Medium","x":90,"y":680,"wires":[["a8901b48.1b5118"]]},{"id":"ce599cec.1f3818","type":"inject","z":"6bdb1635.f6c19","name":"Fast","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Fast","x":90,"y":640,"wires":[["a8901b48.1b5118"]]},{"id":"b0115be.8060d28","type":"template","z":"6bdb1635.f6c19","name":"Speed","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"curl -H \"BOND-Token: {{token}}\" -X PUT -i http://{{host}}/v2/devices/{{id}}/actions/{{command}} -d \"{\\\"argument\\\": {{argument}}}\"\n","output":"str","x":970,"y":860,"wires":[["2bb8246.06738dc","962210ca.8017e"]]},{"id":"da73569.a95a628","type":"function","z":"6bdb1635.f6c19","name":"Enable Or Disable?","func":"var theDisable = {enabled: false};\nvar theEnable = {enabled: true};\nvar theTopic = {topic: msg.topic };\n\nlet msgs;\n\nswitch(msg.topic) {\n    \n    case \"Fast\":\n        msgs = [theDisable, theEnable, theEnable, theEnable, theEnable, theTopic];\n        break;\n\n    case \"Medium\":\n        msgs = [theEnable, theDisable, theEnable, theEnable, theEnable, theTopic];\n        break;\n\n    case \"Slow\":\n        msgs = [theEnable, theEnable, theDisable, theEnable, theEnable, theTopic];\n        break;\n\n    // Off...\n    default:\n        msgs = [theEnable, theEnable, theEnable, theDisable, theDisable, theTopic];\n        break;\n} \n\nreturn msgs;","outputs":6,"noerr":0,"initialize":"","finalize":"","x":450,"y":640,"wires":[["cefda8.73260a58"],["3440d68e.26240a"],["681e0e2b.3c6e5"],["3ec8e1a0.22e1ce"],["a0e9eb24.71f5e"],["913d0b94.dadc68"]],"outputLabels":["Fast","Medium","Slow","Off","Reverse","Topic"]},{"id":"913d0b94.dadc68","type":"switch","z":"6bdb1635.f6c19","name":"Command?","property":"topic","propertyType":"msg","rules":[{"t":"cont","v":"Reverse","vt":"str"},{"t":"cont","v":"Off","vt":"str"},{"t":"cont","v":"Fast","vt":"str"},{"t":"cont","v":"Medium","vt":"str"},{"t":"cont","v":"Slow","vt":"str"}],"checkall":"false","repair":false,"outputs":5,"x":650,"y":820,"wires":[["441c03bc.2e73d4"],["2cfb3178.206bde"],["3a8540ca.5cb0d"],["6490b822.7d95c8"],["dfee7169.6deb4"]]},{"id":"3a8540ca.5cb0d","type":"change","z":"6bdb1635.f6c19","name":"Fast","rules":[{"t":"set","p":"host","pt":"msg","to":"host","tot":"flow"},{"t":"set","p":"id","pt":"msg","to":"id","tot":"flow"},{"t":"set","p":"token","pt":"msg","to":"token","tot":"flow"},{"t":"set","p":"command","pt":"msg","to":"SetSpeed","tot":"str"},{"t":"set","p":"argument","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":820,"wires":[["b0115be.8060d28"]]},{"id":"5649db3b.82e8f4","type":"link out","z":"6bdb1635.f6c19","name":"","links":["3d2d3cc0.42112c"],"x":755,"y":640,"wires":[]},{"id":"3d2d3cc0.42112c","type":"link in","z":"6bdb1635.f6c19","name":"","links":["5649db3b.82e8f4","a8901b48.1b5118"],"x":295,"y":640,"wires":[["da73569.a95a628"]]},{"id":"2bb8246.06738dc","type":"debug","z":"6bdb1635.f6c19","name":"Message","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1160,"y":860,"wires":[]},{"id":"a8901b48.1b5118","type":"link out","z":"6bdb1635.f6c19","name":"","links":["3d2d3cc0.42112c"],"x":215,"y":720,"wires":[]},{"id":"6490b822.7d95c8","type":"change","z":"6bdb1635.f6c19","name":"Medium","rules":[{"t":"set","p":"host","pt":"msg","to":"host","tot":"flow"},{"t":"set","p":"id","pt":"msg","to":"id","tot":"flow"},{"t":"set","p":"token","pt":"msg","to":"token","tot":"flow"},{"t":"set","p":"command","pt":"msg","to":"SetSpeed","tot":"str"},{"t":"set","p":"argument","pt":"msg","to":"2","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":860,"wires":[["b0115be.8060d28"]]},{"id":"dfee7169.6deb4","type":"change","z":"6bdb1635.f6c19","name":"Slow","rules":[{"t":"set","p":"host","pt":"msg","to":"host","tot":"flow"},{"t":"set","p":"id","pt":"msg","to":"id","tot":"flow"},{"t":"set","p":"token","pt":"msg","to":"token","tot":"flow"},{"t":"set","p":"command","pt":"msg","to":"SetSpeed","tot":"str"},{"t":"set","p":"argument","pt":"msg","to":"3","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":900,"wires":[["b0115be.8060d28"]]},{"id":"2cfb3178.206bde","type":"change","z":"6bdb1635.f6c19","name":"Off","rules":[{"t":"set","p":"host","pt":"msg","to":"host","tot":"flow"},{"t":"set","p":"id","pt":"msg","to":"id","tot":"flow"},{"t":"set","p":"token","pt":"msg","to":"token","tot":"flow"},{"t":"set","p":"command","pt":"msg","to":"TurnOff","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":780,"wires":[["3d5a80f8.6f6cd"]]},{"id":"441c03bc.2e73d4","type":"change","z":"6bdb1635.f6c19","name":"Reverse","rules":[{"t":"set","p":"host","pt":"msg","to":"host","tot":"flow"},{"t":"set","p":"id","pt":"msg","to":"id","tot":"flow"},{"t":"set","p":"token","pt":"msg","to":"token","tot":"flow"},{"t":"set","p":"command","pt":"msg","to":"ToggleDirection","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":740,"wires":[["3d5a80f8.6f6cd"]]},{"id":"ec5848a0.8f482","type":"change","z":"6bdb1635.f6c19","name":"Light","rules":[{"t":"set","p":"host","pt":"msg","to":"host","tot":"flow"},{"t":"set","p":"id","pt":"msg","to":"id","tot":"flow"},{"t":"set","p":"token","pt":"msg","to":"token","tot":"flow"},{"t":"set","p":"command","pt":"msg","to":"ToggleLight","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":230,"y":880,"wires":[["e1e8749.bda0d08","3922fc9f.a0a0c4"]]},{"id":"e1e8749.bda0d08","type":"link out","z":"6bdb1635.f6c19","name":"","links":["d323601c.93241"],"x":335,"y":860,"wires":[]},{"id":"d323601c.93241","type":"link in","z":"6bdb1635.f6c19","name":"","links":["e1e8749.bda0d08"],"x":855,"y":700,"wires":[["3d5a80f8.6f6cd"]]},{"id":"3922fc9f.a0a0c4","type":"debug","z":"6bdb1635.f6c19","name":"Message","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":380,"y":900,"wires":[]},{"id":"8d963189.5016a","type":"change","z":"6bdb1635.f6c19","name":"Token, Id And Host","rules":[{"t":"set","p":"token","pt":"flow","to":"[redacted]","tot":"str"},{"t":"set","p":"id","pt":"flow","to":"67ea44a0","tot":"str"},{"t":"set","p":"host","pt":"flow","to":"ZZDE61263.local","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":760,"wires":[[]]},{"id":"da33091b.b4ef78","type":"ui_group","z":"","name":"Casitas","tab":"5ccafa7e.acac54","order":1,"disp":true,"width":2,"collapse":true},{"id":"5ccafa7e.acac54","type":"ui_tab","z":"","name":"Bond","icon":"dashboard","disabled":false,"hidden":false}]

The easy way to get the token is from the bond bridge (phone) application, the device id(s) via using anything that can do REST API calls, say curl on Linux, and the bridge network name, is based on the serial number printed on the bridge. The bridge is based on either an ESP32 or ESP8266 module, given how it shows up on the network via an arp-scan.

The really cool future development is that bond is working on an MQTT API as well. As well adding more device types over time. A raw beta of the MQTT API is available on the bond API web site. I encourage anyone interested to let bond know of interest, so they will complete development of same.

Oh, for the flow guru out there, this is one of the first flows I have published, so suggestions welcome... but be kind... still learning about NR. Enjoy!