Adding device_class to samsungtv (#28168)

* Adding device_id to samsungtv

* Lint

* Adding test
This commit is contained in:
kennedyshead 2019-10-24 22:41:07 +02:00 committed by Paulus Schoutsen
parent c96d4c978d
commit 98ac8a217d
2 changed files with 15 additions and 1 deletions

View File

@ -6,7 +6,11 @@ import socket
import voluptuous as vol
from homeassistant.components.media_player import MediaPlayerDevice, PLATFORM_SCHEMA
from homeassistant.components.media_player import (
MediaPlayerDevice,
PLATFORM_SCHEMA,
DEVICE_CLASS_TV,
)
from homeassistant.components.media_player.const import (
MEDIA_TYPE_CHANNEL,
SUPPORT_NEXT_TRACK,
@ -227,6 +231,11 @@ class SamsungTVDevice(MediaPlayerDevice):
return SUPPORT_SAMSUNGTV | SUPPORT_TURN_ON
return SUPPORT_SAMSUNGTV
@property
def device_class(self):
"""Set the device class to TV."""
return DEVICE_CLASS_TV
def turn_off(self):
"""Turn off media player."""
self._end_of_power_off = dt_util.utcnow() + timedelta(seconds=15)

View File

@ -8,6 +8,7 @@ from asynctest import mock
import pytest
import tests.common
from homeassistant.components.media_player import DEVICE_CLASS_TV
from homeassistant.components.media_player.const import (
SUPPORT_TURN_ON,
MEDIA_TYPE_CHANNEL,
@ -197,6 +198,10 @@ class TestSamsungTv(unittest.TestCase):
self.device._mac = "fake"
assert SUPPORT_SAMSUNGTV | SUPPORT_TURN_ON == self.device.supported_features
def test_device_class(self):
"""Test for device_class property."""
assert DEVICE_CLASS_TV == self.device.device_class
def test_turn_off(self):
"""Test for turn_off."""
self.device.send_key = mock.Mock()