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
240
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
620
RubyとOpenCVで始める画像処理 / ruby-opencv-megurorb-23
thomi40
1
430
WebVRをはじめよう
thomi40
0
69
Other Decks in Programming
See All in Programming
Try creating your own orderedmap
kazamori
1
180
Milestoner
bkuhlmann
1
410
Kotlin Multiplatform at Stable and Beyond (Android Makers 2024)
zsmb
0
460
PostmanでAPIの動作確認が楽になった話
h455h1
0
180
大規模UIKitベースアプリへのTCAの段階的導入/gradual-adoption-of-tca-in-a-large-scale-uikit-based-app
takehilo
2
200
GitHub Copilotのススメ
marcy731
1
220
if constexpr文はテンプレート世界のラムダ式である
faithandbrave
3
670
ゆるい個人開発のススメ
kuroppe1819
10
1k
Azure OpenAI Serviceのプロンプトエンジニアリング入門
tomokusaba
3
870
Introducing Kotlin Multiplatform in an existing mobile app - Workshop Edition | AndroidMakers Paris
prof18
0
150
スクラムガイドのスプリントレトロスペクティブを改めて読みかえしてみた / Re-reading the Sprint Retrospective Section in the Scrum Guide
mackey0225
3
480
Three ways to use AI on Android: The Good, the Bad and the Ugly
marxallski
0
110
Featured
See All Featured
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
126
32k
Adopting Sorbet at Scale
ufuk
69
8.6k
StorybookのUI Testing Handbookを読んだ
zakiyama
13
4.6k
Automating Front-end Workflow
addyosmani
1357
200k
Rebuilding a faster, lazier Slack
samanthasiow
74
8.2k
The Language of Interfaces
destraynor
151
23k
Visualization
eitanlees
137
14k
Statistics for Hackers
jakevdp
790
220k
The World Runs on Bad Software
bkeepers
PRO
61
6.7k
Why You Should Never Use an ORM
jnunemaker
PRO
51
8.7k
Build The Right Thing And Hit Your Dates
maggiecrowley
25
2k
Build your cross-platform service in a week with App Engine
jlugia
226
17k
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