You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NameError: name 'kTLVError_Unavailable' is not defined #16
Trying to pair a Leviton DH6HD switch, it give the error:
"Traceback (most recent call last):
File "/usr/lib/python3.5/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/root/.local/lib/python3.5/site-packages/homekit/pair.py", line 47, in
pairing = perform_pair_setup(conn, args.pin, iOSPairingId)
File "/root/.local/lib/python3.5/site-packages/homekit/protocol.py", line 77, in perform_pair_setup
error_handler(response_tlv[TLV.kTLVType_Error], "step 3")
File "/root/.local/lib/python3.5/site-packages/homekit/protocol.py", line 39, in error_handler
elif error == kTLVError_Unavailable:
NameError: name 'kTLVError_Unavailable' is not defined"
It seems like it's having a hard time decoding the Salt from the TLV packet. Here's the packet it's receiving:
That did fix the error about the error message :) but not the underlying problem. Now I get:
Traceback (most recent call last):
File "/usr/lib/python3.5/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/root/.local/lib/python3.5/site-packages/homekit/pair.py", line 47, in
pairing = perform_pair_setup(conn, args.pin, iOSPairingId)
File "/root/.local/lib/python3.5/site-packages/homekit/protocol.py", line 77, in perform_pair_setup
error_handler(response_tlv[TLV.kTLVType_Error], "step 3")
File "/root/.local/lib/python3.5/site-packages/homekit/protocol.py", line 44, in error_handler
raise homekit.exception.InvalidError(stage)
homekit.exception.InvalidError: step 3
I take back what I said in the beginning, there seems to be just a general issue in reading the TLV altogether. I know just enough about programing to be dangerous, so with that said I added this the line to end of the Step 1 in protocol.py:
and the program outputs this: "b'\x06\x01\x02\x07\x01\x01'" which is not at all what the packet capture (attached) shows the response being.... however looking more closely at the packet capture I see the crazy little Leviton switch is sending 2 HTTP headers, the first one has the error code in it your program is responding to and the second has the expected response.
this is about as far as my knowledge can take me. I wrote a simple little bash script that sends:
POST /pair-setup HTTP/1.1
Host: 192.168.42.70
Content-Length: 6
Content-Type: application/pairing+tlv8
\x00\x01\x01\x06\x01\x01
and the switch sends back just 1 HTTP header as expected (with the stage 2 data in it), so I would guess there's something about the way Python is sending data that is confusing the switch, but I'm not sure where to start looking at that. My only guess looking at the packet capture is that Python is fragmenting the HTTP request into 2 packets and the http server running on this light switch is doing a bad job of reassembly.
One other note, I'm running Python 3.5.3 on a Raspberry Pi. This is the newest version of python that I'm offered through apt. Not sure if their might be an HTTP fix I'm missing.
EDIT: I see looking at the other open issue (#12), this is in-fact a problem with the interaction between Python breaking up the header and body into 2 packets and the Leviton switch. I'm new to Git but it seems that this issue is better described in #12 so I'd say you can close this. Sorry for the confusion.
Activity
jlusiardi commentedon Apr 29, 2018
Hi,
Can you try to apply this patch?
should fix it.
Regards
Joachim
fix for issue #16
nickpl456 commentedon Apr 30, 2018
Thank you for the quick reply!
That did fix the error about the error message :) but not the underlying problem. Now I get:
Traceback (most recent call last):
File "/usr/lib/python3.5/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/root/.local/lib/python3.5/site-packages/homekit/pair.py", line 47, in
pairing = perform_pair_setup(conn, args.pin, iOSPairingId)
File "/root/.local/lib/python3.5/site-packages/homekit/protocol.py", line 77, in perform_pair_setup
error_handler(response_tlv[TLV.kTLVType_Error], "step 3")
File "/root/.local/lib/python3.5/site-packages/homekit/protocol.py", line 44, in error_handler
raise homekit.exception.InvalidError(stage)
homekit.exception.InvalidError: step 3
I take back what I said in the beginning, there seems to be just a general issue in reading the TLV altogether. I know just enough about programing to be dangerous, so with that said I added this the line to end of the Step 1 in protocol.py:
and the program outputs this: "b'\x06\x01\x02\x07\x01\x01'" which is not at all what the packet capture (attached) shows the response being.... however looking more closely at the packet capture I see the crazy little Leviton switch is sending 2 HTTP headers, the first one has the error code in it your program is responding to and the second has the expected response.
this is about as far as my knowledge can take me. I wrote a simple little bash script that sends:
and the switch sends back just 1 HTTP header as expected (with the stage 2 data in it), so I would guess there's something about the way Python is sending data that is confusing the switch, but I'm not sure where to start looking at that. My only guess looking at the packet capture is that Python is fragmenting the HTTP request into 2 packets and the http server running on this light switch is doing a bad job of reassembly.
One other note, I'm running Python 3.5.3 on a Raspberry Pi. This is the newest version of python that I'm offered through apt. Not sure if their might be an HTTP fix I'm missing.
Thanks again!
pcap.zip
EDIT: I see looking at the other open issue (#12), this is in-fact a problem with the interaction between Python breaking up the header and body into 2 packets and the Leviton switch. I'm new to Git but it seems that this issue is better described in #12 so I'd say you can close this. Sorry for the confusion.
jlusiardi commentedon Apr 30, 2018
no problem with the confusion. Seems I have to really look at it. Guessing what @mjg59 monkey patched there...
fixes the 2 packets issue (#12 and #16)