-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
homekit_controller: unable to complete pair_setup with LG TV #25960
Comments
Thanks for tagging me @niemyjski Just a heads up - even if we get pairing to work we don't support the TV accessory type yet, although I can look into if if you want to do some backwards and forwards trying it out for me. I think the timeout is from one of your other accessories so i'm ignoring that here. It's normal behaviour for Homekit devices with screens to change the pairing code every time a controller (be it iPhone or Home Assistant) sends the M1 request to the pairing process. The act of showing the "enter pairing code" screen is what triggers the M1 request, so reloading that page or clicking on the form and back onto it will cause the code to change. Step M3 is when we send a SRP Verify Request to the TV using the pairing code you entered. M4 is the response from the accessory. It should contain a kTLVType_State and either a kTLVType_Proof or a kTLVType_Error. An empty response is not a documented case. So we'll have to reverse engineer what the trigger for that is. It's clearly not an invalid pairing code format, as that is checked on our side before talking to the TV. The best next step is to try pairing with the underlying library in debug mode. There are some notes on that here. As your device has a screen, don't specify |
I seemed to have one timeout per one of these calls roughly around the same time so I decided to include it. I'd be more than happy to do any testing :), might be this weekend before I can try out the above. On a separate request, it would be sooo nice if the input box automatically formatted the input to the correct homekit format. |
Doesn't look like I was able to run discovery jlusiardi/homekit_python#158 |
I was able to finally do discovery after they supplied a patch but I don't know what to put for the arguments |
There is a manual "test devices" workflow you can go through to try all the API's - here's an example for a Koogeek device. |
I've updated the linked issue. |
It seems problems with the |
They are completely different issues affecting different integrations. This ticket is about the homekit_controller integration, the other is about the homekit one. One lets you control devices with the homekit logo (without any Apple phones or tablets involved), the other makes your home assistant look like a homekit accessory to your Apple phones, tablets, etc. |
I see. The titles make it sound like they're similar problems. Thanks for pointing me in the right direction! It doesn't help that https://www.home-assistant.io/components/homekit/ versus https://www.home-assistant.io/components/homekit_controller/ are super confusing too. At least for end users not intimately familiar with Home Assistant — which includes me :) It'd be better if one were called |
Agreed, it's a shame neither of us were around when they were added to suggest that! That said, controlller is what Apple officially calls the consumer so I think it could be worse. Renaming would be hard at this point (too many users familiar with old names, and their configs would break if it changed), and we've tried to improve the docs. |
Is there anything else I can do to help out with this issue? |
Not on this issue no - let's discuss on the upstream issue over here. |
Hey, I'm having the same issue I think trying to pair an LG C9 too, happy to help if I can.
|
For anyone following this issue - the current thinking is that our homekit library currently only supports pairing devices with hardware crypto chips provided by Apple. In the case of LG TV's that got HomeKit as a software update this seems to be clearly the case - and indeed pairing fails. There is another pairing mode we can use, and it only needs a single line code change to test it out. Indeed it's a single character change. As we understand it it just disables "attestation" during the pairing key exchange but is still otherwise secure. You can try editing homekit/protocol/tlv.py in your virtualenv packages directory. There should be a line that looks like this:
Change the \x01 to \x00 and try and pair. This fixes things for some devices. What we don't know with any certainty yet is when to send a |
That did the trick for pairing. I have a device now in HA however there are no entities. |
@dmulcahey cheers - can you post the output of That's what i'd expected btw - theres absolutely no mapping from HK to HA for the TV type yet - priority has been events for a while, and is now stateless button devices. Posting your |
do I have to run this from my prod env? Just ran it on my dev machine and got a key error:
Here is the entity map stuff:
|
Ah its a TV, and the current release of the homekit library doesn't know that key 31 is a TV. As a safe and quick work around maybe something like editing If i cobble together a basic PR to for TV support would you be able to test it easily? |
Hey,
I can test TV stuff if needed, happy to help
…On Sun 1 Mar 2020, 19:22 Jc2k, ***@***.***> wrote:
Ah its a TV, and the current release of the homekit library doesn't know
that key 31 is a TV. As a safe and quick work around maybe something like
editing
/Users/davidmulcahey/development/home-assistant/lib/python3.7/site-packages/homekit/model/categories.py.
Instead of the raise on line 94, make it return something - maybe just
"unknown".
If i cobble together a basic PR to for TV support would you be able to
test it easily?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#25960>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGVHT6MGYR7FKXCFITQFIDRFKYVZANCNFSM4IL44QAQ>
.
|
Hey @Ulrar - thanks for offering. I'm specifically looking for someone with a home-assistant dev environment (or experience running one) - how does that sound? |
I have a regular home assistant, but manually installed, no docker or
anything so I can pull specific branches to test them out.
I can setup another instance just for the tests though, might be easier
…On Sun 1 Mar 2020, 19:40 Jc2k, ***@***.***> wrote:
Hey @Ulrar <https://github.com/Ulrar> - thanks for offering. I'm
specifically looking for someone with a home-assistant dev environment (or
experience running one) - how does that sound?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#25960>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGVHT2VINLOBNEGJIZ3VP3RFK22VANCNFSM4IL44QAQ>
.
|
Yep, I run dev constantly with a venv |
OK - first PR is up. Just to prove it works, should create a So if you can verify that with this PR you can see your TV appear in HA, that you can see its current state (playing/paused/idle) and that you can play/pause. This is off Supporting channel switching and volume control should be do-able, but are much more complicated that unusual as they involve "linked services". Up till now there has been a 1-entity-1-service relationship, and this assumption will need a bit of re-factoring around. |
So, I get the media player entity. None of the buttons do anything and I don't see much in the logs. I get events: powering off the TV I see this in the logs:
I don't notice anything in the logs after I power the set back on and play calls after that fail with:
Let me know what I can do to help here. |
@dmulcahey Cheers. Lot to think about here. The power button - i'm surprised it appears in the UI, its definitely not wired up to anything. What other buttons were there apart from play? In terms of debugging why the state is This is called once a minute and will have the raw data from the poll request, including errors. We can verify that all the characteristics i expect are being polled and that the poll is working. The other thing to look for is the log message:
and a corresponding "Finished". These will only be visible at debug level, though. I'm sure i'm wrong but also I'm hoping that the play and pause events are "working" but that they just don't do anything on the screen of the TV you were on. The best way to test this is to add some logging here: If That you see a Connection lost message is promising - i think you would have seen that sooner if the connection was so badly broken that the TV dropped it. So whatever is happening is a layer up. But it does look like I need to test error recovery a bit better. I have only been testing what happens when a device is missing at start up time. How long was the TV off for? How long did you wait after powering it on to press play? (Even if it's not this case, it's made me think that the re-connect has an exponential back off but is capped at a minute, so i guess if you turned on the TV and the re-connect hadn't yet reconnected then we'd see some weird unhandled error). |
dev...Jc2k:homekit_controller_channels has a crude pass at channel switching. Testing against HAP-NodeJS atm and can see the 3 input sources that test accessory has (and switch between them). Code is a bit janky, need to do some refactoring to better support "linked services" before i can submit a PR for this one. |
Here are the logs from pairing. It appears to lose its connection immediately:
I added logging there as well. It doesn't log and the log lines you reference aren't there either. Assuming this is related to the lost connection referenced above?
When I first turn off the tv:
This is weird as I don't see anything related to a new connection being established after the original connection lost message above. Is HCK connecting a bunch of times to the TV? I waited about 5 minutes after turning the TV back on and I don't see anything about a new connection to the TV being established in the logs and now the play button does this:
Let me know what else I can do to help. EDIT: Interesting... when shutting down my dev environment I got these (I had to force kill the env):
maybe something is screwy in the "reconnecter"? |
Losing connection after pairing is normal. It closes an insecure channel and then opens a secure one. What is a bit screwy here though is that the logging is asymmetric - i'm not logging new connections at all.
I'm unsure about this. Later on we see seemingl see the put call succeed. Let's come back to this. Oh, maybe if you wait for the 2nd poll you'll see something?
Empty Reconnection is definitely screwy and have been able to recreate most of what you are seeing. Right now i suggest restarting HA before performing any tests, i'll figure out whats going on over here and then push a PR. I managed to do the refactoring i wanted so the PR with channel switching support should go up today (need to finish the tests) then we can test with that. |
Cool. I see the PR. Are you on discord at all? |
I'm going to close this now, all the code should be queued up to go into 0.107.0 @dmulcahey has an LG TV paired and can switch input sources. Play/pause also works (but it is context sensitive). The LG implementation doesn't report much state (like playing vs paused etc). Volume support will be added later. |
Hi,
I can confirm, with 107 I can play/pause (at least in the apps I tried),
change source (only HDMI, live TV and airplay, it's not showing apps like
Netflix) and other services seem to either do nothing or complain about a
missing key.
The media player card has the name of the TV and that's it, no info about
what is playing or any status.
Still, great start, thanks for the work !
…On Wed 11 Mar 2020, 21:14 Jc2k, ***@***.***> wrote:
Closed #25960 <#25960>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#25960 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGVHT242KZPFUDGNIPMPATRG75LPANCNFSM4IL44QAQ>
.
|
Thanks! Unfortunately we probably won't get to see more than that from what I can see. The "current state" characteristic is limited to "playing", "paused" and "stopped" and not every manufacturer implements it :-( I hope to come back and expose the other remote buttons at some point, and volume control. |
Home Assistant release with the issue:
0.97.2
Operating environment (Hass.io/Docker/Windows/etc.):
hassio stable x64
Component/platform:
homekit_controller
Description of problem:
My tv got the update for homekit support last week and I decided to finally try adding it to homekit but it fails to set up which then the tv generates a completely new pairing code. I finally got time to try and add it and keep the logs open.
Traceback (if applicable):
Additional information:
cc @Jc2k
The text was updated successfully, but these errors were encountered: