home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.51k stars 30.34k forks source link

Missing device_class for Android TV media_player entities #75925

Closed Bascht74 closed 2 years ago

Bascht74 commented 2 years ago

The problem

Hi,

i am setting up my homekit integration right now. I read about the supported components and TV devices here: https://www.home-assistant.io/integrations/homekit/#supported-components

media_player | TelevisionMediaPlayer | All media players that have tv as their device_class. Represented as Television and Remote accessories in HomeKit to control on / off, play / pause, select source, or volume increase / decrease, depending on supported_features of entity. Requires iOS 12.2/macOS 10.14.4 or later. -- | -- | --

But for my android TV media_player entity the device class is missing. The entity just got none. Could this be corrected an the missing device_class "tv" added for this integration

What version of Home Assistant Core has the issue?

core-2022.8.0b2

What was the last working version of Home Assistant Core?

-

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Andoid TV

Link to integration documentation on our website

https://www.home-assistant.io/integrations/androidtv

Diagnostics information

config_entry-androidtv-e9c8cc04dbf4da1d2245671b356cd74d.json.txt

Example YAML snippet

./. (UI)

Anything in the logs that might be useful for us?

no

Additional information

No response

probot-home-assistant[bot] commented 2 years ago

androidtv documentation androidtv source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years ago

homekit documentation homekit source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years ago

Hey there @jefflirion, @ollo69, mind taking a look at this issue as it has been labeled with an integration (androidtv) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

probot-home-assistant[bot] commented 2 years ago

Hey there @bdraco, mind taking a look at this issue as it has been labeled with an integration (homekit) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

Bascht74 commented 2 years ago

Hi, I tried to add it anyway to homekit. But the "Home" App says that "This device is not supported by the Home-App" (message is in German, so maybe a little different in English). Could the missing device_class be the cause?

ollo69 commented 2 years ago

I don't know if this is the cause, but I can confirm that in AndroidTV integration device class is not defined. Define a class is very simply, but we don't have any information to understand if a device is a TV or a Receiver. It is correct to assume that any Android device connected through this integration is a TV?

Bascht74 commented 2 years ago

I don’t know, but the integration says AndroidTV so tv seemed to be right for me.

If the integration is not able to detect it, the user could be able to choose it.

Without this information other integrations cannot work as desired.

ollo69 commented 2 years ago

Because @bdraco is in this thread. I will wait for his opinion. No problem to create a PR to add device class if he think that this make sense.

JollyRgrs commented 2 years ago

You cannot assume that every device will be a TV. I use Chromecast with Google TV on all my TVs in the house. This is the dongle, which I connect via Android TV integration but it is not a TV itself. I am not sure if designating the device class as a TV would hurt anything or not, but I wanted to make it know that you cannot just assume that any device is an actual TV.

ollo69 commented 2 years ago

Because at this moment just exist 3 device class, all cast device (as Chromecast or FireTV) probably better match to DeviceClass TV than any others. At the end these devices just transform a classic TV to a Smart TV.

mouth4war commented 2 years ago

I used customize to set device class to TV, as a workaround. In homekit I see a power toggle and source selection but volume controls don't seem to work.

Bascht74 commented 2 years ago

I used customize to set device class to TV, as a workaround. In homekit I see a power toggle and source selection but volume controls don't seem to work.

could you give me your example, please?

Bascht74 commented 2 years ago

@ollo69 I read here: https://www.home-assistant.io/integrations/media_player/#device-class

... that we should be able to select the device class in the customize section. But I don't see this option.

Here I can change it: image

But for the anroidTV integration I don't see it: image

There is a reference blog entry: https://www.home-assistant.io/blog/2021/12/11/release-202112/

The customize.yaml UI (customization) has been removed. The YAML configuration for this is recommended and remains available. To customize entities, use the entity settings available via the icon in the top right of the entity “more info” dialog (when clicking on an entity). Entity settings now also allows customizing device_class for certain binary_sensor and cover cases.

So setting the device_class is right now not available for media_players... This path could be another way to solve this: Add "show as" to the media_player integration itself.

I am curios for @bdraco opinion.

Seb

mouth4war commented 2 years ago

I use the customize yaml with an entry for the Android tv entity.

Bascht74 commented 2 years ago

I use the customize yaml with an entry for the Android tv entity.

I tried that, but no success. Can you share you config entries for that?

SebastianLarsson commented 2 years ago

Can confirm doing this manually and not through GUI (where it is missing worked). Not all buttons work but the remote connects

configuration.yaml homeassistant: customize: !include customize.yaml

media_player.android_tv_your_device_name: device_class: tv

cheynespc commented 2 years ago

make a new universal media player and add the tv media player to the children list then after attributes set device_class: tv

This should work and just a wrapper for your existing media players

then in devices on ha make a new home kit

choose accessory and NOT Bridge

select the Universal media player

and to homekit that media player and u will get a new qr

scan to add accessories in homekit

tv will appear

VOLUME USE IPHONE UP/DOWN Buttons

hope this helps you all

im cheynespc on community home assistant Universal media player Homekit accessories mode

Bascht74 commented 2 years ago

Because @bdraco is in this thread. I will wait for his opinion. No problem to create a PR to add device class if he think that this make sense.

Because at this moment just exist 3 device class, all cast device (as Chromecast or FireTV) probably better match to DeviceClass TV than any others. At the end these devices just transform a classic TV to a Smart TV.

@bdraco I hope you can take a quick look after the holiday season... :-) Right now the official AndroidTV integration doesn't set a device_class so that you cannot use the created entity with your homkit integration. Before anything happens the code owners would like a short feedback from you :-) Another way could be to make the device_class (tv, speaker, receiver) customable in the entity dialog like with binary sensors (e.g. to set the device_class door / window / etc.). But I don't know who to ask nicely about this.

bdraco commented 2 years ago

It does look like tv is a reasonable device class for this based on https://www.android.com/tv/. Some of them may be headless but they still generally behave like a TV.

It would also be good to add customize support to the frontend for media_players as its expected that the device class may not always be perfect. As developers we can only accommodate the most likely use case.

Bascht74 commented 2 years ago

Because @bdraco is in this thread. I will wait for his opinion. No problem to create a PR to add device class if he think that this make sense.

@ollo69 Could you please create a PR for it?

Maybe later on somebody can add customization to the frondend for media_players. Before that everybody could use customize in rare usecases if tv is not working for them. For people that are using customize right now to add the device_class, nothing changes in my oppinion. So maybe this is not even a breaking change, only streamlining the usage of media players and homekit a little :-)

Bascht74 commented 2 years ago

Great thx!