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
110
Rubyで家電をスマートに操作しよう!
kojiro tominaga
November 07, 2024
Tweet
Share
More Decks by kojiro tominaga
See All by kojiro tominaga
マネージャーとエンジニアが効果的に協力するために意識した方が良い事
kotominaga
2
260
Other Decks in Technology
See All in Technology
AndroidXR 開発ツールごとの できることできないこと
donabe3
0
130
白金鉱業Meetup Vol.17_あるデータサイエンティストのデータマネジメントとの向き合い方
brainpadpr
5
740
Platform Engineeringは自由のめまい
nwiizo
4
2.1k
Moved to https://speakerdeck.com/toshihue/presales-engineer-career-bridging-tech-biz-ja
toshihue
2
740
リーダブルテストコード 〜メンテナンスしやすい テストコードを作成する方法を考える〜 #DevSumi #DevSumiB / Readable test code
nihonbuson
11
7.2k
OpenID BizDay#17 KYC WG活動報告(法人) / 20250219-BizDay17-KYC-legalidentity
oidfj
0
240
AndroidデバイスにFTPサーバを建立する
e10dokup
0
250
Amazon S3 Tablesと外部分析基盤連携について / Amazon S3 Tables and External Data Analytics Platform
nttcom
0
130
クラウドサービス事業者におけるOSS
tagomoris
1
690
2025-02-21 ゆるSRE勉強会 Enhancing SRE Using AI
yoshiiryo1
1
320
Developers Summit 2025 浅野卓也(13-B-7 LegalOn Technologies)
legalontechnologies
PRO
0
710
RECRUIT TECH CONFERENCE 2025 プレイベント【高橋】
recruitengineers
PRO
0
160
Featured
See All Featured
Build The Right Thing And Hit Your Dates
maggiecrowley
34
2.5k
Building Your Own Lightsaber
phodgson
104
6.2k
The Cult of Friendly URLs
andyhume
78
6.2k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
The Language of Interfaces
destraynor
156
24k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.2k
We Have a Design System, Now What?
morganepeng
51
7.4k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
114
50k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
21
2.5k
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. ご清聴ありがとうございました!