LoginSignup
8

More than 5 years have passed since last update.

IRKit と IFTTT でエアコンを決まった時間に自動でオフする

Last updated at Posted at 2016-09-04

昨晩、エアコンをつけっぱなしだったので、設定中。

http://ifttt.getirkit.comhttps://blog.hello-world.jp.net/irkit/3462/ を参考に。

  • まず、操作した IRKit の clientkeydeviceid を取得する。これは、IRKitと同じネットワークにいる必要が有る。(つまり同じアクセスポイントにアクセスしている必要が有る。)
$ dns-sd -B _irkit._tcp
Browsing for _irkit._tcp
DATE: ---Sun 04 Sep 2016---
10:29:20.535  ...STARTING...
Timestamp     A/R    Flags  if Domain               Service Type         Instance Name
10:12:34.567  Add        2   4 local.               _irkit._tcp.         irkitFFFF
  • この irkitFFFF の部分の名前から、IPアドレスを取得
$ dns-sd -G v4 irkitFFFF.local
ikeuchis-air:aws-iot-shadow-test ikeyasu$ dns-sd -G v4 irkitFFFF.local
DATE: ---Sun 04 Sep 2016---
10:34:56.678  ...STARTING...
Timestamp     A/R Flags if Hostname                               Address                                      TTL
10:34:56.789  Add     2  4 irkit42e7.local.                       192.168.1.4                                  10
  • 192.168.1.4 と分かりました。
$ curl -i "http://192.168.1.4/keys" -d ''
HTTP/1.0 200 OK
Access-Control-Allow-Origin: *
Server: IRKit/2.1.2.0.g424fa95
Content-Type: text/plain

{"clienttoken":"0123456789ABCDEF"}
  • これで、clienttokenが分かりました。これをもとに、api.getirkit.com に clientkeydeviceid を問い合わせます。
$ curl -i -d "clienttoken=0123456789ABCDEF" "https://api.getirkit.com/1/keys"
HTTP/1.1 200 OK
Server: openresty
Date: Sun, 04 Sep 2016 01:37:53 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 94
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: X-Requested-With
X-Content-Type-Options: nosniff

{"deviceid":"ABCDEF0123456789","clientkey":"0123456789ABCDEF0123456789"}
  • 次に、リモコンの信号を取得します。以下のコマンドは直前に受信したリモコン信号を返します。まずは、コマンドを何度か実行して、以下以外の文字が表示されないようにしてください。
$ curl -i "http://192.168.1.4/messages"
HTTP/1.0 200 OK
Access-Control-Allow-Origin: *
Server: IRKit/2.1.2.0.g424fa95
Content-Type: text/plain
  • 次に、操作したいリモコンのボタンを押し、再度実行します。
$ curl -i "http://192.168.1.4/messages"
HTTP/1.0 200 OK
Access-Control-Allow-Origin: *
Server: IRKit/2.1.2.0.g424fa95
Content-Type: text/plain

{"format":"raw","freq":38,"data":[7371,3704,904,904,904,2813,904,904,904,2813,904,904,904,2813,904,1002,904,2718,904,1037,843,2813,935,935,935,2813,935,2813,935,935,935,2813,935,935,935,2813,935,2813,935,2813,935,2813,935,935,935,935,935,2813,935,2813,935,935,935,935,935,935,935,935,935,2813,935,935,935,935,935,935,935,935,935,935,935,935,935,935,935,935,935,935,843,1002,843,1002,1002,2718,935,935,935,935,935,935,935,935,843,2813,843,1002,843,1002,843,1002,1002,1002,843,1002,843,1002,843,1002,1002,843,1002,2813,935,935,935,935,935,2813,935,935,935,2813,935,935,935,935,935,935,935,935,843,1002,843,1002,843,2813,935,2813,935,935,935,2813,935,935,935,935,935,935,843,1002,843,2813,935,935,935,935,935,2813,935,935,935,2813,935,935,935,2813,935,2813,935,935,935,935,935,2813,935,935,935,935,935,935,935,2813,935,935,935,2813,935,935,935,2813,935,2813,935,2813,935,2813,935,1037,843,935,935,935,935,2718,935,935,935,935,935,935,935]}

ここで取得できた信号を使います。

  • IFTTT で、create recipe をクリック。
    https://ifttt.com/myrecipes/personal/new

  • this をクリックし、date & time を選択。
    regular.png

  • 繰り返しの種別を選択。ここでは、Everyday at をクリック。

  • 時間を設定。

  • thatをクリック。

  • Makerをクリック。(2017/10/13現在、Webhooks に名前が変わっています)
    regular-2.png

  • Make a web request をクリック。

  • URL を入力。https://api.getirkit.com/1/messages

  • Method を POST に

  • Content Type を "application/x-www-form-urlencoded"に

  • body は入力。clientkeyと、deviceid、messageを先ほど取得したものに置き換えてください。

clientkey=0123456789ABCDEF0123456789&deviceid=ABCDEF0123456789&message={"format":"raw","freq":38,"data":[7371,3704,904,904,904,2813,904,904,904,2813,904,904,904,2813,904,1002,904,2718,904,1037,843,2813,935,935,935,2813,935,2813,935,935,935,2813,935,935,935,2813,935,2813,935,2813,935,2813,935,935,935,935,935,2813,935,2813,935,935,935,935,935,935,935,935,935,2813,935,935,935,935,935,935,935,935,935,935,935,935,935,935,935,935,935,935,843,1002,843,1002,1002,2718,935,935,935,935,935,935,935,935,843,2813,843,1002,843,1002,843,1002,1002,1002,843,1002,843,1002,843,1002,1002,843,1002,2813,935,935,935,935,935,2813,935,935,935,2813,935,935,935,935,935,935,935,935,843,1002,843,1002,843,2813,935,2813,935,935,935,2813,935,935,935,935,935,935,843,1002,843,2813,935,935,935,935,935,2813,935,935,935,2813,935,935,935,2813,935,2813,935,935,935,935,935,2813,935,935,935,935,935,935,935,2813,935,935,935,2813,935,935,935,2813,935,2813,935,2813,935,2813,935,1037,843,935,935,935,935,2718,935,935,935,935,935,935,935]}

  • create recipe をクリック

  • 名前をつけて、create recipe をクリック

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
8