Add device class for roku devices (#39627)

* add tv device class for roku tvs

* Update test_media_player.py

* Update test_media_player.py

* Update media_player.py

* Update test_media_player.py

* Update media_player.py

* Update test_media_player.py

* Update test_media_player.py

* Update media_player.py
pull/39632/head
Chris Talkington 2020-09-03 16:06:24 -05:00 committed by GitHub
parent a87fedc0af
commit 77f5fb765b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View File

@ -1,10 +1,14 @@
"""Support for the Roku media player."""
import logging
from typing import List
from typing import List, Optional
import voluptuous as vol
from homeassistant.components.media_player import MediaPlayerEntity
from homeassistant.components.media_player import (
DEVICE_CLASS_RECEIVER,
DEVICE_CLASS_TV,
MediaPlayerEntity,
)
from homeassistant.components.media_player.const import (
MEDIA_TYPE_APP,
MEDIA_TYPE_CHANNEL,
@ -90,6 +94,14 @@ class RokuMediaPlayer(RokuEntity, MediaPlayerEntity):
"""Return the unique ID for this entity."""
return self._unique_id
@property
def device_class(self) -> Optional[str]:
"""Return the class of this device."""
if self.coordinator.data.info.device_type == "tv":
return DEVICE_CLASS_TV
return DEVICE_CLASS_RECEIVER
@property
def state(self) -> str:
"""Return the state of the device."""

View File

@ -3,6 +3,7 @@ from datetime import timedelta
from rokuecp import RokuError
from homeassistant.components.media_player import DEVICE_CLASS_RECEIVER, DEVICE_CLASS_TV
from homeassistant.components.media_player.const import (
ATTR_APP_ID,
ATTR_APP_NAME,
@ -77,6 +78,7 @@ async def test_setup(
assert hass.states.get(MAIN_ENTITY_ID)
assert main
assert main.device_class == DEVICE_CLASS_RECEIVER
assert main.unique_id == UPNP_SERIAL
@ -108,6 +110,7 @@ async def test_tv_setup(
assert hass.states.get(TV_ENTITY_ID)
assert tv
assert tv.device_class == DEVICE_CLASS_TV
assert tv.unique_id == TV_SERIAL