4 m
A TV upon a closet with stuffed animal dogs around itThere it was, standing in the corner. My second hand flat screen tv, waiting for me to set it up. My first idea was to use it as a computer display. My second and much better idea was to use it to watch my favorite series right from my bed for a complete cinematic feel. So, I put it on top of my closet, hooked it up to my Apple TV, a spare Google Chromecast, connected an audio cable to my Echo Plus’s audio input and started the process of automating to get a full bedroom cinematic experience.

There are a couple of things I would like to happen when I turn on the TV. I would like my Echo Plus speaker to stop playing music, the bedroom fan’s windspeed to slow down if the fan is turned on, the lights in the bedroom to turn off slowly and my phone to go on to do not disturb.

Now it’s time to automate. First of all, I connected my Chromecast’s power supply to the USB port on my tv. That way, it gets power when my TV is on and no power when the TV turns off. After integrating that same Chromecast into Home Assistant using the Google Cast Integration, I can see when the TV is on or off using the availability of the Chromecast. That’s all for the Chromecast. It’s likely that I’ll be never using it to watch my series. I like to have a remote at hand and the Apple TV gives me a far better experience on that point.

Second, I made a template motion sensor in Home Assistant to let Amazon Alexa know that the bedroom tv is on. See ‘Reversing The Alexa Integration’ to learn why I’m doing it this way. I added the following lines to my configuration file:

# Binary sensor example
  - platform: template
        friendly_name: "Bedroom TV Sensor"
        device_class: motion
        value_template: "{{ is_state('media_player.tv', 'unavailable') }}"

As you may have noticed, the sensor renders true if my tv is unavailable or off. I did that because the state of the Chromecast can change between ‘off’, ‘idle’ and ‘playing’ when it’s turned on. If I change the state to ‘off’, indicating that my Chromecast and TV are on, I may getting issues in the unlikely event when I start a cast session on my Chromecast and the state changes to ‘playing’. At that point, my Home Assistant thinks my TV is off since the sensor no longer renders true. With that out of the way, I pressed save, got a green checkmark indicating that my configuration was valid and continued restarting Home Assistant.

Alexa app device page showing motion on the Bedroom TV SensorAfter restarting, my Amazon Alexa app detected a new motion sensor called ‘Bedroom TV Sensor’, which I can use to trigger Alexa routines. Since it renders true when my TV is off, the sensor stops detecting motion as soon as I turn on my TV. I know, it’s confusing, but after creating the necessary routines, you’ll never have to worry about it again. I created two routines: one for when the TV turns on (no motion detected) and one for when the TV turns off (motion detected).

I added two actions to the routine for when the TV turns on:

  1. Stop playing music.
  2. Set the Bedroom Speaker volume to 5.

For when the TV turns off, I also added two actions:

  1. Set the Bedroom Speaker volume to 3
  2. Play music

Third, I created an automation to turn off my bedroom lights in a nice and slow transition, just like it happens at the movies. This automation is triggered by a state change from the ‘Bedroom TV Sensor’. In order to accomplish this transition, I used a service call to the ‘lights.turn_off’ service. The service data is as follows:

entity_id: light.bedroom
transition: 7
# Transition is in seconds.

To prevent the motion sensor in my bedroom from turning on the lights while the TV is on, I added a condition to that automations in which the ‘Bedroom TV Sensor’ has to be ‘on’. (Remember that in this specific situation ‘on’ actually means ‘off’.)

Last but not least, the fan in my bedroom. It makes an awful lot of noise. So, when I watch TV, I wanted the fan to be quiet. Since my bedroom fan is controlled with a remote, it’s as easy as to send a command to slow the windspeed down when the TV turns on. That’s where the easy part ends, because when I turn on the fan while the TV is already on, I also wanted to quiet the fan. So, I came up with the following automation:

  alias: Bedroom fan and bedroom tv on
  description: ''
  - entity_id: binary_sensor.bedroom_tv
    from: 'on'
    platform: state
    to: 'off'
  - entity_id: input_boolean.bedroom_fan
    for: 00:00:06
    # The extra time is to give the bedroom fan some time to turn on before giving the windspeed command.
    from: 'off'
    platform: state
    to: 'on'
  - condition: state
    entity_id: binary_sensor.bedroom_tv
    state: 'off'
  - condition: state
    entity_id: input_boolean.bedroom_fan
    state: 'on'
  - condition: state
    entity_id: input_boolean.nightmode
    state: 'off'
  - data: {}
    service: rest_command.br_fan_speed
    # Triggers the windspeed command, yours may be different.

And that’s it! The start of a true cinematic experience in my bedroom. I have a lot of ideas to inprove my bedroom cinema, which I will tell you as soon as it’s working.