Skip to content

Instantly share code, notes, and snippets.

@naotea
Created June 19, 2019 14:32
Show Gist options
  • Save naotea/a490357489b00384bbf499226629e02e to your computer and use it in GitHub Desktop.
Save naotea/a490357489b00384bbf499226629e02e to your computer and use it in GitHub Desktop.
Nature Remo miniの温度を読んでSlackに投稿
# -*- 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