maxileith / homebridge-appletv-enhanced

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

Add AirPlay as an input #187

Closed mark3apps closed 6 months ago

mark3apps commented 6 months ago

Analysis

While Airplaying to my TV music, it seems like it's unable to detect what's happening.

Expected Behavior

It should show in the Inputs that it's currently Airplaying or show what app is currently open while airplaying.

Steps To Reproduce

Airplay to a TV to play Music

Logs

Output from logs
Living Room Apple TV (XX:XX:XX:XX:XX:XX): Could not update the input to com.apple.TVAirPlay since the app is unknown.

Configuration

{
    "mediaTypes": [
        "music",
        "unknown",
        "video"
    ],
    "remoteKeysAsSwitch": [
        "pause",
        "play",
        "volume_down",
        "volume_up"
    ],
    "deviceStateDelay": 0,
    "platform": "AppleTVEnhanced",
    "_bridge": {
        "port": xxxxx,
        "username": "XX:XX:XX:XX:XX:XX"
    },
    "deviceStates": [
        "paused",
        "playing"
    ],
    "discover": {
        "unicast": [],
        "blacklist": [],
        "multicast": true
    },
    "name": "Apple TV Enhanced",
    "disableVolumeControlRemote": false,
    "forceVenvRecreate": false,
    "customInputURIs": [],
    "logLevel": 2,
    "avadaKedavraAppAmount": 15
}

Additional Context

No response

maxileith commented 6 months ago

This is not really an error as the follwing log message is already indicating by beeing a warning ...

Living Room Apple TV (XX:XX:XX:XX:XX:XX): Could not update the input to com.apple.TVAirPlay since the app is unknown.

I would consider this rather an enhancement. The goal would be to display something like "AirPlay: Spotify" as the currently selected input in HomeKit.

The reason that my plugin does not know the app com.apple.TVAirPlay is that the Apple TV itself does not report that it has this app. Why am I speaking of an app? I am pretty sure that AirPlay is a dedicated app on the Apple TV that just opens when a device connects to it and then it simply plays the content. So no matter what you are playing on the Apple TV, it is always the same app ...

So in order to achieve "AirPlay: Spotify" as the currently selected input, I have added a special input for AirPlay which is renaming itself whenever the app that is airplaying to the AppleTV.

Could you please install version v1.2.0-2 and test if everything works for you?

mark3apps commented 6 months ago

The fact that I reported this yesterday and already it's doing what I want it to do is amazing. I just tested it out with airplaying from the Apple Music App (the typical one I use) and it worked perfectly. Curious, for homekit shortcuts, is there a way you could expose that current input name as a variable that can be selected in the "Get ____" Home Shortcut? It would be great to be able to create automations and shortcuts based on the airplay names.

Also, I just wanna say, I love this plug in so much and really appreciate the effort and time you've put into it. Put my smart home to the next level.

maxileith commented 6 months ago

Also, I just wanna say, I love this plug in so much and really appreciate the effort and time you've put into it. Put my smart home to the next level.

Thank you! I really appreciate your warm words :heart:

Curious, for homekit shortcuts, is there a way you could expose that current input name as a variable that can be selected in the "Get ____" Home Shortcut?

You can get the current input with "Get activity id" (or something similiar, I am not 100% sure because I have set my iPhone to german). Depending on the app there is a unique number which is generated by hashing the URI of the app.

In v1.2.0-2 this applies for the AirPlay input as well (of course). However, since one input is used for all possible AirPlay signals that is then renamed dynamically, this is always the same value. An option would be to change the identifier of the input dynamically but this is not possible due to HomeKit limitations.

DataFran commented 5 months ago

Maybe I'm messing up my automation settings, but what I'd love to be able to do here is trigger an automation when I airplay from my phone to the AppleTV. Is this possible with the current exposed sensors?