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に通知する / Net...
Search
Tomoki Ishimaru
November 30, 2018
Programming
0
260
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
700
RubyとOpenCVで始める画像処理 / ruby-opencv-megurorb-23
thomi40
1
480
WebVRをはじめよう
thomi40
0
74
Other Decks in Programming
See All in Programming
『GO』アプリ バックエンドサーバのコスト削減
mot_techtalk
0
140
CNCF Project の作者が考えている OSS の運営
utam0k
6
710
ARA Ansible for the teams
kksat
0
150
[JAWS-UG横浜 #80] うわっ…今年のServerless アップデート、少なすぎ…?
maroon1st
1
180
負債になりにくいCSSをデザイナとつくるには?
fsubal
9
2.4k
お前もAI鬼にならないか?👹Bolt & Cursor & Supabase & Vercelで人間をやめるぞ、ジョジョー!👺
taishiyade
6
4k
Spring gRPC について / About Spring gRPC
mackey0225
0
220
DROBEの生成AI活用事例 with AWS
ippey
0
130
GAEログのコスト削減
mot_techtalk
0
120
密集、ドキュメントのコロケーション with AWS Lambda
satoshi256kbyte
0
190
GoとPHPのインターフェイスの違い
shimabox
2
180
[JAWS-UG横浜 #79] re:Invent 2024 の DB アップデートは Multi-Region!
maroon1st
1
140
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.6k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
120k
Building an army of robots
kneath
303
45k
Visualization
eitanlees
146
15k
Designing for humans not robots
tammielis
250
25k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
Art, The Web, and Tiny UX
lynnandtonic
298
20k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.1k
Become a Pro
speakerdeck
PRO
26
5.1k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.1k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
100
18k
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