lsibarra Posted March 5, 2017 Posted March 5, 2017 Hi xKing, after 58 minutes I started getting this error and the garage will not respond at this time. See error below 2017-03-04 12:53:13,503 ERROR Traceback (most recent call last): 2017-03-04 12:53:13,503 ERROR File "/home/pi/node/myq-garage.p ", line 407, in <module> 2017-03-04 12:53:13,504 ERROR gdoor_main() 2017-03-04 12:53:13,504 ERROR File "/home/pi/node/myq-garage.p ", line 396, in gdoor_main 2017-03-04 12:53:13,505 ERROR print(doorname + ' not found in av ilable doors.') 2017-03-04 12:53:13,505 ERROR UnboundLocalError 2017-03-04 12:53:13,505 ERROR : 2017-03-04 12:53:13,505 ERROR local variable 'doorname' referenc d before assignment 2017-03-04 14:37:59,209 INFO ================================== TARTED================================== 2017-03-04 14:41:08,850 INFO ================================== TARTED================================== pi@raspberrypi:~/node/logs $
xKing Posted March 5, 2017 Posted March 5, 2017 you can pull the updated myq-garage.py from here https://github.com/exking/myq-garage/ or wait for Einstein.42 to review the change
lsibarra Posted March 5, 2017 Posted March 5, 2017 Hi xKing, I downloaded the file and the ISY network resource commands is not responding with the new file. However, it is working if I run the command ./myq-garage.py open [doorname] via terminal.
lsibarra Posted March 5, 2017 Posted March 5, 2017 Hi xKing, Disregard the issue I mentioned above regarding the new file. I forgot to declare the full path on the config file as you instructed earlier. After adding /home/pi/node/config.ini on the config.read line, it is working now. I will keep you posted on the myqtoken file issue. I still have the TOKENTTL set to 8. Thanks
xKing Posted March 5, 2017 Posted March 5, 2017 Awesome! If it runs good for some time - you can probably bump it up to like 45 or 60 minutes and let it handle re-authentication.
lsibarra Posted March 6, 2017 Posted March 6, 2017 (edited) Hi xKing, I just updated the TOKENTTL to 60. I will let you know how it goes. One thing I noticed after changing the config.read path to full path ('home/pi/node/config.ini') I am no longer able to run it from the terminal. I started getting this error below when i sent this command from the terminal [pi@raspberrypi:~/node $ ./myq-garage.py status] pi@raspberrypi:~/node $ ./myq-garage.py status Traceback (most recent call last): File "./myq-garage.py", line 57, in <module> USERNAME = config.get('main', 'USERNAME') File "/usr/lib/python2.7/ConfigParser.py", line 330, in get raise NoSectionError(section) ConfigParser.NoSectionError: No section: 'main' However, changing it back to [config.read('config.ini')] works in the terminal but not in ISY. Any idea what I am doing wrong here? Thanks for all your help. Edited March 6, 2017 by lsibarra
xKing Posted March 6, 2017 Posted March 6, 2017 to full path ('home/pi/node/config.ini') That does not look like a full path, think you missing / in front ('/home/pi/node/config.ini')
lsibarra Posted March 7, 2017 Posted March 7, 2017 Hi xKing, I cannot thank you enough for guiding me through this. The '/' was indeed the issue and after adding that.. all is well. I changed the TOKENTTL to 60 and all of that is working perfectly as well. Thank you again for all your help and patience with me.
tehinternet Posted March 27, 2017 Posted March 27, 2017 Hello, Thank you for developing this script and making it public. It's very helpful. I've been experimenting with it on my rasberry pi with the most simple configuration ever; I just added my username/password for my MyQ account and it works for my Chamberlain garage door opener! But, as others have recently reported, I have a problem where after sometime the script no longer returns results (e.g. ./myq_garage.py status returns nothing). I need to delete /tmp/myqtoken.json for it to work again. I first installed it last night, but by this morning I needed to remove /tmp/myqtoken.json for it to work again. Then this morning once I got it working, 2 hours later when I attempt to use it again, it wasn't working. I have not yet done testing to see how long I can get it to work for. /tmp/myqtoken.json is getting created by the standard linux user which I'm using when I run the myq-garage.py from the command line. When it's not working, deleting that file appears to make it work again. I have attempted to change the config.ini's TOKENTTL value from 60 to 50, but that had no effect. Shouldn't the token be getting deleted after 60 (or 50) minutes? Why do I have to manually delete it? What changes would you guys recommend so that this script can be reliably called when needed? Thank you! Also, below, is my log this morning when it wasn't working. The time is a little screwy on my system due to UTC offset. Here is what these times break down to if it helps. 7:00 and 8:00 hour: Over night when I was not using this script or the garage door. When I went to bed it was working. 10:00 hour: When I found it wasn't working this morning and needed to delete the token file to make it work again. Deleted the token file about 10:30. 11:00 to 12:00: When I left the plugin working and went to work. 12:29: Arrived at work to find the plugin no longer working. 13:01: Deleted the token file and the script was working again. 2017-03-27 00:07:12,432 INFO ==================================STARTED==================================2017-03-27 00:07:13,487 INFO Garage Door is Closed. Last changed at Sun 26 Mar 2017 23:52:222017-03-27 00:07:13,558 ERROR Caught Exception in isy_get_var_id: ('Connection aborted.', gaierror(-2, 'Name or service not known'))2017-03-27 00:07:13,561 ERROR Traceback (most recent call last):2017-03-27 00:07:13,562 ERROR File "./myq-garage.py", line 407, in <module>2017-03-27 00:07:13,565 ERROR gdoor_main()2017-03-27 00:07:13,567 ERROR File "./myq-garage.py", line 380, in gdoor_main2017-03-27 00:07:13,569 ERROR id, varname, init, value = isy_get_var_id(inst.name)2017-03-27 00:07:13,571 ERROR TypeError2017-03-27 00:07:13,572 ERROR :2017-03-27 00:07:13,574 ERROR 'NoneType' object is not iterable2017-03-27 00:07:52,759 INFO ==================================STARTED==================================2017-03-27 00:07:53,908 ERROR Caught Exception in isy_get_var_id: ('Connection aborted.', gaierror(-2, 'Name or service not known'))2017-03-27 00:07:53,911 ERROR Traceback (most recent call last):2017-03-27 00:07:53,913 ERROR File "./myq-garage.py", line 407, in <module>2017-03-27 00:07:53,915 ERROR gdoor_main()2017-03-27 00:07:53,917 ERROR File "./myq-garage.py", line 391, in gdoor_main2017-03-27 00:07:53,919 ERROR id, varname, init, value = isy_get_var_id(inst.name)2017-03-27 00:07:53,921 ERROR TypeError2017-03-27 00:07:53,923 ERROR :2017-03-27 00:07:53,924 ERROR 'NoneType' object is not iterable2017-03-27 00:07:59,447 INFO ==================================STARTED==================================2017-03-27 00:08:00,421 INFO Garage Door is Opening. Last changed at Mon 27 Mar 2017 00:07:552017-03-27 00:08:00,487 ERROR Caught Exception in isy_get_var_id: ('Connection aborted.', gaierror(-2, 'Name or service not known'))2017-03-27 00:08:00,490 ERROR Traceback (most recent call last):2017-03-27 00:08:00,492 ERROR File "./myq-garage.py", line 407, in <module>2017-03-27 00:08:00,494 ERROR gdoor_main()2017-03-27 00:08:00,496 ERROR File "./myq-garage.py", line 380, in gdoor_main2017-03-27 00:08:00,499 ERROR id, varname, init, value = isy_get_var_id(inst.name)2017-03-27 00:08:00,500 ERROR TypeError2017-03-27 00:08:00,502 ERROR :2017-03-27 00:08:00,503 ERROR 'NoneType' object is not iterable2017-03-27 00:08:04,022 INFO ==================================STARTED==================================2017-03-27 00:08:04,945 INFO Garage Door is Opening. Last changed at Mon 27 Mar 2017 00:07:552017-03-27 00:08:05,014 ERROR Caught Exception in isy_get_var_id: ('Connection aborted.', gaierror(-2, 'Name or service not known')) 2017-03-27 00:08:05,016 ERROR Traceback (most recent call last):2017-03-27 00:08:05,018 ERROR File "./myq-garage.py", line 407, in <module>2017-03-27 00:08:05,021 ERROR gdoor_main()2017-03-27 00:08:05,023 ERROR File "./myq-garage.py", line 380, in gdoor_main2017-03-27 00:08:05,025 ERROR id, varname, init, value = isy_get_var_id(inst.name)2017-03-27 00:08:05,027 ERROR TypeError2017-03-27 00:08:05,028 ERROR :2017-03-27 00:08:05,030 ERROR 'NoneType' object is not iterable2017-03-27 00:08:07,852 INFO ==================================STARTED==================================2017-03-27 00:08:08,803 INFO Garage Door is Opening. Last changed at Mon 27 Mar 2017 00:07:552017-03-27 00:08:08,869 ERROR Caught Exception in isy_get_var_id: ('Connection aborted.', gaierror(-2, 'Name or service not known'))2017-03-27 00:08:08,871 ERROR Traceback (most recent call last):2017-03-27 00:08:08,873 ERROR File "./myq-garage.py", line 407, in <module>2017-03-27 00:08:08,875 ERROR gdoor_main()2017-03-27 00:08:08,877 ERROR File "./myq-garage.py", line 380, in gdoor_main2017-03-27 00:08:08,880 ERROR id, varname, init, value = isy_get_var_id(inst.name)2017-03-27 00:08:08,881 ERROR TypeError2017-03-27 00:08:08,883 ERROR :2017-03-27 00:08:08,884 ERROR 'NoneType' object is not iterable2017-03-27 00:08:11,034 INFO ==================================STARTED==================================2017-03-27 00:08:12,023 INFO Garage Door is Open. Last changed at Mon 27 Mar 2017 00:08:092017-03-27 00:08:12,092 ERROR Caught Exception in isy_get_var_id: ('Connection aborted.', gaierror(-2, 'Name or service not known'))2017-03-27 00:08:12,095 ERROR Traceback (most recent call last):2017-03-27 00:08:12,096 ERROR File "./myq-garage.py", line 407, in <module>2017-03-27 00:08:12,099 ERROR gdoor_main()2017-03-27 00:08:12,101 ERROR File "./myq-garage.py", line 380, in gdoor_main2017-03-27 00:08:12,103 ERROR id, varname, init, value = isy_get_var_id(inst.name)2017-03-27 00:08:12,105 ERROR TypeError2017-03-27 00:08:12,106 ERROR :2017-03-27 00:08:12,108 ERROR 'NoneType' object is not iterable2017-03-27 00:08:15,108 INFO ==================================STARTED==================================2017-03-27 00:08:16,053 INFO Garage Door is Open. Last changed at Mon 27 Mar 2017 00:08:092017-03-27 00:08:16,130 ERROR Caught Exception in isy_get_var_id: ('Connection aborted.', gaierror(-2, 'Name or service not known'))2017-03-27 00:08:16,132 ERROR Traceback (most recent call last): 2017-03-27 00:08:16,134 ERROR File "./myq-garage.py", line 407, in <module>2017-03-27 00:08:16,136 ERROR gdoor_main()2017-03-27 00:08:16,138 ERROR File "./myq-garage.py", line 380, in gdoor_main2017-03-27 00:08:16,141 ERROR id, varname, init, value = isy_get_var_id(inst.name)2017-03-27 00:08:16,143 ERROR TypeError2017-03-27 00:08:16,144 ERROR :2017-03-27 00:08:16,146 ERROR 'NoneType' object is not iterable2017-03-27 10:32:39,220 INFO ==================================STARTED==================================2017-03-27 10:32:47,251 INFO ==================================STARTED==================================2017-03-27 10:32:51,102 INFO ==================================STARTED==================================2017-03-27 10:33:21,730 INFO ==================================STARTED==================================2017-03-27 10:41:55,218 INFO ==================================STARTED==================================2017-03-27 10:43:12,552 INFO ==================================STARTED==================================2017-03-27 10:43:14,650 INFO Garage Door is Open. Last changed at Mon 27 Mar 2017 00:08:092017-03-27 10:43:15,098 ERROR Caught Exception in isy_get_var_id: ('Connection aborted.', gaierror(-2, 'Name or service not known'))2017-03-27 10:43:15,101 ERROR Traceback (most recent call last):2017-03-27 10:43:15,103 ERROR File "./myq-garage.py", line 407, in <module>2017-03-27 10:43:15,106 ERROR gdoor_main()2017-03-27 10:43:15,108 ERROR File "./myq-garage.py", line 380, in gdoor_main2017-03-27 10:43:15,110 ERROR id, varname, init, value = isy_get_var_id(inst.name)2017-03-27 10:43:15,112 ERROR TypeError2017-03-27 10:43:15,114 ERROR :2017-03-27 10:43:15,116 ERROR 'NoneType' object is not iterable2017-03-27 10:49:25,594 INFO ==================================STARTED==================================2017-03-27 10:49:26,651 INFO Garage Door is Closed. Last changed at Mon 27 Mar 2017 10:43:502017-03-27 10:49:26,721 ERROR Caught Exception in isy_get_var_id: ('Connection aborted.', gaierror(-2, 'Name or service not known'))2017-03-27 10:49:26,723 ERROR Traceback (most recent call last):2017-03-27 10:49:26,725 ERROR File "./myq-garage.py", line 407, in <module>2017-03-27 10:49:26,727 ERROR gdoor_main()2017-03-27 10:49:26,729 ERROR File "./myq-garage.py", line 380, in gdoor_main2017-03-27 10:49:26,731 ERROR id, varname, init, value = isy_get_var_id(inst.name)2017-03-27 10:49:26,733 ERROR TypeError2017-03-27 10:49:26,734 ERROR :2017-03-27 10:49:26,736 ERROR 'NoneType' object is not iterable2017-03-27 12:29:54,301 INFO ==================================STARTED==================================2017-03-27 13:00:53,882 INFO ==================================STARTED==================================2017-03-27 13:01:06,165 INFO ==================================STARTED==================================2017-03-27 13:01:07,272 INFO Garage Door is Closed. Last changed at Mon 27 Mar 2017 11:20:002017-03-27 13:01:07,427 ERROR Caught Exception in isy_get_var_id: ('Connection aborted.', gaierror(-2, 'Name or service not known'))2017-03-27 13:01:07,430 ERROR Traceback (most recent call last):2017-03-27 13:01:07,431 ERROR File "./myq-garage.py", line 407, in <module>2017-03-27 13:01:07,434 ERROR gdoor_main()2017-03-27 13:01:07,435 ERROR File "./myq-garage.py", line 380, in gdoor_main2017-03-27 13:01:07,438 ERROR id, varname, init, value = isy_get_var_id(inst.name)2017-03-27 13:01:07,440 ERROR TypeError2017-03-27 13:01:07,441 ERROR :2017-03-27 13:01:07,443 ERROR 'NoneType' object is not iterable
xKing Posted March 27, 2017 Posted March 27, 2017 you can fetch the fixed version here https://github.com/exking/myq-garage/ I've also submitted a pull request to the original repository so waiting on Mr. Einstein.42's approval to do so.
tehinternet Posted March 27, 2017 Posted March 27, 2017 (edited) Thank you xKing. I'll give that version a try. Also, as an end-user I ran into a little problem in this scenario. I can run the script fine as a normal linux user from the command line. I am attempting to run this python script via PHP using the exec_shell() function within PHP. When I do that, it's really being run as my apache user (www-data). The problem is that www-data can execute the python script, but it dies quickly with this error: Traceback (most recent call last): File "/home/trent/hal/garage_door/myq-garage.py", line 57, in <module> USERNAME = config.get('main', 'USERNAME') File "/usr/lib/python2.7/ConfigParser.py", line 330, in get raise NoSectionError(section) ConfigParser.NoSectionError: No section: 'main' I found that this is because the www-data user really isn't sitting in the directory where the scipt and the config.ini are held. It can run the script, but it doesn't know where to find the config.ini. To resolve this, I had to edit the python script and change this line: config.read('config.ini') to config.read('/full/path/to/find/config.ini') Regardless if my web server or PHP is running the script, this problem is reproducible as a normal user if you run the myq-garage.py script not from the directory it's located in. For example: This works: $ pwd /home/user/garage $./myq-garage.py This would not work: $pwd /home/user/garage $cd ../.. $pwd /home $ /home/user/garage/myq-garage.py Traceback (most recent call last): File "/home/trent/hal/garage_door/myq-garage.py", line 57, in <module> USERNAME = config.get('main', 'USERNAME') File "/usr/lib/python2.7/ConfigParser.py", line 330, in get raise NoSectionError(section) ConfigParser.NoSectionError: No section: 'main' This may not be a concern if you're using ICY, but if you're trying to use it in other ways like I am, it might be problematic for some users. My recommendation, for what it's worth, would be to make a user configurable variable in the top of the python script (which screams out to the user to edit it) which points to the full path of the config file. Or combine the config and script into a singe file. Or make the config file a Python script which then calls the main Python script which interacts with the Chamberain API. xKing, thanks again. I just found this form script yesterday, so I hope to mess with it more and I'll let you know if it solved my token problem or not. EDIT: xKing, I found a little odd thing when running your version. With Mr.Einstin's version I could run it from my command line like this: ./my* status but for yours that fails and it tells me the proper syntax. Your version requires my to run it as ./myq-garage status Basically I can't wildcard the name of the python script when running it. That's kinda odd. I've seen that before, but I can't remember what the fix is. Edited March 27, 2017 by tehinternet
xKing Posted March 28, 2017 Posted March 28, 2017 btw, I have a cgi script if you like running under apache https://github.com/exking/myq-cgi and it uses different token save filename
tehinternet Posted March 28, 2017 Posted March 28, 2017 (edited) btw, I have a cgi script if you like running under apache https://github.com/exking/myq-cgi and it uses different token save filename Thanks. That looks very helpful! Also, BTW, your version of the base myq-garage script does appear to fix the problem with having to delete the token. Been running great for about 24 hours now as I build a custom home website around it. Edited March 28, 2017 by tehinternet
godoorgo Posted June 21, 2017 Posted June 21, 2017 (edited) I revisited this script and still cannot get it to work. I see it is authenticating because if I put in bogus credentials I get an authentication error. Here's what I get with the correct username and password. If I don't provide a door ID, status returns nothing. If I provide an ID, I get an error and more in the log. pi@raspberrypi:~/myq-garage $ pwd /home/pi/myq-garage pi@raspberrypi:~/myq-garage $ ls -la total 44 drwxr-xr-x 4 pi pi 4096 Jun 21 18:48 . drwxr-xr-x 8 pi pi 4096 Jun 21 18:53 .. -rwxr-xr-x 1 pi pi 803 Jun 21 18:32 config.ini drwxr-xr-x 8 pi pi 4096 Jun 21 17:54 .git -rw-r--r-- 1 pi pi 1067 Jun 21 17:54 LICENSE drwxr-xr-x 2 pi pi 4096 Jun 21 18:53 logs -rwxr-xr-x 1 pi pi 15421 Jun 21 17:54 myq-garage.py -rw-r--r-- 1 pi pi 1928 Jun 21 17:54 README.md pi@raspberrypi:~/myq-garage $ ./myq-garage.py status pi@raspberrypi:~/myq-garage $ tail logs/myq-garage.log 2017-06-21 18:53:17,879 INFO ==================================STARTED================================== pi@raspberrypi:~/myq-garage $ ./myq-garage.py status 0 Usage: ./myq-garage.py [open/close/status] [door ID] pi@raspberrypi:~/myq-garage $ tail logs/myq-garage.log 2017-06-21 18:53:17,879 INFO ==================================STARTED================================== 2017-06-21 18:53:35,342 INFO ==================================STARTED================================== 2017-06-21 18:53:35,893 ERROR Traceback (most recent call last): 2017-06-21 18:53:35,894 ERROR File "./myq-garage.py", line 407, in <module> 2017-06-21 18:53:35,910 ERROR gdoor_main() 2017-06-21 18:53:35,910 ERROR File "./myq-garage.py", line 396, in gdoor_main 2017-06-21 18:53:35,911 ERROR print(doorname + ' not found in available doors.') 2017-06-21 18:53:35,911 ERROR UnboundLocalError 2017-06-21 18:53:35,911 ERROR : 2017-06-21 18:53:35,911 ERROR local variable 'doorname' referenced before assignment pi@raspberrypi:~/myq-garage $ Any idea what the issue is? Thanks Edited June 22, 2017 by godoorgo
brbeaird Posted September 18, 2017 Posted September 18, 2017 Has anyone had any luck with this in the UK or elsewhere in Europe? It seems like the MyQApplicationId value is different somehow over there because I get an Unauthorized message when trying to get the doors, but I'm not sure how to figure out what that ID is.
xKing Posted September 18, 2017 Posted September 18, 2017 I've used Windows app called "Fiddler" previously (and set it as proxy on my iPhone) to sniff out the exchange between MyQ app and their server, not sure if that technique still works, give it a try.
G W Posted September 18, 2017 Posted September 18, 2017 I've used Windows app called "Fiddler" previously (and set it as proxy on my iPhone) to sniff out the exchange between MyQ app and their server, not sure if that technique still works, give it a try.Are you having your phone connect to your PC for its Wi-Fi? Sent from my Nexus 6P using Tapatalk
xKing Posted September 18, 2017 Posted September 18, 2017 huh? No, just configure my pc as a proxy on iPhone for that session
G W Posted September 18, 2017 Posted September 18, 2017 Okay. I understand. An idea I hadn't thought of. Sent from my SM-G955U1 using Tapatalk
xKing Posted September 19, 2017 Posted September 19, 2017 works great unless app developer uses certificate pinning so app won't accept "fake" Fiddler's root certificate. But in that case you can sniff exchange between your browser and web portal (there is no pinning possible in this case)
G W Posted September 19, 2017 Posted September 19, 2017 works great unless app developer uses certificate pinning so app won't accept "fake" Fiddler's root certificate. But in that case you can sniff exchange between your browser and web portal (there is no pinning possible in this case)Except that the phone applicationons use a different API than the web portal. Sent from my Nexus 6P using Tapatalk
Recommended Posts