Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
日曜HackでHomeKitと戯れた話
Search
Tatsuya Tanaka
October 30, 2016
Technology
1
2k
日曜HackでHomeKitと戯れた話
API非公開の学習リモコンをHomeKit対応させた話と、HomeKitについて。
@iOS_LT #23
Tatsuya Tanaka
October 30, 2016
Tweet
Share
More Decks by Tatsuya Tanaka
See All by Tatsuya Tanaka
iPhoneのセンサー情報をmacOSアプリでリアルタイム活用するための技術
tattn
1
540
Better use of SwiftUI
tattn
0
410
Swift Concurrencyによる安全で快適な非同期処理
tattn
2
1.2k
iOSアプリの技術選択2022
tattn
7
3.8k
Widget Suggestions 対応と ヤフーの新OS対応
tattn
1
1.2k
WidgetKitで良い体験を作るには / Good experience with WidgetKit
tattn
2
1.5k
既存アプリにSwiftUIをどう組み込んでいくか
tattn
8
2.3k
iOS 14からのアプリ内課金
tattn
5
2.8k
iOS 14の位置情報系アップデート
tattn
0
22k
Other Decks in Technology
See All in Technology
プロダクトエンジニア構想を立ち上げ、プロダクト志向な組織への成長を続けている話 / grow into a product-oriented organization
hiro_torii
1
310
ソフトウェアエンジニアと仕事するときに知っておいたほうが良いこと / Key points for working with software engineers
pinkumohikan
1
130
2/18/25: Java meets AI: Build LLM-Powered Apps with LangChain4j
edeandrea
PRO
0
150
明日からできる!技術的負債の返済を加速するための実践ガイド~『ホットペッパービューティー』の事例をもとに~
recruitengineers
PRO
3
550
ビジネスモデリング道場 目的と背景
masuda220
PRO
9
680
レビューを増やしつつ 高評価維持するテクニック
tsuzuki817
2
870
コンテナサプライチェーンセキュリティ
kyohmizu
1
120
データ資産をシームレスに伝達するためのイベント駆動型アーキテクチャ
kakehashi
PRO
2
630
PHPで印刷所に入稿できる名札データを作る / Generating Print-Ready Name Tag Data with PHP
tomzoh
0
180
次世代KYC活動報告 / 20250219-BizDay17-KYC-nextgen
oidfj
0
430
EDRの検知の仕組みと検知回避について
chayakonanaika
8
3.6k
Goで作って学ぶWebSocket
ryuichi1208
3
2.4k
Featured
See All Featured
Making Projects Easy
brettharned
116
6k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.2k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
366
25k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7k
Visualization
eitanlees
146
15k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
Java REST API Framework Comparison - PWX 2021
mraible
28
8.4k
Raft: Consensus for Rubyists
vanstee
137
6.8k
Building an army of robots
kneath
303
45k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.3k
It's Worth the Effort
3n
184
28k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7.1k
Transcript
ాத ୡ (tattn) Github: https://github.com/tattn Qiita: http://qiita.com/tattn Twitter: https://twitter.com/tanakasan2525 ༵HackͰ
HomeKitͱٔΕͨ
HomeKit iOS 8 ͔Β͑ΔΑ͏ʹͳͬͨ iOSͱՈి Λܨ͙Ս͚ڮ
ઌिͷ༵ʹ͜Ε͕ಧ͖·ͨ͠ (ܹ҆ʂ2500ԁ) ֶशϦϞίϯϢχοτ
͔͠͠ɻɻɻ ͱ͍ͬͯ҆ͷͰ͕͢ APIެ։͞Εͯͳ͍ HomeKitʹରԠͯ͠ͳ͍
Demo
ಈըஏ͔͍ͣ͠ͷͰΧοτ
γεςϜߏ • RM mini 3 (ࠇ౾) • Node.js • homebridge
• iPhone 6s (iOS10) ࠇ౾ HomeKit API UDP ֎ઢ TV
ࠇ౾Λૢ࡞͢ΔͨΊʹ WireSharkͰެࣜΞϓϦͱࠇ౾ͷ௨৴Λݟͯɺ Node.jsͰͦΕΛਅࣅΔ͜ͱͰૢ࡞Մೳʹɻɻɻ
ࠇ౾Λૢ࡞͢ΔͨΊʹ ͪͳΈʹɺQUIC (ΫΠοΫ) ͱ͍͏ Google͕։ൃͨ͠৽͠ΊͷϓϩτίϧΛར༻͠ɺ UDPͷίωΫγϣϯΛு໋ͬͯྩΛग़ͯ͠·ͨ͠ɻɻɻʂ
Homebridge Node.jsͰHomeKitAPIͷΤϛϡϨʔτ͕Ͱ͖Δπʔϧ homebridge-***ͱ͍͏npmύοέʔδΛ࡞֦ͬͯு͢ΔΈɻ ࠇ౾༻ͷύοέʔδΛ࡞ɻ https://github.com/nfarina/homebridge https://github.com/tattn/homebridge-rm-mini3
iOS10ͰೖͬͨHomeΞϓϦ
ίʔυΛಡΈऔͬͯՈిΛઃఆ
͜Ε͚ͩͰɺHomeΞϓϦ & Siri ͔ΒϦϞίϯૢ࡞͕ՄೳʹͳΓ·ͨ͠ɻ
ୈࡾͷϖʔδ͕૿͑·ͨ͠
ͦ͏͍͑iOSͷLTͰͨ͠ɻɻɻ HomeKitͷAPIΛͬͯΈ·ͨ͠ https://github.com/tattn/HomeKit-Playground
HomeKitΛ͏ͨΊʹ CapabilityͰHomeKitΛOnʹ͢Δ
HomeKitͷઃఆͷΞΫηε plistʹ NSHomeKitUsageDescription ͷՃ͕ඞཁ iOS10͔ΒϢʔβʔσʔλͷΞΫηεͷ తͷهड़͕ඞਢʹ
ͱΓ͋͑ͣͷUI AppleͷΨΠυϥΠϯʹେମԊͬͨ ૉΒ͍͠UIΛ࡞ • ߇͑ΊͰ͋Δ͜ͱ • ໌ྎͰ͋Δ͜ͱ • Ԟߦ͖Λ༩͑Δ͜ͱ
Demo
ಈըஏ͔͍ͣ͠ͷͰΧοτ
HomeKit https://developer.apple.com/jp/documentation/HomeKitDeveloperGuide.pdf
Accessoryͷத (ྫ) https://developer.apple.com/jp/documentation/HomeKitDeveloperGuide.pdf TV Accessory Service • TV • εΠον
Characteristic • ిݯ • ϛϡʔτ • …
Primary Homeͷऔಘ // 管理クラスの取得 let homeManager = HMHomeManager() homeManager.delegate =
self // MARK: - HMHomeManagerDelegate func homeManagerDidUpdateHomes(_ manager: HMHomeManager) { // Primary Homeの取得 let home = manager.primaryHome } ↓͜ΕΛऔಘ
Room / Accessoryͷऔಘ let home = manager.primaryHome let room =
home?.rooms[0] let accessory = room?.accessories[0] // これでも可 let accessory = home?.accessories[0]
Characteristicͷऔಘ for service in accessory.services { switch service.serviceType { case
HMServiceTypeSwitch: for chara in service.characteristics { switch chara.characteristicType { case HMCharacteristicTypePowerState: // 電源スイッチの取得 chara default: () } } default: () } } Accessory Service • TV • Ϙλϯ Characteristic • ిݯ • ϛϡʔτ • …
ͷऔಘ Accessory Service • TV • Ϙλϯ Characteristic switch chara.characteristicType
{ case HMCharacteristicTypePowerState: // 値の取得 chara.readValue { error in let isOn = chara.value as? Bool } // 値の設定 chara.writeValue(true) { error in print(error) } default: () } • ిݯ • ϛϡʔτ • …
Έͳ͞Μͥͻ࡞Γ·͠ΐ͏ʂ APIͷ͜ͱΛΔͨΊʹ ۙʹͦͷٕज़Λײ͡Δͷ͕खͬऔΓૣ͍Ͱ͢ʂ ←ֶशϦϞίϯϢχοτ ɹ͓͢͢ΊͰ͢ʂ