LoginSignup
2
8

More than 5 years have passed since last update.

NatureRemoのAPIを使って各種センサーの数値取得

Last updated at Posted at 2018-06-24

API

NatureRemoのAPI項目が増えてました。
いままで温度、湿度センサーは取得できていましたが、
照度センサーも今回取得できるようになりましたので活用したいと思います。
(公式swaggerが更新されていなかったので気づかなかったです)


NatureRemoのアクセストークンを発行する

https://home.nature.global/
Generate Access Tokenでトークンを作成してください。
NatureRemo固有のトークンになりますので他人に知られないように注意。

NatureRemoのデータを取得する

環境導入等は以下をご参照を
NatureRemoのAPIを活用する準備

swaggerによると
1/devices で、デバイスの各種値を取得できるようです
以下のコマンドで取得します

curl -X GET "https://api.nature.global/1/devices" -H "Authorization: Bearer [アクセストークン]" >> data.json




jqコマンドで整形する場合は以下。



curl -X GET "https://api.nature.global/1/devices" -H "Authorization: Bearer [アクセストークン]" | jq . >> data.json



devices取得データ

[
  {
    "name": "Remo",
    "id": "device_id",
    "created_at": "2018-02-20T12:02:31Z",
    "updated_at": "2018-06-24T14:33:28Z",
    "firmware_version": "Remo/1.0.62-gabbf5bd",
    "temperature_offset": 0,
    "humidity_offset": 0,
    "users": [
      {
        "id": "user_id",
        "nickname": "onm",
        "superuser": true
      }
    ],
    "newest_events": {
      "hu": {
        "val": 40,
        "created_at": "2018-06-24T14:01:18Z"
      },
      "il": {
        "val": 182.19,
        "created_at": "2018-06-24T14:33:51Z"
      },
      "te": {
        "val": 26.2,
        "created_at": "2018-06-24T12:30:40Z"
      }
    }
  }
]



hu val =【湿度】
il val =【照度】
te val =【温度】

です。 

赤外線リモコンの登録情報

1/appliancesのアドレスにcurl GETで取得できます。

curl -X GET "https://api.nature.global/1/appliances" -H "Authorization: Bearer [アクセストークン]" | jq . >> data.json

appliances取得データの一部


{
    "id": "[device id]",
    "device": {
      "name": "Remo",
      "id": "[device id]",
      "created_at": "2018-02-20T12:02:31Z",
      "updated_at": "2018-03-18T10:22:27Z",
      "firmware_version": "Remo/1.0.62-gabbf5bd",
      "temperature_offset": 0,
      "humidity_offset": 0
    },
    "model": null,
    "nickname": "light",
    "image": "ico_light",
    "type": "IR",
    "settings": null,
    "aircon": null,
    "signals": [
      {
        "id": "[on/offするためのid]",
        "name": "on/off",
        "image": "ico_off"
      },
      {
        "id": "[常夜灯にするためのid]",
        "name": "small",
        "image": "ico_io"
      },
      {
        "id": "[フル点灯するためのid]",
        "name": "full",
        "image": "ico_on"
      }
    ]
  },

まとめ

取得したデータを利用してintegromatでいろいろとやっていこうと思います。

2
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
8