LoginSignup
9
8

More than 5 years have passed since last update.

Node-REDでChromecastを操作する

Posted at

概要

node-red-contrib-chromecastなるものを見つけました。たまたま家にChromecastがあったので試してみました。

とりあえずサンプル実行

READMEにある以下のサンプルフローをインポートします。

[{"id":"2789229c.d876de","type":"chromecast-play","z":"a83f67b9.57c098","name":"","x":413.5,"y":115,"wires":[["bf26f40d.40d908"]]},{"id":"bf16e7cb.40e918","type":"inject","z":"a83f67b9.57c098","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":141.5,"y":117,"wires":[["647d6115.9b82a"]]},{"id":"bf26f40d.40d908","type":"debug","z":"a83f67b9.57c098","name":"","active":true,"console":"false","complete":"false","x":574.5,"y":115,"wires":[]},{"id":"647d6115.9b82a","type":"function","z":"a83f67b9.57c098","name":"","func":"msg.payload = {\n    ip: '192.168.1.125',\n    url: 'http://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=32&client=tw-ob&q=Word%20Up&tl=En-gb',\n    contentType: 'audio/mp3'\n}\nreturn msg;","outputs":1,"noerr":0,"x":286.5,"y":115,"wires":[["2789229c.d876de"]]}]

インポートすると以下のような感じです。

image

FunctionノードでなにやらIPアドレスとURLとContent-Typeを渡してますね。

image

IPアドレスはChromecastのIPアドレスのようですがChromecastのIPアドレスの確認方法がわからなかったので片っ端から試してみました。

URLはPCの音量を上げてブラウザで確認すると英語が発音されることがわかります。

フローを実行するとテレビで発音されました

画像を表示してみる

続いて画像を表示してみました。以下のようにURLとContent-Typeを変更します。

image

これを実行すると...

AnOOvB.gif

笑い男出た!

おしまい...

9
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
9
8