Read device status and open/close your MyQ controlled garage door.
-
-
Save nothingmn/83f263d6f5f23e53e2aed85b96aadb3e to your computer and use it in GitHub Desktop.
MyQ Chamberlain Garage Door Status and Control
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": "194332a8.956fdd", | |
"type": "inject", | |
"z": "bb696818.adb038", | |
"name": "", | |
"topic": "garage/status", | |
"payload": "", | |
"payloadType": "date", | |
"repeat": "30", | |
"crontab": "", | |
"once": true, | |
"x": 150, | |
"y": 80, | |
"wires": [ | |
[ | |
"7331b236.05a98c" | |
] | |
] | |
}, | |
{ | |
"id": "bfe7658b.737b68", | |
"type": "http request", | |
"z": "bb696818.adb038", | |
"name": "", | |
"method": "POST", | |
"ret": "obj", | |
"url": "https://myqexternal.myqdevice.com/api/v4/User/Validate", | |
"tls": "", | |
"x": 843, | |
"y": 121, | |
"wires": [ | |
[ | |
"cededf2c.258fb" | |
] | |
] | |
}, | |
{ | |
"id": "e2e4390c.2df7d8", | |
"type": "debug", | |
"z": "bb696818.adb038", | |
"name": "", | |
"active": false, | |
"console": "false", | |
"complete": "true", | |
"x": 1170, | |
"y": 120, | |
"wires": [] | |
}, | |
{ | |
"id": "edbda757.770fc8", | |
"type": "function", | |
"z": "bb696818.adb038", | |
"name": "", | |
"func": "\n\nmsg.payload = {\n \"username\" : \"XXXXXXXXXX\",\n \"password\" : \"XXXXXXXXX\"\n}\n\nmsg.headers = {\n ContentType : \"application/json\",\n Accept : \"application/json\",\n MyQApplicationId : \"Vj8pQggXLhLy0WHahglCD4N1nAkkXQtGYpq2HrHD7H1nvmbT55KqtN6RSF4ILB/i\",\n Culture : \"en\"\n}\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 663, | |
"y": 121, | |
"wires": [ | |
[ | |
"bfe7658b.737b68" | |
] | |
] | |
}, | |
{ | |
"id": "7331b236.05a98c", | |
"type": "function", | |
"z": "bb696818.adb038", | |
"name": "", | |
"func": "\nif(msg.payload && msg.payload.desired_state) {\n msg.desired_state = msg.payload.desired_state;\n}\n\n\nmsg.payload = {};\n\nvar myq = global.get(\"myq\");\n\nif(myq && myq.SecurityToken) {\n msg.payload.myq = myq; \n}\n\n\nreturn msg;\n", | |
"outputs": "1", | |
"noerr": 0, | |
"x": 370, | |
"y": 120, | |
"wires": [ | |
[ | |
"405f4ad0.8ea124", | |
"b13641a3.823da", | |
"4b1098de.5f0268" | |
] | |
] | |
}, | |
{ | |
"id": "e3357aa4.0978d8", | |
"type": "debug", | |
"z": "bb696818.adb038", | |
"name": "", | |
"active": false, | |
"console": "false", | |
"complete": "true", | |
"x": 670, | |
"y": 40, | |
"wires": [] | |
}, | |
{ | |
"id": "f2779857.91b468", | |
"type": "debug", | |
"z": "bb696818.adb038", | |
"name": "", | |
"active": false, | |
"console": "false", | |
"complete": "true", | |
"x": 610, | |
"y": 160, | |
"wires": [] | |
}, | |
{ | |
"id": "cededf2c.258fb", | |
"type": "function", | |
"z": "bb696818.adb038", | |
"name": "", | |
"func": "\nif(msg.statusCode == 200 && msg.payload.SecurityToken) {\n var myq = {\n SecurityToken : msg.payload.SecurityToken\n };\n \n global.set(\"myq\", myq);\n msg.payload.myq = myq;\n return msg;\n} else {\n return null;\n}\n\n\n", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 1010, | |
"y": 120, | |
"wires": [ | |
[ | |
"e2e4390c.2df7d8", | |
"4b1098de.5f0268" | |
] | |
] | |
}, | |
{ | |
"id": "405f4ad0.8ea124", | |
"type": "switch", | |
"z": "bb696818.adb038", | |
"name": "", | |
"property": "payload.myq", | |
"propertyType": "msg", | |
"rules": [ | |
{ | |
"t": "nnull" | |
}, | |
{ | |
"t": "else" | |
} | |
], | |
"checkall": "false", | |
"outputs": 2, | |
"x": 503, | |
"y": 121, | |
"wires": [ | |
[ | |
"e3357aa4.0978d8" | |
], | |
[ | |
"edbda757.770fc8", | |
"f2779857.91b468" | |
] | |
] | |
}, | |
{ | |
"id": "b13641a3.823da", | |
"type": "debug", | |
"z": "bb696818.adb038", | |
"name": "", | |
"active": false, | |
"console": "false", | |
"complete": "true", | |
"x": 470, | |
"y": 40, | |
"wires": [] | |
}, | |
{ | |
"id": "4b1098de.5f0268", | |
"type": "function", | |
"z": "bb696818.adb038", | |
"name": "", | |
"func": "\nvar myq;\n\nif(msg.payload.myq) {\n myq = msg.payload.myq;\n} else {\n myq = global.get(\"myq\");\n}\n\nif(!myq) return msg;\n\n\n\n\nmsg.headers = {\n ContentType : \"application/json\",\n Accept : \"application/json\",\n MyQApplicationId : \"Vj8pQggXLhLy0WHahglCD4N1nAkkXQtGYpq2HrHD7H1nvmbT55KqtN6RSF4ILB/i\",\n Culture : \"en\",\n SecurityToken : myq.SecurityToken\n}\n\n\nreturn msg;\n\n", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 510, | |
"y": 240, | |
"wires": [ | |
[ | |
"6e65d74f.d01ef8" | |
] | |
] | |
}, | |
{ | |
"id": "33e9e92c.0b4cf6", | |
"type": "http request", | |
"z": "bb696818.adb038", | |
"name": "", | |
"method": "GET", | |
"ret": "obj", | |
"url": "https://myqexternal.myqdevice.com/api/v4/UserDeviceDetails/Get", | |
"tls": "", | |
"x": 710, | |
"y": 240, | |
"wires": [ | |
[ | |
"c41445ac.a06d88", | |
"e48eb9a8.bfcdd8" | |
] | |
] | |
}, | |
{ | |
"id": "4f7101bc.c6473", | |
"type": "function", | |
"z": "bb696818.adb038", | |
"name": "", | |
"func": "\nvar myq = global.get(\"myq\");\n\nmyq.devices = msg.payload.Devices;\nmyq.timestamp = new Date();\n\nglobal.set(\"myq\", myq);\n\nmsg.payload.myq = myq;\n\nvar state = \"unknown\";\nfor(var d in myq.devices) {\n var device = myq.devices[d];\n if(device && device.MyQDeviceTypeName && device.MyQDeviceTypeName == \"GarageDoorOpener\" && device.Attributes) {\n myq.garage = device;\n for(var a in device.Attributes) {\n var attribute = device.Attributes[a];\n if(attribute && attribute.AttributeDisplayName == \"doorstate\") {\n var state = attribute.Value + \"\";\n myq.garage.state = \"unknown\";\n if(state == \"1\") myq.garage.state = \"open\";\n if(state == \"2\") myq.garage.state = \"closed\";\n if(state == \"3\") myq.garage.state = \"stopped\";\n if(state == \"4\") myq.garage.state = \"opening\";\n if(state == \"5\") myq.garage.state = \"closing\";\n if(state == \"8\") myq.garage.state = \"moving\";\n if(state == \"9\") myq.garage.state = \"open\";\n }\n }\n }\n}\nif(msg.headers) delete msg.headers;\nif(msg.statusCode) delete msg.statusCode;\nif(msg.responseUrl) delete msg.responseUrl;\nif(msg.responseCookies) delete msg.responseCookies;\n\n\nmsg.payload = msg.payload.myq;\n\n\nvar last = global.get(\"myq_garage_last_known\")\nmsg.payload.garage.hasChanged = false;\nif(last && last != msg.payload.garage.state) {\n msg.payload.garage.hasChanged = true;\n}\nglobal.set(\"myq_garage_last_known\", msg.payload.garage.state);\n\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 850, | |
"y": 380, | |
"wires": [ | |
[ | |
"2216094.9c79cf6", | |
"a9216185.b9df5", | |
"12a71985.799606" | |
] | |
] | |
}, | |
{ | |
"id": "c41445ac.a06d88", | |
"type": "debug", | |
"z": "bb696818.adb038", | |
"name": "", | |
"active": false, | |
"console": "false", | |
"complete": "true", | |
"x": 950, | |
"y": 280, | |
"wires": [] | |
}, | |
{ | |
"id": "afdab30a.8318e", | |
"type": "switch", | |
"z": "bb696818.adb038", | |
"name": "", | |
"property": "payload.error", | |
"propertyType": "msg", | |
"rules": [ | |
{ | |
"t": "nnull" | |
}, | |
{ | |
"t": "else" | |
} | |
], | |
"checkall": "false", | |
"outputs": 2, | |
"x": 690, | |
"y": 360, | |
"wires": [ | |
[ | |
"a0f81216.0e393" | |
], | |
[ | |
"4f7101bc.c6473" | |
] | |
] | |
}, | |
{ | |
"id": "a0f81216.0e393", | |
"type": "function", | |
"z": "bb696818.adb038", | |
"name": "", | |
"func": "\nreturn { _msgid : msg._msgid }\n", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 950, | |
"y": 220, | |
"wires": [ | |
[ | |
"edbda757.770fc8" | |
] | |
] | |
}, | |
{ | |
"id": "e48eb9a8.bfcdd8", | |
"type": "function", | |
"z": "bb696818.adb038", | |
"name": "", | |
"func": "\n\nif(msg.payload.ErrorMessage && msg.payload.ErrorMessage != \"\") {\n msg.payload.error = msg.payload.ErrorMessage;\n}\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 690, | |
"y": 300, | |
"wires": [ | |
[ | |
"afdab30a.8318e" | |
] | |
] | |
}, | |
{ | |
"id": "2216094.9c79cf6", | |
"type": "debug", | |
"z": "bb696818.adb038", | |
"name": "", | |
"active": false, | |
"console": "false", | |
"complete": "true", | |
"x": 1070, | |
"y": 460, | |
"wires": [] | |
}, | |
{ | |
"id": "b3182561.8d1958", | |
"type": "comment", | |
"z": "bb696818.adb038", | |
"name": "", | |
"info": "https://github.com/jbnunn/Alexa-MyQGarage/blob/master/myq.py", | |
"x": 70, | |
"y": 220, | |
"wires": [] | |
}, | |
{ | |
"id": "8ada3b40.d4b388", | |
"type": "inject", | |
"z": "bb696818.adb038", | |
"name": "", | |
"topic": "garage/status", | |
"payload": "", | |
"payloadType": "date", | |
"repeat": "", | |
"crontab": "", | |
"once": false, | |
"x": 150, | |
"y": 40, | |
"wires": [ | |
[ | |
"7331b236.05a98c" | |
] | |
] | |
}, | |
{ | |
"id": "a9216185.b9df5", | |
"type": "mqtt out", | |
"z": "bb696818.adb038", | |
"name": "", | |
"topic": "garage", | |
"qos": "", | |
"retain": "", | |
"broker": "724ca09d.3fbec", | |
"x": 1083, | |
"y": 390, | |
"wires": [] | |
}, | |
{ | |
"id": "12a71985.799606", | |
"type": "switch", | |
"z": "bb696818.adb038", | |
"name": "", | |
"property": "payload.garage.hasChanged", | |
"propertyType": "msg", | |
"rules": [ | |
{ | |
"t": "true" | |
}, | |
{ | |
"t": "else" | |
} | |
], | |
"checkall": "false", | |
"outputs": 2, | |
"x": 850, | |
"y": 460, | |
"wires": [ | |
[ | |
"2f8bf702.048c08", | |
"48ace743.906888" | |
], | |
[ | |
"5c74216.04f8ee" | |
] | |
] | |
}, | |
{ | |
"id": "2f8bf702.048c08", | |
"type": "debug", | |
"z": "bb696818.adb038", | |
"name": "", | |
"active": false, | |
"console": "false", | |
"complete": "true", | |
"x": 1030, | |
"y": 560, | |
"wires": [] | |
}, | |
{ | |
"id": "5c74216.04f8ee", | |
"type": "debug", | |
"z": "bb696818.adb038", | |
"name": "", | |
"active": false, | |
"console": "false", | |
"complete": "true", | |
"x": 950, | |
"y": 600, | |
"wires": [] | |
}, | |
{ | |
"id": "48ace743.906888", | |
"type": "function", | |
"z": "bb696818.adb038", | |
"name": "", | |
"func": "\nmsg.payload = \"Garage door is \" + msg.payload.garage.state + \" at \" + msg.payload.timestamp;\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 1030, | |
"y": 500, | |
"wires": [ | |
[ | |
"76477350.35894c" | |
] | |
] | |
}, | |
{ | |
"id": "76477350.35894c", | |
"type": "mqtt out", | |
"z": "bb696818.adb038", | |
"name": "", | |
"topic": "twilio", | |
"qos": "", | |
"retain": "false", | |
"broker": "724ca09d.3fbec", | |
"x": 1190, | |
"y": 500, | |
"wires": [] | |
}, | |
{ | |
"id": "dbe74aef.a85ff8", | |
"type": "inject", | |
"z": "bb696818.adb038", | |
"name": "Close", | |
"topic": "garage/control", | |
"payload": "{\"desired_state\":\"close\"}", | |
"payloadType": "json", | |
"repeat": "", | |
"crontab": "", | |
"once": false, | |
"x": 90, | |
"y": 400, | |
"wires": [ | |
[ | |
"7331b236.05a98c" | |
] | |
] | |
}, | |
{ | |
"id": "e0116c4a.8933e", | |
"type": "debug", | |
"z": "bb696818.adb038", | |
"name": "", | |
"active": false, | |
"console": "false", | |
"complete": "true", | |
"x": 485, | |
"y": 508, | |
"wires": [] | |
}, | |
{ | |
"id": "1addef60.efa501", | |
"type": "http request", | |
"z": "bb696818.adb038", | |
"name": "", | |
"method": "PUT", | |
"ret": "obj", | |
"url": "https://myqexternal.myqdevice.com/api/v4/DeviceAttribute/PutDeviceAttribute", | |
"tls": "", | |
"x": 530, | |
"y": 440, | |
"wires": [ | |
[ | |
"60d9e276.3034dc", | |
"e49bc838.1e6f78" | |
] | |
] | |
}, | |
{ | |
"id": "5ca4df52.148ed", | |
"type": "function", | |
"z": "bb696818.adb038", | |
"name": "", | |
"func": "var myq;\n\nif(msg.payload.myq) {\n myq = msg.payload.myq;\n} else {\n myq = global.get(\"myq\");\n}\nvar open_close_state = 0; \nif (msg.desired_state && msg.desired_state == \"open\") open_close_state = 1;\n\nmsg.payload = {\n \"attributeName\": \"desireddoorstate\",\n \"myQDeviceId\": myq.garage.MyQDeviceId,\n \"AttributeValue\": open_close_state\n }\n\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 370, | |
"y": 420, | |
"wires": [ | |
[ | |
"e0116c4a.8933e", | |
"1addef60.efa501" | |
] | |
] | |
}, | |
{ | |
"id": "6e65d74f.d01ef8", | |
"type": "switch", | |
"z": "bb696818.adb038", | |
"name": "", | |
"property": "topic", | |
"propertyType": "msg", | |
"rules": [ | |
{ | |
"t": "eq", | |
"v": "garage/control", | |
"vt": "str" | |
}, | |
{ | |
"t": "else" | |
} | |
], | |
"checkall": "false", | |
"outputs": 2, | |
"x": 430, | |
"y": 320, | |
"wires": [ | |
[ | |
"5ca4df52.148ed" | |
], | |
[ | |
"33e9e92c.0b4cf6" | |
] | |
] | |
}, | |
{ | |
"id": "60d9e276.3034dc", | |
"type": "debug", | |
"z": "bb696818.adb038", | |
"name": "", | |
"active": false, | |
"console": "false", | |
"complete": "true", | |
"x": 690, | |
"y": 460, | |
"wires": [] | |
}, | |
{ | |
"id": "16ee294d.eece17", | |
"type": "inject", | |
"z": "bb696818.adb038", | |
"name": "Open", | |
"topic": "garage/control", | |
"payload": "{\"desired_state\":\"open\"}", | |
"payloadType": "json", | |
"repeat": "", | |
"crontab": "", | |
"once": false, | |
"x": 90, | |
"y": 440, | |
"wires": [ | |
[ | |
"7331b236.05a98c" | |
] | |
] | |
}, | |
{ | |
"id": "e49bc838.1e6f78", | |
"type": "mqtt out", | |
"z": "bb696818.adb038", | |
"name": "", | |
"topic": "garage/control/state", | |
"qos": "", | |
"retain": "false", | |
"broker": "724ca09d.3fbec", | |
"x": 750, | |
"y": 543, | |
"wires": [] | |
}, | |
{ | |
"id": "f02cd027.22457", | |
"type": "mqtt in", | |
"z": "bb696818.adb038", | |
"name": "", | |
"topic": "garage/control", | |
"qos": "2", | |
"broker": "724ca09d.3fbec", | |
"x": 89.5, | |
"y": 490, | |
"wires": [ | |
[ | |
"7331b236.05a98c" | |
] | |
] | |
}, | |
{ | |
"id": "e4e1cd3f.3808d", | |
"type": "mqtt in", | |
"z": "bb696818.adb038", | |
"name": "", | |
"topic": "garage/status", | |
"qos": "2", | |
"broker": "724ca09d.3fbec", | |
"x": 90, | |
"y": 120, | |
"wires": [ | |
[ | |
"7331b236.05a98c" | |
] | |
] | |
}, | |
{ | |
"id": "724ca09d.3fbec", | |
"type": "mqtt-broker", | |
"z": "", | |
"broker": "localhost", | |
"port": "1883", | |
"clientid": "", | |
"usetls": false, | |
"compatmode": false, | |
"keepalive": "60", | |
"cleansession": true, | |
"willTopic": "", | |
"willQos": "0", | |
"willPayload": "", | |
"birthTopic": "", | |
"birthQos": "0", | |
"birthPayload": "" | |
} | |
] |
I have a MyQ garage door and gate. Will this flow support both in the same flow?
I have a MyQ garage door and gate. Will this flow support both in the same flow?
Good day. I don’t have any idea for sure but I wouldn’t see any reason why it would be a problem to do so.
I made the move off MyQ months ago, so I no longer have the hardware to maintain this flow
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where does one get the value of the header value "MyQApplicationId" from? I see it hard coded in the flow but that can't be the same across different users
Nevermind: found that the App_ID is indeed the same for anyone! Thanks for the great flow, it works great!