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
270
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
710
RubyとOpenCVで始める画像処理 / ruby-opencv-megurorb-23
thomi40
1
490
WebVRをはじめよう
thomi40
0
75
Other Decks in Programming
See All in Programming
GDG Super.init(version=6) - From Where to Wear : 모바일 개발자가 워치에서 발견한 인사이트
haeti2
0
330
iOSでQRコード生成奮闘記
ktcryomm
2
160
クックパッド検索システム統合/Cookpad Search System Consolidation
giga811
0
220
The Clean ArchitectureがWebフロントエンドでしっくりこないのは何故か / Why The Clean Architecture does not fit with Web Frontend
twada
PRO
68
23k
Rubyと自由とAIと
yotii23
6
2k
CDKを使ったPagerDuty連携インフラのテンプレート化
shibuya_shogo
0
150
AWS CDKにおけるL2 Constructの仕組み / aws-cdk-l2-construct
gotok365
4
760
やっと腹落ち「スプリント毎に動くモノをリリースする」〜ゼロから始めるメガバンクグループのアジャイル実践〜
sasakendayo
0
290
AI Agentを利用したAndroid開発について
yuchan2215
0
150
機能が複雑化しても 頼りになる FactoryBotの話
tamikof
1
270
RecSys2024 参加報告
unonao
1
140
PEPCは何を変えようとしていたのか
ken7253
3
330
Featured
See All Featured
Typedesign – Prime Four
hannesfritz
41
2.5k
Measuring & Analyzing Core Web Vitals
bluesmoon
6
280
Site-Speed That Sticks
csswizardry
4
430
Bash Introduction
62gerente
611
210k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.3k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
12k
The Invisible Side of Design
smashingmag
299
50k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.3k
Raft: Consensus for Rubyists
vanstee
137
6.8k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.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