Created
June 19, 2019 14:32
-
-
Save naotea/a490357489b00384bbf499226629e02e to your computer and use it in GitHub Desktop.
Nature Remo miniの温度を読んでSlackに投稿
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: UTF-8 -*- | |
# | |
# get Nature Remo API Temperature and send to Slack. | |
# | |
import requests | |
import json | |
import slackweb | |
#slack post Webhook | |
slack = slackweb.Slack(url="https://hooks.slack.com/services/....................................") | |
# Nature Remo API Access token | |
headers = { | |
'accept': 'application/json', | |
'Authorization': 'Bearer ....................................................................', | |
} | |
# get status from Nature Remo API | |
response = requests.get('https://api.nature.global/1/devices', headers=headers) | |
data = response.json() | |
temp = data[0]['newest_events']['te']['val'] | |
# make message | |
msg = "現在の室温は" + str(round(temp, 1)) + "度です" | |
#show console | |
print(msg) | |
#send to slack | |
slack.notify(text=msg) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment