maxileith / homebridge-appletv-enhanced

Homebridge plugin that exposes Apple TVs with features that should be native to Apple HomeKit.
MIT License
136 stars 1 forks source link

Airplay as a motion sensor? #256

Open DataFran opened 4 months ago

DataFran commented 4 months ago

Current Situation

I'm trying to automate some behavior with my AppleTV, specifically I'd like to trigger scenes with my Hue lights on play/pause/stop, but I also have an automation that automatically turns on the TV and selects the AppleTV input when I airplay to the AppleTV. This steps on the toes of the play/pause automation because this also triggers the "Playing" sensor. Is it possible to create an Airplay specific sensor that doesn't also trigger the "playing" sensor? Or is there some other solution to keep these two functions separate?

Proposed Change

Some way of triggering automations for Airplay that doesn't also trigger "playing", "pause", "stop" so that separate automations/scenes can be created that don't overlap triggers.

Additional Context

No response

maxileith commented 4 months ago

Currently this is not possible. I think it would be a great idea to add a motions Sensor which is triggered when changing apps. Then, you could trigger a shortcut automation with that, that queries the activity id (active App). Then you could do different actions based on the app ...

DataFran commented 4 months ago

Another instance app-specific triggers might be useful is to differentiate things like Apple Fitness+, so that the automations you'd want for movies/tv aren't triggered by workouts.

maxileith commented 4 months ago

Another instance app-specific triggers might be useful is to differentiate things like Apple Fitness+, so that the automations you'd want for movies/tv aren't triggered by workouts.

Where would be the benefit over my proposed solution?

Your solution would imply to add many devices. Since the max amount of devices accessories is 100 (HomeKit limitation), that would max out pretty fast since all the inputs are accessories on there own already.

DataFran commented 4 months ago

That's a good point. Maybe my use-case is too niche or specific to work in this case. I'd like to automate based on play/pause/stop, rather than app-switching, so I can set the lights to go down when I start a movie, bring the up to dim on pause, back to full on stop, but not when I start a workout. I'm not sure how to do that as proposed but maybe I'm missing something?

maxileith commented 4 months ago

@DataFran currently it is not possible.

However, with the solution I have proposed, you could set a trigger on the motion sensor "App Switched". So when switiching apps an automation can be triggered. In this automation, you can query the activity ID of the Apple TV (this indicates which app is currently open). So inside the automation you can just say "Do only something if Netflix is open" or "is not open" ... or whatever ... the possibilities are endless with shortcuts ...

HiddenDragon487 commented 3 months ago

This might be controversial but use the dummy switch plug in, I have one set to cinema mode for example and use in the automation creation. Aka if cinema is true, when playing turn lights off etc. therefore if cinema mode is off the automation for switching lights is not run. With dummy switch you can create a number of “modes” I have a holiday mode one that runs lights on and off while I’m away to appear that I’m home etc. you can set these triggers into a scene then can turn on and off via the Apple TV HomeKit menu or via Siri on the remote. As well as from HomePods if you have any.