Add homekit camera support#32527
Conversation
|
@xdissent Thanks for doing this! There isn't a maintainer for this integration at the moment but i'll try to stand in a bit as I know the HomeKit protocol from maintaining Can you explain whats going on with |
|
@Jc2k It's weird multiple inheritance! I tried really hard to figure out how to subclass both pyhap camera and ha accessory, but the way the different constructors take their args made it impossible. It's been quite a while since I've been deep into python though, so maybe there is a way. |
|
@frenck Added docs: home-assistant/home-assistant.io#12303 Did I do that right? |
|
This feature is not going to work for a large part of our userbase: Home Assistant & Home Assistant Core on Docker users. This is because it relies on an audio feature, which is not compiled in FFmpeg by default. FFmpeg compile options in our Docker images:
Therefore, I'm afraid this will cause issues for people, since it implies to work, but doesn't. |
|
There are 2 possible audio codecs that can be offered to the iDevice AIUI. @frenck from your point of view, if this did some negotiation on our side and only offered aac if it was actually available would it be OK? Are there any utils in the ffmpeg integration for this? A wrapper around |
I think I see what you mean here. But there's quite a bit of code duplication, so I think we need to work with upstream here and find a way to avoid that. |
|
Managed to get the inheritance to work here: Jc2k@eff15d7 - this assumes the 2 changes are merged upstream (change to make microphone service optional and change to set |
|
Good idea. Ideally we'd do stuff like that automatically rather than needing the user to know. Ideally the ffmpeg infastructure could autodetect this for us. (My rule of thumb is adding more config options are a pain in the butt for QA and a pain in the butt for user support, and |
|
@xdissent
|
|
@Jc2k, @xdissent sorry for pushing you guys but are you planning to finalize this PR? I am really interested in having this feature in HASS, so I can finally deprecate Homebridge. :) |
|
@stickpin i'm only here with my reviewer hat on, and only contributed Jc2k@eff15d7 so that I could be a stickler about insisting on reducing code duplication :=) i plan to stick aroud and keep reviewing and nitting but thats about it (my priority this cycle is stablising If we are starting from my last commit then I would maybe start with the changes that need pushing upstream:
They need doing (and a new tag cutting) but don't step on this PR too much. That gives @xdissent time to come back and comment. It's only been 4 days, so seems fair. |
|
@Jc2k thanks so much for figuring out the inheritance thing. That will really clean things up. As you noted, a good deal needs to go upstream and we're kinda in a holding pattern until that gets released. @stickpin if you wanted to help with that effort or any other improvements then knock yourself out! I should have time in the next couple of days tho. Regarding ffmpeg options - I do feel like we probably should have some kind of escape hatch in the configuration that lets you fully control the ffmpeg command. But because the parameters of the stream are decided by the client, I'm not sure what that should look like. Using I'm also wondering if we're not duplicating some of the effort behind the |
|
tested it with CamON Live Streaming android app (rtsp), worked perfectly! |
|
Anyone started looking into upstreaming the bits I called out yet? |
|
@Jc2k I just sent a pr. I didn't make the microphone optional because I took a look at the spec and it's required. |
bdraco
left a comment
There was a problem hiding this comment.
LGTM, but need another reviewer
Jc2k
left a comment
There was a problem hiding this comment.
LGTM, too. Pleased with how the HK bits have turned out. type_cameras.py only 210 lines!
@stickpin I don’t have a camera that supports that so I can’t test but if you want to do a follow up PR after this merges, I’m happy to review it. Any chance you can take the latest version of this branch for a spin? |
|
Ok to merge if @xdissent confirms everything is working as expected. |
|
Works OK for me with 2 Foscam cameras. Thanks to all of you for the work! |
@bdraco working on it. will do push soon... :) |
|
@bdraco, @xdissent, @Jc2k I've added video codec support and submitted PR here: xdissent#1 Everything works as it should with my YI Hack cameras. I'm not sure how to commit to this PR. :) |
Please send a new PR once this one merges |
|
It looks like Another issue I see is reconfigure_stream doesn't stop/restart a running stream, it just tries to run another ffmpeg process. Flipping the phone from portrait to landscape is an easy way to force reconfigure_stream for testing. The asyncio stuff is definitely working again now though. Looks real close! |
It looks like
I'll take a look at what pyhap is doing under the hood. We can always revert back to the stub what was there before if we need to.
|
|
I couldn't replicate the issue with switching phone orientation but it didn't break anything for me to disable reconfigure stream. @xdissent All working with the last change? |
|
/AzurePipelines Run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Ugh, sorry, I think we want zerolatency back in there... it does seem to effect some cams (stuttering without it) and it doesn't exactly fix my trouble cams. However, just using the copy codec does fix my trouble cams. So, I'll probably just go that route with those whenever that's an option. I'm not getting multiple ffmpeg processes anymore so looks like reconfigure_stream stuff is fixed and everything else looks good! |
|
Local tests pass, retested ok from homekit. Definitely works better with |
|
I'll merge when the CI passes (unless it doesn't), and then @stickpin you should be good to send in that PR. Hopefully with a test 😄 ❓ |


Proposed change
Add camera support to the HomeKit integration. Based on camera accessory from pyhap.
Type of change
Example entry for
configuration.yaml:Additional information
Checklist
black --fast homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all..coveragerc.The integration reached or maintains the following Integration Quality Scale: