Reliably detecting Apple TV status changes

I have a 3rd gen Apple TV 4K connected to a receiver, and the receiver is connected to a TV. I also have an XBox connected to the receiver, and I use the receiver to change inputs. I’m trying to use HA or Nodered to help augment the simple remotes that come with each device. What I want to do is have the system:

  • Notice what device has turned on and change the receiver input to match
  • Notice the device turns off and shutdown the rest of the system

Originally, I tried to have CEC help here, but the XBox and Apple TV ended up fighting each other for control. The main issue is that I can’t find a reliable way to know what the Apple TV is up to. For example, I use a trigger that notices when the Apple TV leaves standby. Two strange issues come up with that:

  • When the XBox turns on, followed by the receiver and TV, the Apple TV goes to idle which proceeds to cause the input to change to the Apple TV.
  • So, I figure I watch for standby → idle to know it turned on. Nope! If the last person shut the system off while playing, then it goes to paused. Just to make it more fun, the status will sometimes go standby->paused->idle.
  • Of course, there also are periodic updates that happen that change the status from standby. My oldest son will be downstairs on a computer and suddenly the TV turns on at 1am.

The XBox is simple. Press the power button, and the status goes from off to on.

I’ve turned off CEC (too many headaches), but now I’m looking for a reliable method to know that someone pressed the power button on the Apple TV remote.

I use the Apple TV integration for a lot of automations, mostly in my movie theater, and it works pretty well. Standby should always be when it’s sleeping, something you can force in the settings so that if someone turns off in the middle of something then it will shut off eventually.

I also have smart TV’s or smart plugs on everything so I actually know if the TV is off or on via it’s power consumption, so if the TV is off for X minutes then you can send commands to the Apple TV to shut down or whatever.

For multiple inputs I have a system where it resets to a default state each night when I issue my “bedtime” commands. It turns on the TV, switches to the input I want to start on and turns off again.

I don’t have an Xbox anymore but when I did I would let the CEC switch to that and I know it’s on via integration, then when it goes off I had HA send commands to switch inputs back to the TV again. I use integration and Broadlinks to send my IR signals around as needed.

Using the above, the only time you should get into trouble is if someone turns off the TV while Apple TV is playing something, but you can send a command to auto-stop that if you have a smart plug on the TV.

I’m able to make it all work. However, the problem I have is that even if I have CEC off, the Apple TV turns on when I turn on the Xbox (ATV status standby->idle). So what happens is:

  1. Xbox turns on
  2. HA sees Xbox turned on, turns on receiver and TV, and sets input to Apple TV
  3. Apple TV comes on for some reason, which ends up changing the input to apple TV.
  4. I then get complaints from the family…

Too bad there doesn’t seem to be a way to catch the ATV’s power button being pressed. Tracking status does not seem to be reliable.

Ok, I found the magic other CEC setting in my Samsung TV. Now, the ATV doesn’t turn on when the Xbox turns on. So my automations work correctly now.

I also turned off all the automatic update settings on the ATV. Hopefully, this will prevent things from power on overnight.

1 Like

Dave, can you share what you did in node red?

I’m having difficulties finding a reliable way to detect that the ATV remote has been pushed. The ATV itself does not show as anything else than Standby, until the receiver is also on. Since my remote for the receiver is dead and I don’t want to thumble with multiple remotes, my wish is to be able to turn on my smart contact for the receiver and my Samsung TV, when the ATV is turned on.

Any help appreciated.

I’ve since switched back to my Nvidia Shield, but I do something similar with that. The keys are:

  • Turn off CEC everywhere. If you don’t, your automations end up fighting with CEC.
  • I setup the ATV (and the Shield) remote to work with IR for volume on my receiver.
  • Use a trigger to catch status changes with the ATV when it turns on. From standby/off/unavailable to idle if I remember correctly. The tricky part is the ATV will bounce several times between standby and idle while it starts up. Hence the next rule.
  • Add a flow variable to only allow one change since the ATV bounces around when it starts up. Check flow_variable = false, set to true, and continue on to turn on receiver, turn on TV, set input, etc. Then, when the ATV goes back to standby/off/unavailable for more than a few seconds, set flow_variable to false, turn off the receiver and TV.

Does your receiver allow NR/HA to control it? Mine has a telnet interface which allows NR/HA to control all the functions. With this setup, I only have to use the ATV/Shield remote for video. For music, I have to use a phone to choose which music to play, but I would have to do that regardless of how I set it up.