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
Netatmo API × Rubyで オフィスのCO2濃度をSlackに通知する / Netatmo API × Ruby × Slack
Search
Tomoki Ishimaru
November 30, 2018
Programming
0
250
Netatmo API × Rubyで オフィスのCO2濃度をSlackに通知する / Netatmo API × Ruby × Slack
2018/11/30 BE もくもく会vol,1 での登壇資料です。
Tomoki Ishimaru
November 30, 2018
Tweet
Share
More Decks by Tomoki Ishimaru
See All by Tomoki Ishimaru
Rubyで画像ファイルから様々なオブジェクトを検出する / ruby-opencv-heiseirb-2
thomi40
1
650
RubyとOpenCVで始める画像処理 / ruby-opencv-megurorb-23
thomi40
1
440
WebVRをはじめよう
thomi40
0
70
Other Decks in Programming
See All in Programming
Prompt FlowによるLLMアプリケーション開発
yuto2000
1
1k
Async Await: Mastering Python's Time-Bending Tricks - EuroPython2024
yanbo
1
290
初心者がおさえておきたいAWS CDKのベストプラクティス 2024
konokenj
15
7.3k
Folding Cheat Sheet #7
philipschwarz
PRO
0
150
Product Management LT会_クアンド新家
shinshin
0
210
継続的な活動で築く地方エンジニアの道
myamashii
2
350
I/O Extended Android in Korea 2024 ~ Whats new in Android development tools
pluu
0
250
実用的かつリーズナブルな 「Azure × Gemini × LINE」~キャラクターBot 実装ライブデモ~
tomodo_ysys
1
170
さきがけから振り返るアーキテクチャ刷新 / Reflecting on the Architectural Renewal from the Vanguard
nrslib
2
770
CSC307 Lecture 07
javiergs
PRO
0
220
DDDを志して3年経ったら「DDDの皮を被ったクリーンアーキテクチャ」になった話【デブサミ2024夏】
texmeijin
1
620
今こそ始める、CDKコンストラクトライブラリ開発 ― 入門から実践まで
tmokmss
1
930
Featured
See All Featured
Building Your Own Lightsaber
phodgson
101
5.9k
Bash Introduction
62gerente
607
210k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
662
120k
Side Projects
sachag
451
42k
Fireside Chat
paigeccino
25
2.8k
BBQ
matthewcrist
82
9k
Facilitating Awesome Meetings
lara
46
5.8k
It's Worth the Effort
3n
181
27k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
23
1.9k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
24
1.8k
The MySQL Ecosystem @ GitHub 2015
samlambert
248
12k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3.3k
Transcript
Netatmo API × RubyͰ ΦϑΟεͷCO2ೱΛSlackʹ௨͢Δ 2018/11/30 BE ͘͘ձvol,1 Tomoki Ishimaru
/ @thom_i40
ࣗݾհ • Tomoki Ishimaru • GMO AD Marketing Inc. •
ϑϩϯτΤϯυ / αʔόʔαΠυ • Իָͱࣸਅ͕͖ @thom_i40
ຊ
Netatmo × Ruby ͰΦϑΟεͷCO2ೱΛՄࢹԽ
ͳͥCO2ೱΛՄࢹԽʁ
͖͔͚ͬ
https://www.businessinsider.jp/post-106379
CO2ೱͱਓͷύϑΥʔϚϯε • CO2ೱͷߴ͍ڥͰҙࢥܾఆͳͲͷ ύϑΥʔϚϯε͕Լ͢Δֶज़จ͕ൃද • ްੜ࿑ಇলͱจ෦Պֶলɺڭҭࢪઃݐங ʹCO2ೱͷج४ΛఆΊ͍ͯΔ • CO2ೱ͕ݸਓͷύϑΥʔϚϯεʹӨڹ͢Δ
CO2ೱͷݟ͑ΔԽ͔Β࢝ΊΑ͏
Ͳ͏ͬͯʁ
Netatmo Weather Station
Netatmo Weather Station • ֎ͷڥΛܭଌ͢ΔϞδϡʔϧ • ؾԹ࣪, ؾѹ, ૽Ի, CO2ೱͳͲΛܭଌ
• ෩ྔӍྔΛܭଌ͢ΔՃϞδϡʔϧ • εϚʔτϑΥϯͱ࿈ܞՄೳ • ܭଌσʔλʹΞΫηεͰ͖ΔAPIΛఏڙ
CO2ೱΛSlack௨
Netatmo API require 'net/https' require 'json' require 'uri' token_uri
= URI('https://api.netatmo.com/oauth2/token') res = Net::HTTP.post_form( token_uri, grant_type: 'password', client_id: 'xxx', client_secret: 'xxx', username: 'xxx', password: 'xxx', scope: 'read_station' ) access_token = JSON.parse(res.body)['access_token'] api_uri = URI.parse('https://api.netatmo.com/api/getstationsdata') http = Net::HTTP.new(api_uri.host, api_uri.port) http.use_ssl = true req = Net::HTTP::Post.new(api_uri.path) req.set_form_data(access_token: access_token) res = http.request(req) data = JSON.parse(res.body) puts JSON.pretty_generate(data) https://dev.netatmo.com/en-US/resources/technical/samplessdks/tutorials
Ruby͔ΒSlackͷ௨ • slack-incoming-webhooks • ߦͷεΫϦϓτͰSlackͷ௨͕Մೳ • Slack APIͷAttachmentsʹରԠ https://github.com/shoyan/slack-incoming-webhooks
Ruby͔ΒSlackͷ௨ https://github.com/shoyan/slack-incoming-webhooks
Google Sheets ग़ྗ • google-drive-ruby • CO2ೱͷؾͷޮՌΛՄࢹԽ͢Δ • άϥϑͷੜڞ༗/ΞΧϯτཧ͕༰қ https://github.com/gimite/google-drive-ruby
Google Sheets ग़ྗ https://github.com/gimite/google-drive-ruby
γεςϜߏ Netatmoαʔόʔ ᶃ ᶄ ᶅ ᶆ Netatmo Weather Station Ruby
IFTTTͰμϝͳͷʁ • ௨͕1࣌ؒ΄ͲΕΔ͜ͱ͕͋ͬͨ • ௨ϑΥʔϚοτͷ੍ޚʹݶք͕͋Δ • ௨ͷ݅͝ͱʹΞϓϨοτͷཧ͕ඞཁ
·ͱΊ • Netatmo APIΛͬͯCO2ೱΛՄࢹԽͨ͠ • RubyGemsΛ༻͍ͯ SlackGoogle Sheetsʹग़ྗͨ͠ • Slack௨Λ͖͔͚ͬʹؾ͢Δश׳͕͖ɺ
CO2ೱ্͕͕Γʹ͍͘ΦϑΟεڥΛ࡞Εͨ
https://techblog.gmo-ap.jp/2018/05/15/ruby_netatmo_api_slack/
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ @thom_i40