Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues after the update #9

Closed
JerGitHub opened this issue Jan 10, 2016 · 13 comments
Closed

Issues after the update #9

JerGitHub opened this issue Jan 10, 2016 · 13 comments

Comments

@JerGitHub
Copy link

So....I had everything working with the sanity check code as you guys know. Now - I deleted homekit data on my iPhone, deleted persist, rebooted, and updated everything to:

homebridge to 0.2.15
homebridge-liftmaster to 0.1.1
(and homebridge-nest to 1.0.1 which is a different issue)

Now I'm back to square one. Nothing is working. When I start up Elgato Eve all three of my doors are "Open" when they are all really all Closed. Here is the output of homebridge. Any ideas?

Homebridge is running on port 51826.
[L Garage Door] Logged in with user ID 0
[L Garage Door] Found an opener with ID #####82 [doorstate: undefined]
[L Garage Door] Getting current state: undefined
[J Garage Door] Logged in with user ID 0
[J Garage Door] Found an opener with ID #####83 [doorstate: undefined]
[J Garage Door] Getting current state: undefined
[A Garage Door] Logged in with user ID 0
[A Garage Door] Found an opener with ID #####81 [doorstate: undefined]
[A Garage Door] Getting current state: undefined
[A Garage Door] Logged in with user ID 0
.......
[J Garage Door] Logged in with user ID 0
[J Garage Door] Found an opener with ID #####83. Ready to send command...
[J Garage Door] State was successfully set.
[J Garage Door] Raw response {"UpdatedTime":"1452444093676","ReturnCode":"0","ErrorMessage":"","CorrelationId":"236112fe-15aa-4660-95f9-318078a0b275"}
[J Garage Door] Logged in with user ID 0
[J Garage Door] Found an opener with ID #####83. Ready to send command...
[J Garage Door] State was successfully set.
[J Garage Door] Raw response {"UpdatedTime":"1452444094954","ReturnCode":"0","ErrorMessage":"","CorrelationId":"20fa9c6a-b427-495e-b9e7-c8d02e7e271e"}
.......
[L Garage Door] Logged in with user ID 0
/opt/local/lib/node_modules/homebridge-liftmaster/index.js:103
for (var i=0; i<devices.length; i++) {
^

TypeError: Cannot read property 'length' of undefined
at Request._callback (/opt/local/lib/node_modules/homebridge-liftmaster/index.js:103:32)
at Request.self.callback (/opt/local/lib/node_modules/homebridge-liftmaster/node_modules/request/request.js:373:22)
at emitTwo (events.js:87:13)
at Request.emit (events.js:172:7)
at Request. (/opt/local/lib/node_modules/homebridge-liftmaster/node_modules/request/request.js:1318:14)
at emitOne (events.js:82:20)
at Request.emit (events.js:169:7)
at IncomingMessage. (/opt/local/lib/node_modules/homebridge-liftmaster/node_modules/request/request.js:1266:12)
at emitNone (events.js:72:20)
at IncomingMessage.emit (events.js:166:7)
at endReadableNT (_stream_readable.js:905:12)
at doNTCallback2 (node.js:441:9)
at process._tickCallback (node.js:355:17)

@danoday
Copy link

danoday commented Jan 10, 2016

(edited to add one more variable to the logging)

That is a bit odd - this part of the code wasn't changed.

The failure looks to be at line 103, which is a fairly innocuous loop early in the process. Looks like it is reading the length of "devices", which should have been populated previously by the call to the Chamberlin/Liftmaster site.

Let's try dumping the values of both devices and body to the log, to confirm that this is really pulling data from Chamberlin/Liftmaster properly. We'll also add the length of devices. Find the following block of code in INDEX.JS (should start at line 97) and add the three lines that start with "that.log". I tried to bold them, but haven't been able to figure out the nuances of Github's markdown.

        // parse and interpret the response
        var json = JSON.parse(body);
        var devices = json["Devices"];
        var foundDoors = [];
        that.log("Body: " + body);
        that.log("Devices: " + devices);
        that.log("Devices Length: " + devices.length);

        // look through the array of devices for an opener
        for (var i=0; i<devices.length; i++) {
          var device = devices[i];

The first field returned should be the body of text from Chamberlin/Liftmaster. This is going to be a very long string with lots of variables in it. The second should have one device entry for each of the devices you have in the house. For me, I have an embedded MyQ on each of two garage door openers, so Chamberlin/Liftmaster recognized four devices - two controllers and two garage door openers. My devices log line looks like this:

Devices: [object Object],[object Object],[object Object],[object Object]

The third returns the length of devices, which for me is 4. This is what the loop is counting to, and if it returns zero, you've got a problem.

I suspect when you do this, you might find that the devices line is empty... but I'm still not certain as to why. Look through the body for your devices, and then tell me how many devices you think it should find versus how many devices are actually in the devices variable. Same goes for the Devices Length line... that will likely be zero.

Dan

@JerGitHub
Copy link
Author

Damn! You weren't kidding about the length of the "Body" line. I truncated that but here's what I have for the others. I suspect I have a bunch of objects because I have linked my Nests to the MyQ app and also have a MyQ light - not just 3 garage doors. Think this is what is throwing it off? Like I said - everything was working perfectly until I updated everything which is weird.

Homebridge is running on port 51826.
[L Garage Door] Logged in with user ID 0
[L Garage Door] Body: (TRUNCATED)
[L Garage Door] Devices: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[L Garage Door] Found an opener with ID #####82 [doorstate: undefined]
[L Garage Door] Getting current state: undefined
[A Garage Door] Logged in with user ID 0
[A Garage Door] Body: (TRUNCATED)
[A Garage Door] Devices: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[A Garage Door] Found an opener with ID #####81 [doorstate: undefined]
[A Garage Door] Getting current state: undefined
[J Garage Door] Logged in with user ID 0
[J Garage Door] Body: (TRUNCATED)
[J Garage Door] Devices: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[J Garage Door] Found an opener with ID #####83 [doorstate: undefined]
[J Garage Door] Getting current state: undefined

@danoday
Copy link

danoday commented Jan 10, 2016

Did you also add the "that.log("Devices Length: " + devices.length);" line in per the updated instructions above (I made an edit a couple of minutes after writing the original, but it may not have been the one e-mailed). That will show the number of devices in the loop - which should probably be 13.

@danoday
Copy link

danoday commented Jan 10, 2016

Another thing to consider - I don't know if body has a practical length. It might be that 13 devices is overloading it, and the loop is crashing because it isn't finding all the data in the array that it expects. Without doing a deep analysis of the contents of the body variable, I'm not sure how to diagnose that.

Here's a thought. Could you delete the devices like lights, nests, etc, and try it with just the basic garage doors on your account? If that works, try adding the light and the nests one-by-one, testing after each addition? This is really a shot in the dark, btw.

@JerGitHub
Copy link
Author

I didn't see that 3rd line in the log debug. Just added it and got 13 for each:

[A Garage Door] Devices Length: 13
[J Garage Door] Devices Length: 13
[L Garage Door] Devices Length: 13

I will try unlinking the Nests and the lights in the MyQ app and then retry. Give me a little bit to test and I'll reply back. Thanks!

@JerGitHub
Copy link
Author

OK - just unlinked and deleted everything but the garage doors and I have "Devices Length: 4" which is 1 more than what I actually have. That's strange in my opinion since I have 3 garage doors.

All 3 say "Open" in the Elgate Eve app when all 3 are Closed....

So weird since everything was working fine until I updated homebridge and homebridge-liftmaster.

@JerGitHub
Copy link
Author

OK testing a little more....It looks like Elgato Eve says all 3 are Open when they are Closed but if you tap for more info - "Closed" is highlighted. So if I press on "Open" it opens that garage door and if I tap on "Closed" it will close that garage door. However, you can't use Siri in HomeKit to Open and Close them anymore because the status always shows "Open".

When I opened from the Eve app:
[J Garage Door] Found an opener with ID #####83. Ready to send command...
[J Garage Door] State was successfully set.
[J Garage Door] Raw response {"UpdatedTime":"1452474538993","ReturnCode":"0","ErrorMessage":"","CorrelationId":"f2c289e1-77ed-4182-bf14-1de23ba23767"}

When I closed from the Eve app:
[J Garage Door] Found an opener with ID #####83. Ready to send command...
[J Garage Door] State was successfully set.
[J Garage Door] Raw response {"UpdatedTime":"1452474624426","ReturnCode":"0","ErrorMessage":"","CorrelationId":"ad51777c-1d1b-4324-bbd8-035ae45411cc"}

img_4548
img_4549

@AppleTechy
Copy link
Collaborator

AppleTechy commented Jan 11, 2016 via email

@JerGitHub
Copy link
Author

Unfortunately manually refreshing does nothing to change it. It still shows all garage doors as Open when all are Closed. And HomeKit/Siri think they are Open so you can't Open or close them. Asking Siri if one of the 3 garage doors is Open or asking her if it is Closed always gives a response that they are "Open".

Like I mentioned above - So weird since everything was working fine until I updated homebridge and homebridge-liftmaster.

@danoday
Copy link

danoday commented Jan 11, 2016

I'm betting your configuration is one MyQ Internet gateway controlling three doors - is this correct? If so, this would account for the four devices - one gateway, three openers. I have two of the 8500W openers with MyQ built into each, so I have four devices - two gateways, two openers.

So, did removing the additional devices at least get past the

TypeError: Cannot read property 'length' of undefined
at Request._callback (/opt/local/lib/node_modules/homebridge-liftmaster/index.js:103:32)

error in the log? If so, I think we've identified a possible bug related to too many devices. I'd appreciate it if you would add them back one by one and see how many devices causes it to crash again. We can open a separate ticket for that bug, if we can prove it out.

As for Elgato's Eve app not refreshing properly, it sounds like AppleTechy has a better explanation of that. I'm sort of seeing the same thing in the Home app when I manually open and close the door using the button. It doesn't actually query status until I click something that brings up device details.

Not sure how the Liftmaster app updates the status in near real-time, although it seems to do some. Has anyone actually done an analysis of the traffic between the MyQ app and Liftmaster? Is Liftmaster pushing a state change out to the app, or is the app almost constantly polling the Liftmaster servers looking for updates?

@AppleTechy
Copy link
Collaborator

@danoday , @nfarina and I have both looked at the traffic being sent by the MYQ app you can also view the data by using a program such as Charles Proxy and intercepting and requests. I would look right now but am other wise occupied at the moment.

@JerGitHub
Copy link
Author

@danoday you are correct - I have one MyQ Internet gateway controlling three doors. That makes sense now and why it would show 4. I haven't received that error in the past 24 hours since taking all of the other devices out so I will start adding them in and see what happens.

On the flip side, I haven't been able to use Siri or HomeKit to control the garage doors since upgrading because it is stuck in "Open". Let me know if there is anything else you think I should try to get things working again. Thanks.

@JerGitHub
Copy link
Author

Just updated homebridge-liftmaster from 0.1.1 to 0.1.2 and it's working again. Just make sure you have the naming working right if you have more than one garage door. See #11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants