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
680
RubyとOpenCVで始める画像処理 / ruby-opencv-megurorb-23
thomi40
1
460
WebVRをはじめよう
thomi40
0
73
Other Decks in Programming
See All in Programming
AI時代におけるSRE、 あるいはエンジニアの生存戦略
pyama86
6
1.2k
Amazon Qを使ってIaCを触ろう!
maruto
0
420
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
2
120
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
340
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
120
[Do iOS '24] Ship your app on a Friday...and enjoy your weekend!
polpielladev
0
110
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
TypeScript Graph でコードレビューの心理的障壁を乗り越える
ysk8hori
3
1.2k
CSC509 Lecture 11
javiergs
PRO
0
180
みんなでプロポーザルを書いてみた
yuriko1211
0
280
Micro Frontends Unmasked Opportunities, Challenges, Alternatives
manfredsteyer
PRO
0
110
Why Jakarta EE Matters to Spring - and Vice Versa
ivargrimstad
0
1.2k
Featured
See All Featured
Mobile First: as difficult as doing things right
swwweet
222
8.9k
Designing the Hi-DPI Web
ddemaree
280
34k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Building Your Own Lightsaber
phodgson
103
6.1k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
380
Site-Speed That Sticks
csswizardry
0
33
Gamification - CAS2011
davidbonilla
80
5k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Thoughts on Productivity
jonyablonski
67
4.3k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.2k
Statistics for Hackers
jakevdp
796
220k
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