Camera support for HomeKit component

hi @xdissent i saw in the PR there is one more change request, are you working on it? sorry i wish i could help and do it myself :frowning:

Can’t wait for this. No idea how to install on Hass.IO though.

Same, here. Really excited to be able to see my camera in my Apple watch, but not sure how to install this in Home Assistant. Is it a custom component? Would it be official?

Thanks, cheers!

Can’t wait for this :smiley:

1 Like

Just installed 0.110b0, added the cameras to my config and it’s worked :heart_eyes:

1 Like

Brilliant, can you share a sample of your Config? :smiley:

1 Like

nice man, can you share please

v0.110 is out… just update and you’ll have the feature

I have Unifi G3 Micro added to Home Assistant with:

camera:
  - platform: generic
    name: Child Room
    still_image_url: http://192.168.1.2:7080/api/2.0/snapshot/camera/XXX?force=true&apiKey=YYY
    stream_source: rtsp://192.168.1.2:7447/XXXX
    verify_ssl: false

I’ve added

ffmpeg:

homekit:
  entity_config:
    camera.child_room:
      support_audio: True
    include_entities:
      - camera.child_room

I get still image in HomeKit but stream doesn’t work. I’ve tried playing with codecs but couldn’t get it to work.
Stream works in HomeAssistant.

Any ideas? Thanks!

Also using a UniFi camera, however added through UniFi Video so not sure if the stream is the same format.

Had to add this to my config to get the streaming working.

  entity_config:
    camera.front_door:
      video_codec: copy

I’ve already tried video_codec: copy but didn’t work for me.
I get: No Response. This camera is not responding. Everytime.

Can you please share your UniFi Video config. Thanks!

Nothing different to the docs https://www.home-assistant.io/integrations/uvc/

camera:
  - platform: uvc
    nvr: uvc_ip
    key: !secret uvc_key
    password: !secret uvc_camera_password

Thanks!
I’ve also tried with UVC integration and it is the same.
Works great in home assistant but can not get the stream in HomeKit.

I’ve tried to remove camera integration from homekit and re-adding it but is still the same :frowning:

logger:
  default: info
  logs:
    homeassistant.components.homekit: debug
    pyhap: debug

You’ll get a lot more information that may be helpful in figuring out why it isn’t working with the debug log turned on in configuration.yaml

Thanks for this!

I get this:

2020-05-20 17:08:00 DEBUG (Thread-9) [pyhap.hap_server] Request GET from address ‘(‘192.168.XXX.XXX’, 53567)’ for path ‘/characteristics?id=abcdef1234.16’.
2020-05-20 17:08:00 DEBUG (Thread-9) [pyhap.accessory_driver] Get chars response: [{‘aid’: abcdef1234, ‘iid’: 16, ‘value’: ‘AQEA’, ‘status’: 0}]
2020-05-20 17:08:00 INFO (Thread-9) [pyhap.hap_server] 192.168.XXX.XXX - “GET /characteristics?id=abcdef1234.16 HTTP/1.1” 207 -
2020-05-20 17:08:00 DEBUG (Thread-9) [pyhap.hap_server] Request PUT from address ‘(‘192.168.XXX.XXX’, 53567)’ for path ‘/characteristics’.
2020-05-20 17:08:00 DEBUG (Thread-9) [pyhap.hap_server] Set characteristics content: {‘characteristics’: [{‘aid’: abcdef1234, ‘iid’: 17, ‘value’: ‘XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY//ZZZZZZZZZZZZZZZZZZZZZZ/AAAAAAAAAAAAA/BBBBBBBBBBBBBBBBBBBBBB==’}]}
2020-05-20 17:08:00 DEBUG (Thread-9) [pyhap.characteristic] client_update_value: SetupEndpoints to XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY//ZZZZZZZZZZZZZZZZZZZZZZ/AAAAAAAAAAAAA/BBBBBBBBBBBBBBBBBBBBBB== from client: (‘192.168.XXX.XXX’, 53567)
2020-05-20 17:08:00 DEBUG (Thread-9) [pyhap.camera] Received endpoint configuration:
session_id: 11111111111-2222-3333-4444-55555555555555
address: 192.168.XXX.XXX
is_ipv6: False
target_video_port: 63829
target_audio_port: 65484
video_crypto_suite: 0
video_srtp: rrrrrrrr+bbbbbbb/ggggg/llllllllll/+ppppppp
audio_crypto_suite: 0
audio_srtp: a/023r09jsdiosdofm923740238isdfosopd
2020-05-20 17:08:00 DEBUG (Thread-9) [pyhap.characteristic] set_value: SetupEndpoints to OAOISDNOAS9038798423jcvknsdio9237lkdsmfksd9237498238snnsndf==
2020-05-20 17:08:00 INFO (Thread-9) [pyhap.hap_server] 192.168.XXX.XXX - “PUT /characteristics HTTP/1.1” 204 -
2020-05-20 17:08:00 DEBUG (Thread-9) [pyhap.hap_server] Request GET from address ‘(‘192.168.XXX.XXX’, 53567)’ for path ‘/characteristics?id=abcdef1234.17’.
2020-05-20 17:08:00 DEBUG (Thread-9) [pyhap.accessory_driver] Get chars response: [{‘aid’: abcdef1234, ‘iid’: 17, ‘value’: ‘OAOISDNOAS9038798423jcvknsdio9237lkdsmfksd9237498238snnsndf==’, ‘status’: 0}]
2020-05-20 17:08:00 INFO (Thread-9) [pyhap.hap_server] 192.168.XXX.XXX - “GET /characteristics?id=abcdef1234.17 HTTP/1.1” 207 -
2020-05-20 17:08:00 DEBUG (Thread-9) [pyhap.hap_server] Request PUT from address ‘(‘192.168.XXX.XXX’, 53567)’ for path ‘/characteristics’.
2020-05-20 17:08:00 DEBUG (Thread-9) [pyhap.hap_server] Set characteristics content: {‘characteristics’: [{‘aid’: abcdef1234, ‘iid’: 15, ‘value’: ‘LKANSFIONASD09wu309jsdfvamsd9fgj0w9j3e4tqmw34tlklkdsfmvm98j9NKJANDFLISDULF9834tz98’}]}
2020-05-20 17:08:00 DEBUG (Thread-9) [pyhap.characteristic] client_update_value: SelectedRTPStreamConfiguration to LKANSFIONASD09wu309jsdfvamsd9fgj0w9j3e4tqmw34tlklkdsfmvm98j9NKJANDFLISDULF9834tz98 from client: (‘192.168.XXX.XXX’, 53567)
2020-05-20 17:08:00 DEBUG (Thread-9) [pyhap.camera] set_selected_stream_config - value - LKANSFIONASD09wu309jsdfvamsd9fgj0w9j3e4tqmw34tlklkdsfmvm98j9NKJANDFLISDULF9834tz98
2020-05-20 17:08:00 DEBUG (Thread-9) [pyhap.camera] Set stream config request: 1
2020-05-20 17:08:00 INFO (Thread-9) [pyhap.hap_server] 192.168.XXX.XXX - “PUT /characteristics HTTP/1.1” 204 -
2020-05-20 17:08:00 DEBUG (SyncWorker_14) [homeassistant.components.homekit.type_cameras] [11111111111-2222-3333-4444-55555555555555] Starting stream with the following parameters: {‘v_profile_id’: b’\x02’, ‘v_level’: b’\x02’, ‘width’: 1280, ‘height’: 720, ‘fps’: 30, ‘v_ssrc’: 9706912, ‘v_payload_type’: b’c’, ‘v_max_bitrate’: 299, ‘v_rtcp_interval’: 0.5, ‘v_max_mtu’: b’b\x05’, ‘a_codec’: b’\x03’, ‘a_comfort_noise’: b’\x00’, ‘a_channel’: 1, ‘a_bitrate’: False, ‘a_sample_rate’: 24, ‘a_packet_time’: 20, ‘a_ssrc’: 7284498, ‘a_payload_type’: b’n’, ‘a_max_bitrate’: 24, ‘a_rtcp_interval’: 5.0, ‘a_comfort_payload_type’: b’\r’, ‘id’: UUID(‘11111111111-2222-3333-4444-55555555555555’), ‘address’: ‘192.168.XXX.XXX’, ‘v_port’: 63829, ‘v_srtp_key’: ‘rrrrrrrr+bbbbbbb/ggggg/llllllllll/+ppppppp’, ‘a_port’: 65484, ‘a_srtp_key’: ‘a/023r09jsdiosdofm923740238isdfosopd’}
2020-05-20 17:08:00 DEBUG (SyncWorker_14) [homeassistant.components.homekit.type_cameras] FFmpeg output settings: -map 0:v:0 -an -c:v copy -tune zerolatency -pix_fmt yuv420p -r 30 -b:v 299k -bufsize 1196k -maxrate 299k -payload_type 99 -ssrc 9706912 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params rrrrrrrr+bbbbbbb/ggggg/llllllllll/+ppppppp srtp://192.168.XXX.XXX:63829?rtcpport=63829&localrtcpport=63829&pkt_size=1316 -map 0:a:0 -vn -c:a copy -ac 1 -ar 24k -b:a 24k -bufsize 96k -payload_type 110 -ssrc 7284498 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params a/023r09jsdiosdofm923740238isdfosopd srtp://192.168.XXX.XXX:65484?rtcpport=65484&localrtcpport=65484&pkt_size=188
2020-05-20 17:08:00 INFO (SyncWorker_14) [homeassistant.components.homekit.type_cameras] [11111111111-2222-3333-4444-55555555555555] Started stream process - PID 281
2020-05-20 17:08:30 DEBUG (Thread-9) [pyhap.hap_server] Request PUT from address ‘(‘192.168.XXX.XXX’, 53567)’ for path ‘/characteristics’.
2020-05-20 17:08:30 DEBUG (Thread-9) [pyhap.hap_server] Set characteristics content: {‘characteristics’: [{‘aid’: abcdef1234, ‘iid’: 15, ‘value’: ‘ARUCAQABENQecbzU20uIiyU5VKqDMgU=’}]}
2020-05-20 17:08:30 DEBUG (Thread-9) [pyhap.characteristic] client_update_value: SelectedRTPStreamConfiguration to ARUCAQABENQecbzU20uIiyU5VKqDMgU= from client: (‘192.168.XXX.XXX’, 53567)
2020-05-20 17:08:30 DEBUG (Thread-9) [pyhap.camera] set_selected_stream_config - value - ARUCAQABENQecbzU20uIiyU5VKqDMgU=
2020-05-20 17:08:30 DEBUG (Thread-9) [pyhap.camera] Set stream config request: 0
2020-05-20 17:08:30 INFO (Thread-9) [pyhap.hap_server] 192.168.XXX.XXX - “PUT /characteristics HTTP/1.1” 204 -
2020-05-20 17:08:30 INFO (SyncWorker_14) [homeassistant.components.homekit.type_cameras] [11111111111-2222-3333-4444-55555555555555] close stream.

It seem it starts streaming but after 30 seconds it closes it, and I get No Response message on my iPhone.

I have the same issue. I removed my config and tried onvif and still not working. on hassio works and on homekit doesn’t
I get only the picture which refreshes every 10 seconds

Failed to get stream source - this could be a transient error or your camera might not be compatible with HomeKit yet
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/homekit/type_cameras.py", line 198, in _async_get_stream_source
    stream_source = await camera.stream_source()
  File "/usr/src/homeassistant/homeassistant/components/onvif/camera.py", line 110, in stream_source
    uri_no_auth = await self.device.async_get_stream_uri(self.profile)
  File "/usr/src/homeassistant/homeassistant/components/onvif/device.py", line 309, in async_get_stream_uri
    result = await media_service.GetStreamUri(req)
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/bindings.py", line 13, in send
    options["address"], envelope, http_headers
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/transport.py", line 107, in post_xml
    response = await self.post(address, message, headers)
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/transport.py", line 95, in post
    proxy=self.proxy,
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 426, in _request
    with timer:
  File "/usr/local/lib/python3.7/site-packages/aiohttp/helpers.py", line 569, in __enter__
    raise RuntimeError('Timeout context manager should be used '
RuntimeError: Timeout context manager should be used inside a task

Please see

You’ll need to configure the stream_source manually as the camera is timing out when asking for it HomeKit Bridge - Home Assistant

example? I have to also set ffmpeg -i … or just rtsp link? any ideas?

Just the rtsp link