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
Rubyで家電をスマートに操作しよう!
Search
kojiro tominaga
November 07, 2024
Technology
1
150
Rubyで家電をスマートに操作しよう!
kojiro tominaga
November 07, 2024
Tweet
Share
More Decks by kojiro tominaga
See All by kojiro tominaga
マネージャーとエンジニアが効果的に協力するために意識した方が良い事
kotominaga
2
300
Other Decks in Technology
See All in Technology
Agentic Workflowという選択肢を考える
tkikuchi1002
1
470
Node-REDのFunctionノードでMCPサーバーの実装を試してみた / Node-RED × MCP 勉強会 vol.1
you
PRO
0
110
低レイヤを知りたいPHPerのためのCコンパイラ作成入門 完全版 / Building a C Compiler for PHPers Who Want to Dive into Low-Level Programming - Expanded
tomzoh
4
3.1k
JSX - 歴史を振り返り、⾯⽩がって、エモくなろう
pal4de
4
1.1k
VISITS_AIIoTビジネス共創ラボ登壇資料.pdf
iotcomjpadmin
0
150
GitHub Copilot の概要
tomokusaba
1
130
Clineを含めたAIエージェントを 大規模組織に導入し、投資対効果を考える / Introducing AI agents into your organization
i35_267
4
1.5k
rubygem開発で鍛える設計力
joker1007
2
180
Observability в PHP без боли. Олег Мифле, тимлид Altenar
lamodatech
0
330
IIWレポートからみるID業界で話題のMCP
fujie
0
770
~宇宙最速~2025年AWS Summit レポート
satodesu
1
1.7k
Абьюзим random_bytes(). Фёдор Кулаков, разработчик Lamoda Tech
lamodatech
0
320
Featured
See All Featured
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
228
22k
Reflections from 52 weeks, 52 projects
jeffersonlam
351
20k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Testing 201, or: Great Expectations
jmmastey
42
7.5k
Raft: Consensus for Rubyists
vanstee
140
7k
How to Ace a Technical Interview
jacobian
277
23k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.4k
Writing Fast Ruby
sferik
628
61k
Adopting Sorbet at Scale
ufuk
77
9.4k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.5k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Transcript
© 2024 Wantedly, Inc. Rubyで家電をスマートに操作しよう! Omotesando.rb #103 Nov. 9 2024
- Kojiro Tominaga
© 2024 Wantedly, Inc. 自己紹介 所属: ウォンテッドリー株式会社 職業: バックエンドエンジニア X:
@kou_tominaga 経歴: • 2022/9 ソフトウェアエンジニアに転職 • 2024/7 現職 冨永 康二郎
© 2024 Wantedly, Inc. 1. 話す事 2. モチベーション 3. Rubyで家電を操作する
4. まとめ 目次
© 2024 Wantedly, Inc. 話す事 Slackからスマートリモコンを操作する方法を話します!
© 2024 Wantedly, Inc. モチベーション • 家電(スマートリモコン)の操作をチャットに残したい ◦ スマートリモコンは通信が一方向の場合がある。なので複数人で利用する場合、現在家 電がどうなっているか分からない。チャットに操作が残ると嬉しい。
• チャットから家電を操作したい ◦ 慣れたUIから操作できる。 ◦ 複数のリモコンを意識せずに操作できる。
© 2024 Wantedly, Inc. 使用するツールと技術
© 2024 Wantedly, Inc. Rubyで家電を操作する • Ruby on Rails ◦
連携を仲介するバックエンドに利用します。 簡単なAPIを構築してSlackとNature Remoをつなぎます。 ◦ 爆速でサーバを作成できるので利用しました。 • Slack API ◦ Slackからリクエストを受け取って家電を操作します。 ◦ LINEやDiscordに変更してもOK。 • Nature Remo API ◦ Nature Remoにコマンドを送り家電を操作します。 使用するツールと技術
© 2024 Wantedly, Inc. Nature Remo APIを利用する理由 Rubyで家電を操作する Nature Remo
APIを利用する理由
© 2024 Wantedly, Inc. • IFTTTでSlack -> Alexa連携 ◦ IFTTTでのAlexa連携廃止。Web
hookの有料化。 • Slack -> Rails -> Alexa操作 ◦ Alexa -> Railsは可能だが、Rails -> Alexaは難しそう。 ▪ Railsから音声デバイスを操作して物理的に Alexaを操作する事はできそう。。。 • 直接スマートリモコン(Nature Remo)を操作する! Rubyで家電を操作する Nature Remo APIを利用する理由
© 2024 Wantedly, Inc. Rubyで家電を操作する 構成
© 2024 Wantedly, Inc. Rubyで家電を操作する 必要な作業 1. Nature Remo APIのtokenを取得
2. バックエンドの作成 3. Slackのスラッシュコマンドの設定 必要な作業
© 2024 Wantedly, Inc. Nature Remoの開発者向けサイトにアクセスしてtokenを発行する https://home.nature.global Rubyで家電を操作する Nature Remo
APIのtokenを取得
© 2024 Wantedly, Inc. エンドポイントの実装 Nature Remoのtoken 家電に対応するID Rubyで家電を操作する バックエンドの作成
© 2024 Wantedly, Inc. API docがあるので参考 https://swagger.nature.global/ #/default/get_1_echonetlite_a ppliances Rubyで家電を操作する
バックエンドの作成
© 2024 Wantedly, Inc. 注意! リクエスト制限が5分で30回なので無駄なリクエストが飛ばないようにしま しょう。 キャッシュするなどの工夫が必要です。 https://developer.nature.global/#%e3%83%aa%e3%82%af% e3%82%a8%e3%82%b9%e3%83%88%e5%88%b6%e9%99%90
Rubyで家電を操作する バックエンドの作成
© 2024 Wantedly, Inc. 手軽に検証したかったのでngrok(エングロック)を利用してアプリを公 開しました。 ※ngrokの会員登録が必要です Rubyで家電を操作する バックエンドの作成
© 2024 Wantedly, Inc. コマンド名 Rubyで家電を操作する Slackのスラッシュコマンドの設定 コマンドを設定する サーバーのURL
© 2024 Wantedly, Inc. Rubyで家電を操作する 実際に家電を操作する 🎉照明がついた
© 2024 Wantedly, Inc. まとめ
© 2024 Wantedly, Inc. まとめ Slack -> Rails -> スマートリモコンの連携はとても簡単!
Slackから簡単に家電を操作できるだけでなく、他のAPIやデバイ スとの連携も可能でスマートホームの拡張が期待できます。
© 2024 Wantedly, Inc. まとめ 何よりコードで家電を操作する事は楽しい!
© 2024 Wantedly, Inc. ご清聴ありがとうございました!