Media player function problem

Developing with HA is so interesting because most components are supported with third party package. It means if you dont need to write driver fo every component , you just use it.
Media player supported many devices including AppleTV, but i want to know the reason why there are no up, down, right, left key command on this component. Because when i see the introduction of pyatv, i found there are some commands that you can used for sending direction commands.
Is it enough for the component have the basic functions but no direction command function?
No offence, i just want to know why the media player component defined like this and can i add another functions in this component?

There is a strict rule for developing in Home Assistant that no device/protocol specific logic can be checked in. All code needed to communicate with a device must be placed in a separate library and preferably be published to pypi as well, so it can easily be downloaded as a dependency. Adding support for a new product should mainly be to import the library and write “glue code” that integrate the library with the concepts Home Assistant uses. Fact is that a lot of new libraries have been created because of this.

What and how much functionality is supported depends on a few things. First and foremost what the device itself supports. The Apple TV for instance supports the concept of arrow keys but Sonos don’t - and both are media players in Home Assistant. So the arrow keys would have to be platform specific services only available on the Apple TV (or other media players that support it). More general controls can be available on all media players, like play/pause, volume, etc. Secondly, support for the functionality must be implemented in the corresponding library (might also include some reverse engineering). Lastly, the component and/or platform must be update in Home Assistant to support the new feature. So, just because it’s in the library doesn’t mean that Home Assistant necessarily supports it.

I can speak for the Apple TV integration as I’m the author of it (and pyatv). The reason that the arrow keys are not supported yet is because I have not been able to release a new version of pyatv including this feature because of a dependency issue. If you install from pypi now you would get version 0.2.2, which doesn’t support arrow keys. And even if I did release it, it could not be used in Home Assistant. That has now been sorted out and I’m finalizing device authentication to restore AirPlay functionality for tvOS 10.2+, which is now broken. Once that is done, I will create a new release and update the integration in Home Assistant with a lot of new features. Including a service for sending any of the regular buttons on the remote.

1 Like

I don’t use ATV, but I appreciate the effort you’ve made to clarify the process by which devices are supported. Thanks.

Top notch, always glad to help out!

Its a very clear explaination of this component ,thx:slight_smile: