{"id":969,"date":"2020-05-14T18:15:31","date_gmt":"2020-05-14T22:15:31","guid":{"rendered":"https:\/\/blog.lufamily.ca\/kang\/?p=969"},"modified":"2020-05-14T18:15:33","modified_gmt":"2020-05-14T22:15:33","slug":"apple-homekit-with-unifi-g3-flex","status":"publish","type":"post","link":"https:\/\/blog.lufamily.ca\/kang\/2020\/05\/14\/apple-homekit-with-unifi-g3-flex\/","title":{"rendered":"Apple HomeKit with Unifi G3 Flex"},"content":{"rendered":"\n<p>Over the past few months, I have been peppering the house with the Unifi G3 Flex security camera. They were very easy to install and since they use PoE, they minimize the wiring as well.<\/p>\n\n\n\n<p>To monitor the cameras, I installed the Unifi Video server software on my Ubuntu Server that is up 7 x 24. All of this hardware components are behind my Unifi Security Gateway firewall.<\/p>\n\n\n\n<p>For whatever reason, I had a thought whether Apple HomeKit can talk to these cameras? With a little Google searching, I came across this <a rel=\"noreferrer noopener\" href=\"https:\/\/community.ui.com\/questions\/UniFi-Protect-with-HomeKit-Setup-Guide\/3c47cc46-560c-4fcc-9eaa-d159a16c77e0?page=1\" target=\"_blank\">article<\/a>. The instructions from the article was a bit outdated, but what peeked my interest was the use of the <a rel=\"noreferrer noopener\" href=\"https:\/\/homebridge.io\" target=\"_blank\">homebridge<\/a> server. I already had homebridge service installed on my Ubuntu server because I use the same technique to have HomeKit talked to my home made garage door opener. After looking through the instructions, it looks like all I need to do is:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Configure Unifi Video to enable RTSP streaming for each of the camera that it is managing;<\/li><li>Download a homebridge camera plugin called <a rel=\"noreferrer noopener\" href=\"https:\/\/www.npmjs.com\/package\/homebridge-camera-ffmpeg\" target=\"_blank\">homebridge-camera-ffmpeg<\/a>;<\/li><li>Configure homebridge to add the cameras;<\/li><li>Add the cameras to the Home App;<\/li><\/ol>\n\n\n\n<p>The first step was extremely simple. First we had to enable RTSP streaming for all cameras managed by Unifi Video.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"926\" src=\"https:\/\/blog.lufamily.ca\/kang\/wp-content\/uploads\/sites\/3\/2020\/05\/EnableRTSP-1024x926.png\" alt=\"\" class=\"wp-image-971\" srcset=\"https:\/\/blog.lufamily.ca\/kang\/wp-content\/uploads\/sites\/3\/2020\/05\/EnableRTSP-1024x926.png 1024w, https:\/\/blog.lufamily.ca\/kang\/wp-content\/uploads\/sites\/3\/2020\/05\/EnableRTSP-300x271.png 300w, https:\/\/blog.lufamily.ca\/kang\/wp-content\/uploads\/sites\/3\/2020\/05\/EnableRTSP-768x694.png 768w, https:\/\/blog.lufamily.ca\/kang\/wp-content\/uploads\/sites\/3\/2020\/05\/EnableRTSP.png 1240w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<p>We then had to select each camera and enable the resolution that we want streamed.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"864\" src=\"https:\/\/blog.lufamily.ca\/kang\/wp-content\/uploads\/sites\/3\/2020\/05\/EnableResolutionPerCamera-1024x864.png\" alt=\"\" class=\"wp-image-972\" srcset=\"https:\/\/blog.lufamily.ca\/kang\/wp-content\/uploads\/sites\/3\/2020\/05\/EnableResolutionPerCamera-1024x864.png 1024w, https:\/\/blog.lufamily.ca\/kang\/wp-content\/uploads\/sites\/3\/2020\/05\/EnableResolutionPerCamera-300x253.png 300w, https:\/\/blog.lufamily.ca\/kang\/wp-content\/uploads\/sites\/3\/2020\/05\/EnableResolutionPerCamera-768x648.png 768w, https:\/\/blog.lufamily.ca\/kang\/wp-content\/uploads\/sites\/3\/2020\/05\/EnableResolutionPerCamera.png 1233w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<p>I tested the RTSP URL on the <a rel=\"noreferrer noopener\" href=\"https:\/\/www.videolan.org\" target=\"_blank\">VLC App<\/a> just to make sure the streaming is working properly.<\/p>\n\n\n\n<p>Installed the plugin with the following command line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm install -g --unsafe-perm homebridge-camera-ffmpeg<\/code><\/pre>\n\n\n\n<p>Add the platform section to the homebridge <code>config.json<\/code> file, which for my server was located in <code>\/var\/homebridge<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"platforms\": &#91;\n{\n    \"platform\": \"Camera-ffmpeg\",\n    \"cameras\": &#91;\n    {\n        \"name\": \"Dining Room\",\n        \"videoConfig\":\n        {\n            \"source\": \"-rtsp_transport http -re -i rtsp:\/\/192.168.168.198:7447\/5e42fef4a8faffa2326b5d38_0\",\n            \"maxStreams\": 4,\n            \"maxWidth\": 1280,\n            \"maxHeight\": 720,\n            \"maxFPS\": 15,\n            \"maxBitrate\": 600,\n            \"mapvideo\": \"0:1\",\n            \"mapaudio\": \"0:0\",\n            \"vcodec\": \"h264\",\n            \"audio\": true,\n            \"packetSize\": 188,\n            \"hflip\": false,\n            \"additionalCommandline\": \"-x264-params intra-refresh=1:bframes=0\",\n            \"debug\": false\n        }\n    },\n    {\n        \"name\": \"Garage\",\n        \"videoConfig\":\n        {\n            \"source\": \"-rtsp_transport http -re -i rtsp:\/\/192.168.168.198:7447\/5e417ffba8faffa2326b5c80_0\",\n            \"maxStreams\": 4,\n            \"maxWidth\": 1280,\n            \"maxHeight\": 720,\n            \"maxFPS\": 15,\n            \"maxBitrate\": 600,\n            \"mapvideo\": \"0:1\",\n            \"mapaudio\": \"0:0\",\n            \"vcodec\": \"h264\",\n            \"audio\": true,\n            \"packetSize\": 188,\n            \"hflip\": false,\n            \"additionalCommandline\": \"-x264-params intra-refresh=1:bframes=0\",\n            \"debug\": false\n        }\n    },\n    {\n        \"name\": \"Great Room\",\n        \"videoConfig\":\n        {\n            \"source\": \"-rtsp_transport http -re -i rtsp:\/\/192.168.168.198:7447\/5e0bacf4a8fa51584a2a94cb_0\",\n            \"maxStreams\": 4,\n            \"maxWidth\": 1280,\n            \"maxHeight\": 720,\n            \"maxFPS\": 15,\n            \"maxBitrate\": 600,\n            \"mapvideo\": \"0:1\",\n            \"mapaudio\": \"0:0\",\n            \"vcodec\": \"h264\",\n            \"audio\": true,\n            \"packetSize\": 188,\n            \"hflip\": false,\n            \"additionalCommandline\": \"-x264-params intra-refresh=1:bframes=0\",\n            \"debug\": false\n        }\n    },\n    {\n        \"name\": \"Kitchen\",\n        \"videoConfig\":\n        {\n            \"source\": \"-rtsp_transport http -re -i rtsp:\/\/192.168.168.198:7447\/5e430638a8faffa2326b5d3a_0\",\n            \"maxStreams\": 4,\n            \"maxWidth\": 1280,\n            \"maxHeight\": 720,\n            \"maxFPS\": 15,\n            \"maxBitrate\": 600,\n            \"mapvideo\": \"0:1\",\n            \"mapaudio\": \"0:0\",\n            \"vcodec\": \"h264\",\n            \"audio\": true,\n            \"packetSize\": 188,\n            \"hflip\": false,\n            \"additionalCommandline\": \"-x264-params intra-refresh=1:bframes=0\",\n            \"debug\": false\n        }\n    }]\n}]<\/code><\/pre>\n\n\n\n<p>I had four cameras installed so you will see four cameras configured within the <code>Camera-ffmpeg<\/code> platform. Note that the entire <code>platforms<\/code> section should be sibling to the <code>accessories<\/code> and <code>bridge<\/code> sections.<\/p>\n\n\n\n<p>I restarted the <code>homebridge<\/code> service with <code>systemctl<\/code>, and you should see messages similar to:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>May 14 15:00:05 avs homebridge&#91;2973]: &#91;2020-5-14 15:00:05] Please add &#91;Dining Room] manually in Home app. Setup Code: 031-45-153\nMay 14 15:00:05 avs homebridge&#91;2973]: &#91;2020-5-14 15:00:05] Please add &#91;Great Room] manually in Home app. Setup Code: 031-45-153\nMay 14 15:00:05 avs homebridge&#91;2973]: &#91;2020-5-14 15:00:05] Please add &#91;Kitchen] manually in Home app. Setup Code: 031-45-153\nMay 14 15:00:05 avs homebridge&#91;2973]: &#91;2020-5-14 15:00:05] Please add &#91;Garage] manually in Home app. Setup Code: 031-45-153<\/code><\/pre>\n\n\n\n<p>You simply open the Home App and add the above camera accessories using the manual process instead of the scan code method.<\/p>\n\n\n\n<p>If everything works, you should see something like this on the Home App. Below is a screen shot taken from the macOS version of the Home App.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"904\" height=\"1024\" src=\"https:\/\/blog.lufamily.ca\/kang\/wp-content\/uploads\/sites\/3\/2020\/05\/Screen-Shot-2020-05-14-at-2020-05-14-3.05.23-PM-904x1024.png\" alt=\"\" class=\"wp-image-973\" srcset=\"https:\/\/blog.lufamily.ca\/kang\/wp-content\/uploads\/sites\/3\/2020\/05\/Screen-Shot-2020-05-14-at-2020-05-14-3.05.23-PM-904x1024.png 904w, https:\/\/blog.lufamily.ca\/kang\/wp-content\/uploads\/sites\/3\/2020\/05\/Screen-Shot-2020-05-14-at-2020-05-14-3.05.23-PM-265x300.png 265w, https:\/\/blog.lufamily.ca\/kang\/wp-content\/uploads\/sites\/3\/2020\/05\/Screen-Shot-2020-05-14-at-2020-05-14-3.05.23-PM-768x870.png 768w, https:\/\/blog.lufamily.ca\/kang\/wp-content\/uploads\/sites\/3\/2020\/05\/Screen-Shot-2020-05-14-at-2020-05-14-3.05.23-PM-1357x1536.png 1357w, https:\/\/blog.lufamily.ca\/kang\/wp-content\/uploads\/sites\/3\/2020\/05\/Screen-Shot-2020-05-14-at-2020-05-14-3.05.23-PM.png 1588w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<p>So it is pretty cool to have something working in your home for several months, and because of a thought, I now have a new capability in the house via Apple&#8217;s HomeKit Home App.<\/p>\n\n\n\n<p>Thank you to the homebridge community and the <a href=\"https:\/\/community.ui.com\/questions\/UniFi-Protect-with-HomeKit-Setup-Guide\/3c47cc46-560c-4fcc-9eaa-d159a16c77e0?page=1\" target=\"_blank\" rel=\"noreferrer noopener\">UniFi Protect with HomeKit &#8211; Setup Guide<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Over the past few months, I have been peppering the house with the Unifi G3 Flex security camera. They were very easy to install and since they use PoE, they minimize the wiring as well. To monitor the cameras, I installed the Unifi Video server software on my Ubuntu Server that is up 7 x &hellip; <a href=\"https:\/\/blog.lufamily.ca\/kang\/2020\/05\/14\/apple-homekit-with-unifi-g3-flex\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Apple HomeKit with Unifi G3 Flex&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":976,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-969","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"jetpack_featured_media_url":"https:\/\/blog.lufamily.ca\/kang\/wp-content\/uploads\/sites\/3\/2020\/05\/title.png","jetpack_shortlink":"https:\/\/wp.me\/p7V6i8-fD","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/blog.lufamily.ca\/kang\/wp-json\/wp\/v2\/posts\/969","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.lufamily.ca\/kang\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.lufamily.ca\/kang\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.lufamily.ca\/kang\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.lufamily.ca\/kang\/wp-json\/wp\/v2\/comments?post=969"}],"version-history":[{"count":4,"href":"https:\/\/blog.lufamily.ca\/kang\/wp-json\/wp\/v2\/posts\/969\/revisions"}],"predecessor-version":[{"id":977,"href":"https:\/\/blog.lufamily.ca\/kang\/wp-json\/wp\/v2\/posts\/969\/revisions\/977"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.lufamily.ca\/kang\/wp-json\/wp\/v2\/media\/976"}],"wp:attachment":[{"href":"https:\/\/blog.lufamily.ca\/kang\/wp-json\/wp\/v2\/media?parent=969"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.lufamily.ca\/kang\/wp-json\/wp\/v2\/categories?post=969"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.lufamily.ca\/kang\/wp-json\/wp\/v2\/tags?post=969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}