What's new in HomeKitとNode-REDでカンタンHomeKitデバイスをDIY!

Db5cf21a75ebe2484b95ea9dec5f573b?s=47 Shingo Tamaki
July 09, 2017
1.3k

What's new in HomeKitとNode-REDでカンタンHomeKitデバイスをDIY!

WWDC2017のアップデートとNode-REDを使った簡単なプロトタイプについて

Db5cf21a75ebe2484b95ea9dec5f573b?s=128

Shingo Tamaki

July 09, 2017
Tweet

Transcript

  1. What's new in HomeKit

  2. ࣗݾ঺հ

  3. ࣗݾ঺հ ۄ৓৴ޛ iOS Engineer! ޷͖ͳframework͸HomeKitͰ͢ झຯ" ిࢠ޻࡞⚡ ےτϨ$ ΨδΣοτ%

  4. HomeKitͱ͸ʁ

  5. HomeKitͱ͸ʁ HomeKit͸ɺAppleͷHomeKit Accessory ProtocolʹରԠͨ͠ ϗʔϜΦʔτϝʔγϣϯػثͱ௨৴͠ɺ͜ΕΛ੍ޚ͢ΔͨΊͷ ϑϨʔϜϫʔΫͰ͢ɻ

  6. HomeKitͷػೳ • ϗʔϜ/ϧʔϜ؅ཧ • ΞΫηαϦ؅ཧɾૢ࡞ • Ϣʔβ؅ཧ • γʔϯ •

    τϦΨ • DBڞ༗
  7. ϗʔϜͷϨΠΞ΢τ HomeKitͰ͸Home/Room/Accessory/ServiceʹΑͬͯߏ੒͞Ε ͍ͯ·͢ɻ

  8. γʔϯ

  9. γʔϯ γʔϯͱ͸ଟ਺ͷΞΫηαϦૢ࡞ΛҰׅͰߦ͏ҝͷఆٛͰ͢ɻ ʮ͓͸Α͏ʯ΍ʮ͍ͨͩ·ʯͳͲͷ೔ৗγʔϯΛΠϝʔδͯ͠ ΋Β͑Ε͹ྑ͍ͱࢥ͍·͢ɻ

  10. τϦΨ

  11. τϦΨ HomeKitʹ͸ಛఆͷૢ࡞ΛΦʔτϝʔγϣϯԽ͢ΔͨΊͷτϦ Ψ͕༻ҙ͞Ε͍ͯ·͢ɻ • Ґஔ৘ใ • ࣌ࠁ • ΞΫηαϦͷঢ়ଶมԽ

  12. Φʔτϝʔγϣϯ

  13. Φʔτϝʔγϣϯ γʔϯͱτϦΨͷ૊Έ߹ΘͤʹΑͬͯΞΫηαϦͷૢ࡞Λࣗಈ Խ͢Δࣄ͕Ͱ͖·͢ɻ

  14. HomeApp ϗʔϜ/ϧʔϜ΁ͷΞΫηαϦ؅ཧͷૢ࡞͸iOS10Ͱొ৔ͨ͠ HomeΞϓϦͰ؆୯ʹߦ͏ࣄ͕Ͱ͖·͢ɻ ※ HomeKit frameworkΛ࢖ͬͨαʔυύʔςΟΞϓϦͰ΋ߦ͑ ·͢ɻ

  15. DBڞ༗

  16. DBڞ༗ HomeKit͸ͦͷ৘ใΛϗʔϜ͝ͱʹDBͱ͓ͯ࣋ͬͯ͠Γɺ୺຤ ͕iCloudܦ༝Ͱผ୺຤ʹDBΛڞ༗ɾมߋ؂ࢹΛߦͳ͍ͬͯ· ͢ɻ

  17. ͜͜·Ͱ͕͜Ε·ͰͷHomeKitͷ࿩

  18. ࠷ۙͷΞοϓσʔτ

  19. Home Pod

  20. Home Pod Amazon Echo΍Google HomeͷΑ͏ͳεϚʔτεϐʔΧ SiriʹΑΔԻ੠ૢ࡞͸΋ͪΖΜHomeKitʹ΋ରԠ

  21. New Accessories

  22. New Accessories εϓϦϯΫϥʔͱऄޱ͕௥Ճ͞Ε·ͨ͠ɻ

  23. Dates and Times ͜Ε·Ͱͷ೔ͷೖ/೔ͷग़/࣌ࠁ/༵೔ͷࢦఆ͚ͩͰ͸ͳ͘ɺ೥݄ ೔ͷࢦఆ͕αϙʔτ͞Ε·͢ɻ

  24. Threshold ݻఆ஋͚ͩͰͳ͘࠷େ஋/࠷খ஋/ൣғࢦఆͰΠϕϯτΛτϦΨ͞ ͤΔ͜ͱ͕Ͱ͖ΔΑ͏ʹͳΓ·͢ɻ

  25. Presence ෳ਺ϢʔβͷҐஔ৘ใʹΑΔΠϕϯτΛτϦΨ͕ग़དྷΔΑ͏ʹ ͳΓ·͢ɻ

  26. Presence condition ·ͨɺ͜Ε·ͰͷΠϕϯτͷ৚݅ʹPresenceΛՃ͑ͯॊೈͳΠ ϕϯτൃՐ͕ग़དྷΔΑ͏ʹͳΓ·͢ɻ

  27. End Event ΞΫηαϦΛىಈͤ͞Δ͚ͩͰͳ͘ɺͦͷऴྃΠϕϯτΛఆٛ ͢ΔࣄͰɺ Ұఆ࣌ؒޙʹऴྃͤ͞ΔͳͲͷૢ࡞͕ग़དྷΔΑ͏ʹͳΓ·͢ɻ

  28. Enhanced Setup Code

  29. Enhanced Setup Code ΞΫηαϦͷηοτΞοϓ࣌ͷίʔυೖྗͷํ๏͕৽͘͠௥Ճ ͞Ε·ͨ͠ɻ • QR Code • NFC

  30. HAP࢓༷ͷެ։ ͜Ε·ͰΦʔϓϯʹ͞Ε͍ͯͳ͔ͬͨHAPͷ࢖༻͕։ൃऀ޲͚ ʹެ։͞Ε·ͨ͠ɻ ͜ΕʹΑΓ։ൃऀ͸MFiͷϥΠηϯεܖ໿Λߦ͏͜ͱͳ͘ɺHAP ࢓༷ͷج͖ͮϓϩτλΠϐϯά͕͠΍͘͢ͳΓ·ͨ͠ɻ ౰વɺ঎༻ʹ͸MFiϥΠηϯεͷܖ໿͕ඞཁͰ͕͢ɺ։ൃ࣌΍ݸ ਓར༻ʹ͍ͭͯ͸MFiΛ௨͢ඞཁ͕ͳ͘ͳΓ·ͨ͠ɻ

  31. ڵຯग़ͯདྷ·͔ͨ͠ʁ (͍·͍ͪʁ)

  32. Node-REDΛ࢖ͬͨ HomeKit࿈ܞ

  33. https://speakerdeck.com/tamaki/bu-wu-wonaitosihutosuru-in- node-red-ug

  34. https://speakerdeck.com/tamaki/bu-wu-wonaitosihutosuru-in- node-red-ug

  35. https://speakerdeck.com/tamaki/bu-wu-wonaitosihutosuru-in- node-red-ug

  36. Կ͕໘౗͔ͩͬͨʁ • HomebridgeϓϥάΠϯͷ࣮૷ • ੺֎ઢϦϞίϯΛૢ࡞Ϟδϡʔϧͷ࡞੒

  37. ɹnode-red-contrib-homekit HomebridgeͷϓϥάΠϯ։ൃͳ͠ʹαʔϏελΠϓɾΩϟϥ ΫλϦεςΟοΫΛϊʔυͷઃఆͰબ୒͢Δ͚ͩͰ؆୯ʹΞΫ ηαϦͷఆٛΛߦ͏ࣄ͕Մೳ node-red-contrib-homekit https://www.npmjs.com/package/node-red-contrib-homekit

  38. ࢖͍ํ(1) Node-REDͱnode-red-contrib-homekitͷΠϯετʔϧ $ npm install -g node-red $ cd ~/.node-red/

    $ npm install node-red-contrib-homekit
  39. ࢖͍ํ(2) node-redͷىಈ(ԼهίϚϯυ)ɺ࣮ߦޙlocalhost:1880ʹϒϥ ΢βͰΞΫηε͠Node-REDͷը໘Λ։͖·͠ΐ͏ɻ $ node-red

  40. ࢖͍ํ(3) node-red-contrib-homekit͕Πϯετʔϧ͞Ε͍ͯΕ͹ࠨଆͷ Node-REDύϨοτʹHomeKitϊʔυ͕දࣔ͞Ε·͢ɻ

  41. ࢖͍ํ(4) HomeKitϊʔυΛυϥοάͯ͠ϑϩʔ಺ʹ഑ஔ͠ɺμϒϧΫ ϦοΫͯ͠ઃஔΛ࢝Ί·͢ɻ

  42. ࢖͍ํ(5) ·ͣ͸AccessoryΛ௥Ճ͠·͠ΐ͏ɺฤूϘλϯΛԡͯ͠ Accessoryઃఆը໘ʹભҠ͠·͢

  43. ࢖͍ํ(6) AccessoryͷઃఆͰ͸جຊతʹTypeͱ NameͷઃఆΛߦ͍·͢ɻ ͦͷ΄͔ͷ߲໨΋ઃఆͰ͖·͕͢ɺجຊ తʹσϑΥϧτ஋Ͱ໰୊͋Γ·ͤΜɻ

  44. ࢖͍ํ(7) Type͸Ұཡ͔Βબ୒͢ΔܗʹͳΓ· ͢ɻ ྫͱͯ͠FAN(ઔ෩ػ)Λબ୒ͨ͠ྫͱ͠ ·͢ɻ

  45. ࢖͍ํ(8) ࣍ʹAccessoryͰѻ͏ServiceΛબ୒͠· ͢ɻ ͜͜Ͱ΋Accessory͕FanͳͷͰService ΋FanͰ߹Θ͓͖ͤͯ·͠ΐ͏

  46. ࢖͍ํ(9) ͋ͱ͸Nodeʹ໊લΛ෇͚ͯ׬ྃͰ͢ɻDeployϘλϯͰσϓϩ Πͯ͠Έ·͠ΐ͏ɻ

  47. ࢖͍ํ(10) ࣍ʹiOSͷHomeΞϓϦͰΞΫηαϦͱͯ͠௥ՃͰ͖Δ͔֬ೝͯ͠Έ·͠ΐ͏ɻ ※ iOS୺຤͸Node-REDΛىಈ͍ͯ͠ΔϚγϯͱಉ͡ωοτϫʔΫʹ઀ଓͨ͠ঢ়ଶʹ͍ͯͩ͘͠͞ɻ

  48. ࢖͍ํ(11) AccessoryΛHomeKitʹొ࿥ग़དྷͨΒ࣍ ͸Πϕϯτ௨஌Λ֬ೝ͍͖ͯ͠·͢ɻ ·ͣ͸HomeΞϓϦ͔Βͷૢ࡞Λߦͬͨ ࣌ʹͲͷΑ͏ͳΠϕϯτ͕Node-REDଆ ʹฦͬͯ͘Δͷ͔Λ֬ೝͯ͠Έ·͢ɻ ֬ೝʹ͸DebugϊʔυΛ࢖༻͠·͢ɻ

  49. ࢖͍ํ(11) AccessoryΛHomeKitʹొ࿥ग़དྷͨΒ࣍ ͸Πϕϯτ௨஌Λ֬ೝ͍͖ͯ͠·͢ɻ ·ͣ͸HomeΞϓϦ͔Βͷૢ࡞Λߦͬͨ ࣌ʹͲͷΑ͏ͳΠϕϯτ͕Node-REDଆ ʹฦͬͯ͘Δͷ͔Λ֬ೝͯ͠Έ·͢ɻ ֬ೝʹ͸DebugϊʔυΛ࢖༻͠·͢ɻ

  50. ࢖͍ํ(12) ࣍͸Node-REDଆ͔ΒAccessoryͷมԽ Λىͯ͜͠HomeΞϓϦʹมߋ͕൓ө͞ ΕΔͷΛ֬ೝͯ͠Έ·͠ΐ͏ɻ injectϊʔυΛ࢖༻ͯ͠໌ࣔతʹ HomeKitϊʔυʹinputΛ༩͑ͯΈ· ͢ɻ ͜ͷྫͰ͸{"foo": "bar"}ͱ͍͏ςΩ τʔͳjsonΛinputͱ͍ͯ͠·͢ɻ

  51. ࢖͍ํ(12) ͦͷ৔߹ɺAccessoryʹׂΓ౰ͯͨ Serviceʹ͸ͦΕͧΕHAP(HomeKit Accessory Protocol)Ͱఆٛ͞Εͨ Characteristic͕͋ΔͨΊઌ΄ͲͷΑ͏ ͳσʔλ͸ΤϥʔͱͳΓdebugλϒʹΤ ϥʔ಺༰͕දࣔ͞Ε·͢ɻ͜͏͢Δ͜ͱ ʹΑͬͯService͕࣋ͭCharacteristicͷ ΩʔΛ஌Δ͜ͱ͕Ͱ͖·͢ɻ

  52. ࢖͍ํ(12) ͨͩɺ͜ͷํ๏ͰCharacteristicͷΩʔΛ୳ͯ͠஋Λઃఆ͢Δํ ๏͸͋·Γޮ཰తͱ͸ݴ͑·ͤΜ! CharacteristicͷΩʔ͕Θ͔ͬͯ΋ͦͷ஋ͷܕ(จࣈྻɺ਺஋ɺ࿦ ཧ஋ͳͲʣ͕Θ͔Βͳ͍ͱ͍͏໰୊఺΋͋Γ·͢ɻ ɹ ͜ͷ఺ʹ͍ͭͯ͸ޙ΄Ͳઆ໌͢ΔͷͰҰ୴ઌʹਐΊ·͢ɻ

  53. ࢖͍ํ(13) Fanʹ͸ඞਢͱͳΔCharacteristicͱ͠ ͯ"On"͕͋Γɺͦͷ஋͸0͔1ɺͭ·Γ true/falseͷ࿦ཧ஋Ͱ͋Δࣄ͕HomeΞ ϓϦΛૢ࡞ͨ࣌͠ͷϩάͱઌ΄ͲͷΤ ϥʔ಺༰͔ΒਪଌͰ͖·͢ɻ injectϊʔυʹΩʔ"On"ͷ஋Λઃఆͯ͠ ࣮ߦͯ͠Έ·͠ΐ͏ɻHomeΞϓϦͷ Fanͷঢ়ଶ͕มΘΕ͹੒ޭͰ͢ɻ

  54. Characteristicͷ୳͠ํ ઌ΄ͲΘ͟ͱHomeKitϊʔυʹޡͬͨinputΛ༩͑ͯग़ͨΤϥʔ ΛݩʹCharacteristicΛਪଌ͢Δํ๏ΛͱΓ·͕ͨ͠ɺͦΕҎ֎ ͷCharacteristicͷௐ΂ํʹ͍ͭͯิ଍͠·͢ɻ

  55. Characteristicͷ୳͠ ํ Ұ൪࣮֬ͳͷ͕݁ہHAP-NodeJSͷఆٛ ϑΝΠϧΛಡΉࣄͰͨ͠! ྫ͑͹FanͷCharacteristic͕஌Γ͍ͨ৔ ߹HomeKitTypes.js಺Λݕࡧ͢ΔͱҎ ԼͷΑ͏ͳఆ͕ٛ֬ೝͰ͖·͢ɻ https://github.com/KhaosT/HAP- NodeJS/blob/master/lib/gen/ HomeKitTypes.js

  56. ؾ͖ͮ ͦͷ1 HomeΞϓϦ • Doorbell͸HomeΞϓϦͰ͸αϙʔτ͍ͯ͠ͳ͍ • σόΠεͷొ࿥͸Մೳɺͨͩ͠DoorbellͷΞΠίϯ͸දࣔ͞ Εͳ͍ɺσόΠεͷมߋ௨஌ʹ΋൓Ԡ͠ͳ͍ • HomeKit

    frameworkͷσόΠεͷมߋ௨஌͸ϑΥΞάϥ΢ϯ υͷΈͳͷͰɺόοΫάϥ΢ϯυ࣌ʹυΞϕϧͷมߋ௨஌͸ ඈΜͰ͜ͳ͍
  57. ؾ͖ͮ ͦͷ2 DoorbellΞϓϦ • DoorbellΛѻ͍͍ͨ৔߹͸HomeKit frameworkΛ࢖ͬͯΞϓ ϦΛ࡞Δ • HomeKit frameworkͷσόΠεͷมߋ௨஌͸ϑΥΞάϥ΢ϯ

    υͷΈͳͷͰɺόοΫάϥ΢ϯυ࣌ʹυΞϕϧͷมߋ௨஌͸ ඈΜͰ͜ͳ͍
  58. ॾ஫ҙ ΋͠HomeKitରԠσόΠεͷ։ൃΛߟ͍͑ͯΔͷͰ͋Ε͹ɺ HomebridgeΛͦͷ··࢖͏ͷͰ͸ͳ͘ɺ͋͘·ͰϓϩτλΠ ϐϯάͷखஈͷҰͭͱ͍ͯΈͨํ͕ྑ͍ͱࢥ͍·͢ɻ

  59. DEMO (ࣄલࡱӨ)

  60. DEMO (ࣄલࡱӨ)

  61. DEMO

  62. Ҏ্