-
Notifications
You must be signed in to change notification settings - Fork 3
Unexpected error fetching Schlage data: string indices must be integers #45
Comments
That's an interesting error. That means the API is returning some sort of raw string for access codes instead of the expected JSON object. I'll merge #46 and push a new release which should at least suppress the error for you. I am interested in what the API is returning for you, though. Are you able to run the script in this gist and give me the output? (Feel free to redact any personal data if it outputs any): https://gist.github.com/dknowles2/3eebe440eeee490770cbfc0365272500 |
I pushed a new release, 2023.3.2, that should at least stop initialization from erroring out. Hopefully that fixes it for you! |
Wow - you are on it with the debug script + initialization fix! Installing the update now so I can see which of the locks is actually giving me the error on initialization. I'll run the script when I get to something with a usable terminal :) |
So, I used pprint so I could parse through the output to remove any sensitive information - here is the output with pprint. I wound up omitting "friendlyName", "accessCode" and "accesscodeId". They all seemed like sane values in the output, except for one of the "accessCode" responses which was only a three digit code as opposed to a four digit code. Not sure how that happened. With the latest version of ha-schlage installed on my HA instance, initialization is working, and all devices that previously existed still now exist, but two fail to lock (the same two that fail to initialize, looking at the logs). Here's the output from the debug script (modified slightly to use pprint)
|
That's really strange. Passing those values into the Did each lock return its access codes? Was one of the replies an empty string? |
Okay, I'm actually seeing this in my own logs as well. I'll try and take a look later tonight. I see two different but similar stacktraces:
and
I suspect this is transient, since my locks seem to still be working. But I'll try and make the code a bit more defensive against this. |
I ran a test overnight and it failed in yet another spot where I wasn't able to grab the output. I suspect what's happening is that the API is returning an unexpected error which doesn't return a JSON dict as expected. (In normal circumstances, it seems that HTTP errors from the API are supposed to return a JSON dict like Whatever is returned must still be valid JSON though because the requests library would raise a I'm running a different test now to see if I can catch it. |
Ah, got it! I ran into a I think the fix here is actually to explicitly look for HTTP errors in the response and raise an error (and possibly retry the request as well). That can be caught properly in the HA code since HTTP errors are always a possibility when calling a cloud API. I'll work on a fix tonight after work. |
Super impressed with the follow-up here! Sorry for the silence. Thank you again! |
Hi! Thanks for your work on the Schlage encode Wi-Fi lock. After years of waiting, I appreciate it, and I know others do too!
I was unsure of whether to put this issue here, or in pyschlage, but I think a fox in both may be in order. A fix in pyschlage to handle whatever Schlage’s API is throwing at me here, and a fix in ha-Schlage not to raise an unhandled exception when it fails to set up a lock.
I had some offline locks added to my account, and in order to get the integration working for me, I had to remove them from my account, because the integration would fail to initialize those devices, and would raise an exception because of a TypeError. Since updating, however, even though all my locks are all online, I’m still getting that TypeError. I don’t have visibility into what the API response actually is, but it would be great if you could help me troubleshoot.
If one lock having some unexpected exception on initialization could not crash the entire application, but instead just not initialize that lock (and log the error), that would greatly help troubleshooting.
Here are the error details
The text was updated successfully, but these errors were encountered: