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
530
Better use of SwiftUI
tattn
0
390
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.7k
iOS 14の位置情報系アップデート
tattn
0
22k
Other Decks in Technology
See All in Technology
The future we create with our own MVV
matsukurou
0
940
型情報を用いたLintでコード品質を向上させる
sansantech
PRO
2
210
2024年にチャレンジしたことを振り返るぞ
mitchan
0
170
20241228 - 成為最強魔法使!AI 實時生成比賽的策略 @ 2024 SD AI 年會
dpys
0
330
クレカ・銀行連携機能における “状態”との向き合い方 / SmartBank Engineer LT Event
smartbank
3
130
pg_bigmをRustで実装する(第50回PostgreSQLアンカンファレンス@オンライン 発表資料)
shinyakato_
0
150
Fabric 移行時の躓きポイントと対応策
ohata_ds
1
120
エンジニアリングマネージャー視点での、自律的なスケーリングを実現するFASTという選択肢 / RSGT2025
yoshikiiida
4
2.1k
ヤプリQA課題の見える化
gu3
0
140
事業貢献を考えるための技術改善の目標設計と改善実績 / Targeted design of technical improvements to consider business contribution and improvement performance
oomatomo
0
250
20241220_S3 tablesの使い方を検証してみた
handy
4
850
OPENLOGI Company Profile
hr01
0
57k
Featured
See All Featured
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Building Better People: How to give real-time feedback that sticks.
wjessup
366
19k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.3k
Docker and Python
trallard
43
3.2k
Writing Fast Ruby
sferik
628
61k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3.1k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Building Your Own Lightsaber
phodgson
104
6.1k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
1
150
Become a Pro
speakerdeck
PRO
26
5.1k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
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ͷ͜ͱΛΔͨΊʹ ۙʹͦͷٕज़Λײ͡Δͷ͕खͬऔΓૣ͍Ͱ͢ʂ ←ֶशϦϞίϯϢχοτ ɹ͓͢͢ΊͰ͢ʂ