Homebridgeを使ってSiriでPhilips Hueをコントロールする
いい加減HueとIRKitを使いこなして未来的なお部屋にしたいなぁと考えています。 しかしモチベーションが上がらないのでなかなか進まず…
今回はhomebridgeというApple HomeKitのオープンソース実装を使ってみます。 これを使用することでSiriの音声認識をトリガーとして行うことが出来ます。
手順
必要とされる物は以下の通りです。
Philips Hue(ヒュー) スターターセット v2 929001156101
- 出版社/メーカー: Philips(フィリップス)
- 発売日: 2016/04/06
- メディア: Personal Computers
- この商品を含むブログを見る
Avahiが必要とされるのでインストールしておきましょう。
% yaourt -S avahi nss-mdns % systemctl start avahi-daemon.service % systemctl enable avahi-daemon.service
Avahi-daemonを起動していないと以下のログを吐いて起動してくれません。
dns_sd.DNSServiceRegister(self.serviceRef, flags, ifaceIdx, name, ^ Error: dns service error: unknown
homebridgeをインストールします。
% sudo npm install -g homebridge homebridge-philipshue --unsafe-perm
homebridgeのconfigファイルを作成します。とりあえずこんな感じで動作するはずです。
gist367b7b462abb690e6ab010cc4ed37d43
usernameを空白にすると、自動的にhueのユーザを作ってくれます。
homebridgeコマンドで起動するので、とりあえず起動してみます。
/usr/lib/node_modules/homebridge-philipshue/node_modules/q/q.js:126 throw e; ^ Please press the link button on your Philips Hue bridge, then start the HomeBridge server within 30 seconds.
hueの"username"を空白にすると上のようにログを出力するので、Hueボタンを押して素早くhomebridgeを再起動します。
/usr/lib/node_modules/homebridge-philipshue/node_modules/q/q.js:126 throw e; ^ Created a new username "O81cjxxxxxxxxxxxxxxxx" for your Philips Hue. Please add it to your config.json then start the HomeBridge server again:
すると、上記のようにログを出力するのでusernameの所に記載します。
再び起動すると特に問題なく起動が完了するはずです。
その後Homekitアプリを起動して、PINコードを入力すれば動作させる事が可能です。
参考にしたサイトはこちらになります。ありがとうございます。
実際に試してみて
音声でHueが操作できたときは、ランプのon/offだけですが感動しました… Siriの音声認識は結構な精度があると思っていましたが、これを開発者が良いように使えるのはまだまだかなぁと思っていたからです。
homebridgeのpluginは色々とあって、http叩いたりcmd叩いたりirkit叩いたりとユメが広がりそうなのでぜひぜひやっていきたいです。