mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
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:
parent
44b33d45b1
commit
d88040eeed
@ -17,7 +17,8 @@ from homeassistant.components.media_player import (
|
|||||||
SUPPORT_TURN_ON, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_STEP,
|
SUPPORT_TURN_ON, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_STEP,
|
||||||
MediaPlayerDevice)
|
MediaPlayerDevice)
|
||||||
from homeassistant.const import (
|
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
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
@ -153,11 +154,11 @@ class SamsungTVDevice(MediaPlayerDevice):
|
|||||||
BrokenPipeError):
|
BrokenPipeError):
|
||||||
# BrokenPipe can occur when the commands is sent to fast
|
# BrokenPipe can occur when the commands is sent to fast
|
||||||
self._remote = None
|
self._remote = None
|
||||||
self._state = None
|
self._state = STATE_ON
|
||||||
except (self._exceptions_class.UnhandledResponse,
|
except (self._exceptions_class.UnhandledResponse,
|
||||||
self._exceptions_class.AccessDenied):
|
self._exceptions_class.AccessDenied):
|
||||||
# We got a response so it's on.
|
# We got a response so it's on.
|
||||||
self._state = None
|
self._state = STATE_ON
|
||||||
self._remote = None
|
self._remote = None
|
||||||
_LOGGER.debug("Failed sending command %s", key, exc_info=True)
|
_LOGGER.debug("Failed sending command %s", key, exc_info=True)
|
||||||
return
|
return
|
||||||
|
@ -12,8 +12,8 @@ from homeassistant.components.media_player import SUPPORT_TURN_ON, \
|
|||||||
MEDIA_TYPE_CHANNEL, MEDIA_TYPE_URL
|
MEDIA_TYPE_CHANNEL, MEDIA_TYPE_URL
|
||||||
from homeassistant.components.media_player.samsungtv import setup_platform, \
|
from homeassistant.components.media_player.samsungtv import setup_platform, \
|
||||||
CONF_TIMEOUT, SamsungTVDevice, SUPPORT_SAMSUNGTV
|
CONF_TIMEOUT, SamsungTVDevice, SUPPORT_SAMSUNGTV
|
||||||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT, CONF_MAC, \
|
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT, STATE_ON, \
|
||||||
STATE_OFF
|
CONF_MAC, STATE_OFF
|
||||||
from tests.common import MockDependency
|
from tests.common import MockDependency
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
@ -103,7 +103,7 @@ class TestSamsungTv(unittest.TestCase):
|
|||||||
def test_update_on(self):
|
def test_update_on(self):
|
||||||
"""Testing update tv on."""
|
"""Testing update tv on."""
|
||||||
self.device.update()
|
self.device.update()
|
||||||
assert self.device._state is None
|
self.assertEqual(STATE_ON, self.device._state)
|
||||||
|
|
||||||
def test_update_off(self):
|
def test_update_off(self):
|
||||||
"""Testing update tv off."""
|
"""Testing update tv off."""
|
||||||
@ -117,7 +117,7 @@ class TestSamsungTv(unittest.TestCase):
|
|||||||
def test_send_key(self):
|
def test_send_key(self):
|
||||||
"""Test for send key."""
|
"""Test for send key."""
|
||||||
self.device.send_key('KEY_POWER')
|
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):
|
def test_send_key_broken_pipe(self):
|
||||||
"""Testing broken pipe Exception."""
|
"""Testing broken pipe Exception."""
|
||||||
@ -126,8 +126,8 @@ class TestSamsungTv(unittest.TestCase):
|
|||||||
side_effect=BrokenPipeError('Boom'))
|
side_effect=BrokenPipeError('Boom'))
|
||||||
self.device.get_remote = mock.Mock(return_value=_remote)
|
self.device.get_remote = mock.Mock(return_value=_remote)
|
||||||
self.device.send_key('HELLO')
|
self.device.send_key('HELLO')
|
||||||
assert self.device._remote is None
|
self.assertIsNone(self.device._remote)
|
||||||
assert self.device._state is None
|
self.assertEqual(STATE_ON, self.device._state)
|
||||||
|
|
||||||
def test_send_key_connection_closed_retry_succeed(self):
|
def test_send_key_connection_closed_retry_succeed(self):
|
||||||
"""Test retry on connection closed."""
|
"""Test retry on connection closed."""
|
||||||
@ -138,7 +138,7 @@ class TestSamsungTv(unittest.TestCase):
|
|||||||
self.device.get_remote = mock.Mock(return_value=_remote)
|
self.device.get_remote = mock.Mock(return_value=_remote)
|
||||||
command = 'HELLO'
|
command = 'HELLO'
|
||||||
self.device.send_key(command)
|
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
|
# verify that _remote.control() get called twice because of retry logic
|
||||||
expected = [mock.call(command),
|
expected = [mock.call(command),
|
||||||
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.get_remote = mock.Mock(return_value=_remote)
|
||||||
self.device.send_key('HELLO')
|
self.device.send_key('HELLO')
|
||||||
assert self.device._remote is None
|
self.assertIsNone(self.device._remote)
|
||||||
assert self.device._state is None
|
self.assertEqual(STATE_ON, self.device._state)
|
||||||
|
|
||||||
def test_send_key_os_error(self):
|
def test_send_key_os_error(self):
|
||||||
"""Testing broken pipe Exception."""
|
"""Testing broken pipe Exception."""
|
||||||
@ -178,8 +178,8 @@ class TestSamsungTv(unittest.TestCase):
|
|||||||
|
|
||||||
def test_state(self):
|
def test_state(self):
|
||||||
"""Test for state property."""
|
"""Test for state property."""
|
||||||
self.device._state = None
|
self.device._state = STATE_ON
|
||||||
assert self.device.state is None
|
self.assertEqual(STATE_ON, self.device.state)
|
||||||
self.device._state = STATE_OFF
|
self.device._state = STATE_OFF
|
||||||
assert STATE_OFF == self.device.state
|
assert STATE_OFF == self.device.state
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user