Upgrade to Pro — share decks privately, control downloads, hide ads and more …

部屋をナイトシフトする in Node-RED UG

部屋をナイトシフトする in Node-RED UG

HomeKit + homebridge + Node-RED + irMagician で部屋の明かりを調光してみた話

Db5cf21a75ebe2484b95ea9dec5f573b?s=128

Shingo Tamaki

June 27, 2016
Tweet

More Decks by Shingo Tamaki

Other Decks in Technology

Transcript

  1. ෦԰ΛNightShift͢Δ in Node-RED UG

  2. ࣗݾ঺հ ۄ৓ ৴ޛ • iOS ΤϯδχΞ • ޷͖ͳiOSͷϑϨʔϜϫʔΫ HomeKit •

    ΨδΣοτ޷͖ • ిࢠ޻࡞࢝Ί·ͨ͠ɻRaspberry PiɺArduinoɺEdison
  3. ຊ೔ͷςʔϚ σόΠε࿈ܞ

  4. γʔϦϯάϥΠτͷ৭Թ౓ௐޫػೳ Λ࢖ͬͯ φΠτγϑτΛ࣮ݱͯ͠Έ·ͨ͠ɻ

  5. None
  6. ߏ੒ • iOS HomeKit • homebridge • Node-RED in Raspberry

    Pi • irMagician • γʔϦϯάϥΠτ
  7. irMagician

  8. irMagicianͱ͸ʁ • PCରԠܕͷ੺֎ઢϦϞίϯγεςϜ • ϗετͱͷ઀ଓ͸USB • ΤΞίϯͷϦϞίϯͷֶश͕Մೳ • CDC-ACMΛ࠾༻͠ɺओཁͳOS(Windows, MacOSX,

    Linux, ͦͷଞ)ʹରԠ • ٕज़ࢿྉΛެ։͍ͯ͠ΔʢΦʔϓϯιʔεԽʣ http://www.omiya-giken.com/?page_id=837
  9. ࢖͍ํ screen /dev/cu.usbmodem01231 9600 ※σόΠε໊͸irMagicianͷόʔδϣϯ΍OSʹΑͬͯҟͳΓ· ͢ɻ ίϯιʔϧʹೖͬͨΒc΍pͰ৴߸ΛΩϟϓνϟɺൃ৴ग़དྷ·͢ ... Ready irMagician

    1.0.3-T OK ... 60 ... Done !
  10. Node-RED͔Β irMagicianΛૢ࡞͢ Δ serialportϊʔυΛ࢖ͬͯirMagicianʹ ίϚϯυΛૹΔflowΛ࡞Δࣄ͕Ͱ͖·͢ ͕ɺ ؾܰʹirMagician͕࢖͑Δͱ͸ݴ͑ͳ͍ ؾ͕͠·ͨ͠

  11. !

  12. ࡞Ε͹͍͍͡Όͳ͍

  13. ࡞Γ·ͨ͠ɻ

  14. ·ͣNodeͷϞδϡʔϧ https://www.npmjs.com/package/ irmagician CLIπʔϧͱͯ͠irMagicianΛૢ࡞͢Δ ࣄ͕Ͱ͖·͢ɻ

  15. σόΠε৘ใҰཡΛදࣔͨ͠Γ $ irMagician info ----------------------------------- [irMagician Infomation] 0) Version :

    1.0.3 1) IR change point : 60 (3c) 2) Max of high IR signal : 33578 (832a) 3) Min of high IR signal : 1178 (49a) 4) Max of low IR signal : 3819 (eeb) 5) Min of low IR signal : 1183 (49f) 6) postScaler : 256 (100) 7) current bank : 0 (0) -----------------------------------
  16. Ωϟϓνϟͨ͠Γ $ irMagician capture 3 'bytes written' ... ... 62

    ϓϨΠͨ͠Γ $ irMagician play
  17. μϯϓͨ͠Γ $ irMagician dump {"postscale":256,"freq":38,"data":[63,1,141,39,40,12,12,12,12,12, 28,12,28,12,28,12,28,12,12,12,12,12,162,39,40,12,12,12,12,12,28, 12,28,12,28,12,28,12,12,12,12,12,160,39,40,12,12,12,12,12,28,12, 28,12,28,12,28,12,12,12,12,12],"format":"raw"} ॻ͖ࠐΜͩΓ $irMagician

    write data.json
  18. HelpݟͨΓ͢Δࣄ͕Ͱ͖·͢ $ irMagician CLI Tool for irMagician Usage: irMagician <command>

    [file] Command capture Capture a IR data play Send a IR data dump Dump written data write Write a IR data from json info Show irMagician Infomation showPorts Show device ports Options -p, --port Device port Examples irMagician capture irMagician dump data.json irMagician write data.json
  19. Node-REDͰirMagicianΛ ѻ͏ͨΊͷΧελϜϊʔυΛ ࡞੒͠·ͨ͠ https://www.npmjs.com/package/ node-red-contrib-irmagician

  20. None
  21. None
  22. গ͠୤ઢ

  23. ΧελϜϊʔυͷςϯ ϓϨʔτੜ੒ generator-node-red ΧελϜϊʔυΛ࡞੒͢Δ৔߹ɺhtmlͱ jsΛॻ͘ඞཁ͕͋ΔͷͰ͕͢ɺ ͜Ε͕݁ߏ໘౗Ͱ͢ɻyoͷδΣωϨʔλ Λ࢖͑͹ςϯϓϨʔτΛੜ੒ͯ͘͠ΕΔ ͷͰ ΧελϜϊʔυ࡞੒ͷ࠷ॳʹ࢖͏ͱศར Ͱ͢ɻ

  24. ͜ͷޙ͸iOSͷ࿩

  25. HomeKit࢖ͬͯ·͔͢ʁ

  26. ͱݴ͏͔

  27. ஌ͬͯ·͔͢ʁ

  28. HomeKit is Կʁ HomeKit͸ɺAppleͷHomeKit Accessory ProtocolʹରԠͨ͠ ϗʔϜΦʔτϝʔγϣϯػثͱ௨৴͠ɺ͜ΕΛ੍ޚ͢ΔͨΊͷ ϑϨʔϜϫʔΫͰ͢ɻ(HomeKit Developer GuideΑΓൈਮ)

  29. HomeKitରԠΞϓϦ։ൃͷ໰୊఺ • ରԠ୺຤͕গͳ͍ • ֹ͕ۚߴ͍! • HomeKit Accessory SimulatorͰ͸ຯؾͳ͍

  30. homebridge

  31. homebridge is Կʁ • HomeKitͷԾ૷σόΠεΛΤϛϡϨʔγϣϯ • Node.js͕ಈ͘୺຤Λར༻ՄೳɺRaspberry Pi΍Edison͕࢖͑ Δ

  32. homebridge-cmd ಛఆͷίϚϯυΛ࣮ߦͤ͞Δࣄ͕Ͱ͖ΔϓϥάΠ ϯ ͜ΕʹΑΓSiriܦ༝ͰΠϕϯτΛτϦΨͤͯ͞ޙ ͸ࣗ෼ͷ޷͖ͳίϚϯυΛ࣮ߦͰ͖·͢ https://github.com/senyoltw/ homebridge-cmd

  33. None
  34. Demo

  35. ࠓޙͷ༧ఆ • homebridge-irMagicianͷ։ൃ • SwiftʹΑΔγϦΞϧ௨৴ͰirMagicianΛૢ࡞͢Δ • iOS10ͷHomeKitͷ৽ػೳΛࢼ͢

  36. Ҏ্