Hi,
I’m pretty new to HA and I am confused with setting up an new automation (or a script maybe?)
What I am looking to achieve is, when I press the power button on the apple remote it triggers a smart switch turns on my TV and speakers. Also, for bonus points I’d like to add a second action to stop the internet radio in the kitchen playing music when I start the TV up.
When I finish watching, and long press the power button on the remote this in kills the power to the TV via the same smart switch.
I’m sure this is all possible but I have not had much luck so far in achieving this myself, would someone help me out with this?
All the research I’ve done has been about getting control of AppleTV, I’m sort wanting to do the opposite and get one remote to make everything thing work via that.
The YAML config examples on the Apple TV integration page are not helping me understand what to do at the moment…
Any news on getting this to work? Ive been looking to see if I can find any “buttons” inside the .remote entity but there isn’t any. Not sure if there is an IR listener that is needed to be aware of the button presses on the remote. The remote only seems to be active or inactive, no details inside of its options, and the media player is only what is actively happening on the AppleTV itself.
I don’t see how this could possibly be done. Apple’s remote does not use IR to talk to the Apple TV, it uses bluetooth. The only thing it uses IR for is sending volume commands to ancient TVs/receivers which do not support HDMI CEC. And there is no reason for Apple to make available via external API which remote buttons are pressed.
Now what you can do if your use case is something similar to OP above, is to simply trigger automations based on the state of the Apple TV itself. If the Apple TV goes active > do X, if the Apple TV goes into standby > do Y, etc.
I’ve been wrestling with the same objective. I have studied the documentation and the YAML produced by various attempts at automations and scripts through the UI, but I remain stumped, apparently because, as @Mayhem_SWE says, it can’t be done. Still would like to understand what the integration is doing in some regards, though. In particular, why does the Apple TV remote show a state of “on” even when the Apple TV is in standby mode? What does that state actually mean?
Also, what do “on,” “off,” and “idle” mean as states for the Apple TV media player (or are those legacy states not relevant to my Apple TV 4K)?
And how do I create an automation to turn off the TV or AVR when I long-press the Apple TV remote power button. That sends the Apple TV to standby mode, but it appears from my HA log that it also goes in and out of standby mode on its own or due to other button-press events coming from the remote, meaning the turn-off automation fires when it shouldn’t. Or am I seeing aberrant behavior from the Apple TV that shouldn’t be happening?
One piece of advice to @nilthing9 that took me a minute to figure out is that if you want to trigger an AVR or TV off of the state of the Apple TV entity (e.g., when the state changes from standby to anything else or from anything to either idle or playing), you need to turn off HDMI CEC/ARC; otherwise, you’ll have both the Apple TV and HA sending turn-on and turn-off commands.
I would say it means nothing. The state of the remote is pretty much irrelevant, only the state of the media player matters.
Not sure about your Apple TV, I have the latest third gen 4K model. The only time I have ever seen its state being reported as “off” was during the restart I just now made to test. Seems the integration couldn’t handle that though as it never came back online, had to reload the whole integration…
Anyway, don’t think I have ever observed the state to be on or idle either, though depending on what an app says it is doing they may well show up. It is pretty much always either playing or paused for me, or standby when it goes to sleep.
But mostly I don’t care about any of that at all, I simply rely on HDMI-CEC to turn everything on and off which mostly works correctly…
I’ve got another idea. I don’t have Apple Homebridge but but have been thinking about getting it and integrating it with HA doing (mostly just to see what capabilities that would unlock in each platform). I see this plugin that says, “Since every Apple TV is exposed as a Set-Top Box, you can create a trigger on the power state to execute automations when turning on or off.” I’m hoping that feature gets exposed to HA through the integration, but if not, I presume that I can build the automation in Homekit and call it from HA as needed.
Will report back once I try this, but any thoughts, advice, or cautions are most welcome.