Archive for IOT

Casting media from terminal to Chromecast.

I would like to setup a cronjob to play RTHK hourly news to my Google Home in the morning, there are many many ways of doing this but here is a simple one.

I already had cronjob running to fetch current RTHK hourly news to a local archive as mp3 file from http://news.rthk.hk/rthk/ch/news-bulletins.htm

By using node-castv2-client, task done in no time.

Installation
$ sudo npm install -g castv2-client

The sample code uses mdns to discover all Chromecast device, I am having issue install mdns for unknown reason, but well I already know my IP address of the Google Home anyway, so I comment the discovery part out, hard coded my Google Home IP address, change the URLs or media, title and cover image, then fire up the js file and it is done.

Links
node-castv2-client
GitHub – A Chromecast client based on the new (CASTV2) protocol