Add device class to directv devices (#39628)

* add device class to directv devices

* Update test_media_player.py

* Update media_player.py

* Update test_media_player.py

* Update media_player.py
This commit is contained in:
Chris Talkington 2020-09-03 16:27:13 -05:00 committed by GitHub
parent d0120d5e0a
commit f6a3eea7f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View file

@ -1,10 +1,13 @@
"""Support for the DirecTV receivers."""
import logging
from typing import Callable, List
from typing import Callable, List, Optional
from directv import DIRECTV
from homeassistant.components.media_player import MediaPlayerEntity
from homeassistant.components.media_player import (
DEVICE_CLASS_RECEIVER,
MediaPlayerEntity,
)
from homeassistant.components.media_player.const import (
MEDIA_TYPE_CHANNEL,
MEDIA_TYPE_MOVIE,
@ -137,6 +140,11 @@ class DIRECTVMediaPlayer(DIRECTVEntity, MediaPlayerEntity):
"""Return the name of the device."""
return self._name
@property
def device_class(self) -> Optional[str]:
"""Return the class of this device."""
return DEVICE_CLASS_RECEIVER
@property
def unique_id(self):
"""Return a unique ID to use for this media player."""

View file

@ -10,6 +10,7 @@ from homeassistant.components.directv.media_player import (
ATTR_MEDIA_RECORDED,
ATTR_MEDIA_START_TIME,
)
from homeassistant.components.media_player import DEVICE_CLASS_RECEIVER
from homeassistant.components.media_player.const import (
ATTR_INPUT_SOURCE,
ATTR_MEDIA_ALBUM_NAME,
@ -169,12 +170,15 @@ async def test_unique_id(
entity_registry = await hass.helpers.entity_registry.async_get_registry()
main = entity_registry.async_get(MAIN_ENTITY_ID)
assert main.device_class == DEVICE_CLASS_RECEIVER
assert main.unique_id == "028877455858"
client = entity_registry.async_get(CLIENT_ENTITY_ID)
assert client.device_class == DEVICE_CLASS_RECEIVER
assert client.unique_id == "2CA17D1CD30X"
unavailable_client = entity_registry.async_get(UNAVAILABLE_ENTITY_ID)
assert unavailable_client.device_class == DEVICE_CLASS_RECEIVER
assert unavailable_client.unique_id == "9XXXXXXXXXX9"