Revert changes that broke UI (#18495)

* Revert changes that broke UI

* Change from UNKNOWN to None

* Remove STATE_UNKNOWN import
This commit is contained in:
dapowers87 2018-11-20 06:29:05 -06:00 committed by Paulus Schoutsen
parent 44b33d45b1
commit d88040eeed
2 changed files with 15 additions and 14 deletions

View File

@ -17,7 +17,8 @@ from homeassistant.components.media_player import (
SUPPORT_TURN_ON, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_STEP,
MediaPlayerDevice)
from homeassistant.const import (
CONF_HOST, CONF_MAC, CONF_NAME, CONF_PORT, CONF_TIMEOUT, STATE_OFF)
CONF_HOST, CONF_MAC, CONF_NAME, CONF_PORT, CONF_TIMEOUT, STATE_OFF,
STATE_ON)
import homeassistant.helpers.config_validation as cv
from homeassistant.util import dt as dt_util
@ -153,11 +154,11 @@ class SamsungTVDevice(MediaPlayerDevice):
BrokenPipeError):
# BrokenPipe can occur when the commands is sent to fast
self._remote = None
self._state = None
self._state = STATE_ON
except (self._exceptions_class.UnhandledResponse,
self._exceptions_class.AccessDenied):
# We got a response so it's on.
self._state = None
self._state = STATE_ON
self._remote = None
_LOGGER.debug("Failed sending command %s", key, exc_info=True)
return

View File

@ -12,8 +12,8 @@ from homeassistant.components.media_player import SUPPORT_TURN_ON, \
MEDIA_TYPE_CHANNEL, MEDIA_TYPE_URL
from homeassistant.components.media_player.samsungtv import setup_platform, \
CONF_TIMEOUT, SamsungTVDevice, SUPPORT_SAMSUNGTV
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT, CONF_MAC, \
STATE_OFF
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT, STATE_ON, \
CONF_MAC, STATE_OFF
from tests.common import MockDependency
from homeassistant.util import dt as dt_util
from datetime import timedelta
@ -103,7 +103,7 @@ class TestSamsungTv(unittest.TestCase):
def test_update_on(self):
"""Testing update tv on."""
self.device.update()
assert self.device._state is None
self.assertEqual(STATE_ON, self.device._state)
def test_update_off(self):
"""Testing update tv off."""
@ -117,7 +117,7 @@ class TestSamsungTv(unittest.TestCase):
def test_send_key(self):
"""Test for send key."""
self.device.send_key('KEY_POWER')
assert self.device._state is None
self.assertEqual(STATE_ON, self.device._state)
def test_send_key_broken_pipe(self):
"""Testing broken pipe Exception."""
@ -126,8 +126,8 @@ class TestSamsungTv(unittest.TestCase):
side_effect=BrokenPipeError('Boom'))
self.device.get_remote = mock.Mock(return_value=_remote)
self.device.send_key('HELLO')
assert self.device._remote is None
assert self.device._state is None
self.assertIsNone(self.device._remote)
self.assertEqual(STATE_ON, self.device._state)
def test_send_key_connection_closed_retry_succeed(self):
"""Test retry on connection closed."""
@ -138,7 +138,7 @@ class TestSamsungTv(unittest.TestCase):
self.device.get_remote = mock.Mock(return_value=_remote)
command = 'HELLO'
self.device.send_key(command)
assert self.device._state is None
self.assertEqual(STATE_ON, self.device._state)
# verify that _remote.control() get called twice because of retry logic
expected = [mock.call(command),
mock.call(command)]
@ -152,8 +152,8 @@ class TestSamsungTv(unittest.TestCase):
)
self.device.get_remote = mock.Mock(return_value=_remote)
self.device.send_key('HELLO')
assert self.device._remote is None
assert self.device._state is None
self.assertIsNone(self.device._remote)
self.assertEqual(STATE_ON, self.device._state)
def test_send_key_os_error(self):
"""Testing broken pipe Exception."""
@ -178,8 +178,8 @@ class TestSamsungTv(unittest.TestCase):
def test_state(self):
"""Test for state property."""
self.device._state = None
assert self.device.state is None
self.device._state = STATE_ON
self.assertEqual(STATE_ON, self.device.state)
self.device._state = STATE_OFF
assert STATE_OFF == self.device.state