Christmas Music, Yule Log, lights, and more with Google Home

I may have gone a little overboard with the automation stuff this christmas…

I’m using IFTTT to trigger a group in HASS which does the “heavy lifting”.

My christmas lights are switched on and off with the cheapest z-wave switches I could easily find on amazon (I bought one to try it out, and it works pretty damn well, so I grabbed a few more. I got them at $28 each but it seems they’ve gone up in price since then).

The tv is a chromecast, and the music is through the google home which acts like an audio-only chromecast. So I setup a “command line switch” in HASS which runs a node.js program called castnow which will let me cast a local file (or files) to a specific chromecast in the house.

Then by creatively using the commandline program screen I’m able to start the cast in a screen, check on it’s status, and stop it whenever I want.

For the music I took it a step further and wrote a bash oneliner that would shuffle a bunch of andy-williams christmas album songs randomly and play them all together. The config for the andy-williams commandline switch is here:

  command_on: >
    screen -S christmasmusic -d -m -L bash -c "/root/.nvm/versions/node/v7.2.0/bin/node /root/castnow/index.js $(ls -d -1 /root/videos/andy_williams_christmas/** | shuf | sed 's/\s/\\&/g' | tr '\n' ' ') --address --localfile-port 5100 --quiet"

  command_off: 'screen -S christmasmusic -p 0 -X stuff "sq"'
  command_state: 'screen -ls | grep "christmasmusic" | wc -l'
  value_template: '{{ value == "1" }}'

Very nice!

Very nice, I have HA turning on a GE Wall switch with the Christmas tree plugged into it, and a GE outdoor switch (the thing that looks like a real short extension cord) to turn on the outdoor lights. Both devices are in a group called xmas, so I have an automation that turns on the group at sunset and another automation that turns off the automation at 22:00. I have a DOT so I haven’t gotten around to the music yet, but it’s a simple as telling Alexa to play christmas music or shuffle my pandora christmas station (not sure of the verbiage there). But it really does make it nice and festive. It also turns off the indoor lights if everyone leaves the house. Need to work on the one that turns them back on when people come home.

Yeah I’ve got something similar for the christmas lights to turn them on when we are home after sunset and off at midnight or if we leave the house.

A side effect of using command-line switches to run the music and yule-log tv thing is that they show up in HASS as normal switches, so you can just open the page and click on “Play christmas music” to start just it alone.

What was the advantage of using castnow instead of the built-in media player functionality? I have a similar script but I use:

 - service: media_player.play_media
      entity_id: media_player.livingroom
        media_content_id: ""
        media_content_type: "video/mp4"

Someone else pointed that out on reddit, and to be completely honest, I didn’t know the built-in media player could do that!

The docs for the google-cast component only shows that you can add the chromecast as a media-player platform, and I never really looked into it more.

But regardless at least for my stuff it was easier to pipe a randomized list of songs to castnow using bash than it would be to randomize the list every time I start it in HASS directly.

And I’m actually using youtube-dl to pipe the fireplace video from youtube to castnow instead of downloading it as I still want the views to be counted and my youtube-red time to count toward the creator of it.

That makes perfect sense. Thank you for pointing out youtube-dl. I didn’t know that existed and wasn’t a fan of having to rehost every video I wanted to include in an automation on my personal server.

Time to use presence detection to Rick Roll my wife…


I just got our lights turning on via an Amazon Dot. It’s a bit old school with an X10 switch, but I had it anyway. May look at getting some other switches for future projects