"good night" scene, how do I get my tv to turn off?

Hello, I am trying to make a “good night” scene, I want all my lights to run off and also my speakers to stop playing, and my tv to turn off. few other thing such as air purifiers should not turn off…

The lights are easy, but I can’t seem to figure out how to get the tv to turn off when I run the scene. I have two devicec that are capable of turning of the TV, a sonos soundbar (beam) and a chromecast. Both of them are hdmi connected to the TV and can turn it on and off.


When I run the scene the TV does not turn off, the lights how ever does.

You provide too litlle information for us to be able to be helpful.

I can assume many things like: the good-night-scene is on google, you have a sonos integration in HA. And your TV is not connect to HA. You have HA connected to google via Nabu Casa.
I do not like to waste my time assuming, so, please give us more details.

as @bouwew said, we need more details. Assuming you have a media player that can turn off your TV in the UI already, then all you need is this action:

  - service: media_player.turn_off
      entity_id: media_player.living_room_chromecast
1 Like

The good night scene is a scene that I am trying to create within HA

Okay. No I don’t think I have a media player that can turn off the tv. or… that depends what context you are referring to… because I would call the sonos beam a media player, and I know that can turn off my TV, I do have the sonos beam integrated in HA but I’m not sure if HA can send instructions to the beam to turn of the TV - i was purely assume that would be the case.

but it sounds like you are meaning a media player in some HA context? which I don’t think I have no.

How do I add a media player that can turn off my TV then?

You probably need an ‘smart’ tv with LAN (WiFi), f.e. like LG WebOS

I might be completely lost here… but why? I can turn off the tv from the google home app via the chromecast which also exist in HA, i can turn off the TV in the sonos app on my phone via the beam which also exist in HA. but HA cannot turn the TV off via either is that corret?

AFAIK, the media_player domain doesn’t support sending an actual PowerOff command to all devices in that domain. I know for a fact that sending that command to my Chromecasts does not actually send a PowerOff command. It sends a stop which the media_player domain seems to think is a PowerOff. I think the Sonos domain also has the same limitation.

An easy solution might be to get a cheap IR controller like a Broadlink RM and use that to send the PowerOff command.

1 Like

hmmm… or I could record a memo of my self saying “hey google turn off the tv” and play it when I run the good night scene.

Another solution would be to create an input_boolean in HA and then use a Google routine to flip that and also turn off the TV as part of that routine. That’s kind of what I do right now; When my wife and I go to bed, I tell Google “Hey Google, time for bed” and that flips an input_boolean in HA that kicks off an automation that takes care of everything to shut down the house.

That sounds like a way more smooth solution.

So just to get it right here, you have created a google routine, that is activated by the voice command “hey google, time for bed”,

Then google turns of your tv? and also flips an input bool in your HA? (how to i get google to flip it?)

And it looks like you are using node red (which i unfortunately dont have any experience with yet) but inside node red, when that input if flipped you trigger a whole lot of diveces?

including running a scene “goodnight scene” which is what I want to do.

1 Like

Basically, yeah. I modified the built-in good night routine in Google Home. You can adjust smart home devices in the “Adjust lights, plugs, and more” and that’s where I flip the input_boolean on. You could actually use the same routine to do everything, but there’s a LOT of stuff that gets flipped off and on when we go to bed, so I find it easier to do the heavy lifting in HA rather than Google Home. Plus, I could do everything in the scene as well, but I like to keep my scenes constrained to just lights and switches and nothing more.

NodeRed (for me) is a lot easier than the built-in automation engine sometimes. If you haven’t played with it, you should. :smiley:

I also have a good night scene to control most of my lights that I call from NodeRed as well.

- id: goodnight_scene
  name: Goodnight Scene
    group.attic_lights: false
    light.crawlspace_lights: false
    group.dining_room_lights: false
    group.kitchen_lights: false
    group.living_room_lights: false
    group.master_bedroom_fan_lights: false
    group.office_lights: false
    group.pantry_lights: false
    light.hue_goodnight: false
    group.fish_tank_switches: false
    switch.bathroom_outlet: false
    input_boolean.living_room_tower_fan_switch: false
    switch.dining_room_wall_outlet: false
    switch.master_bedroom_outlet: false
    switch.master_bedroom_zwave_repeater_switch: false
    switch.pantry_motion_trigger: false
    switch.master_bedroom_motion_trigger: false
1 Like

If you want to do the same thing in an automation, you could do something like this and just add whatever actions you need.

- alias: Goodnight Mode
  description: Responds to input_boolean.good_night being turned on
  - platform: state
    entity_id: input_boolean.good_night
    from: 'off'
    to: 'on'
  condition: []
  - scene: scene.goodnight_scene
  - scene: scene.hallway_light_overnight
  - scene: scene.bathroom_overnight
  - scene: scene.master_bedroom_before_bed
  mode: single

Here’s how I did mine. I have an older TV in my bedroom that isn’t a smart TV. It doesn’t have ip control or hdmi cec so this solution helps in not only turning off the TV but also turning it on.

Buy a smart outlet that home assistant will consider a switch. I have wemo and also tp link ones. Now you can cut power to your TV to turn it off any time you want. If you turn it on, your TV should turn on as well. I use that gor my goodnight routine. Turn switch off, wait, turn switch on so my TV is waiting for me.

With some switches, their apps can also let you turn off whatever device has been powered on after X minutes. Its a good sleep timer.