mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Removed property from universal media player
The active_child_state property was unnecessary as it was not being referenced outside the class. This commit removes it and updates the tests accordingly.
This commit is contained in:
parent
769f5aafb7
commit
12da6f531e
@ -171,7 +171,7 @@ class UniversalMediaPlayer(MediaPlayerDevice):
|
||||
|
||||
def _child_attr(self, attr_name):
|
||||
""" returns the active child's attr """
|
||||
active_child = self.active_child_state
|
||||
active_child = self._child_state
|
||||
return active_child.attributes.get(attr_name) if active_child else None
|
||||
|
||||
def _call_service(self, service_name, service_data=None,
|
||||
@ -185,7 +185,7 @@ class UniversalMediaPlayer(MediaPlayerDevice):
|
||||
if service_data is None:
|
||||
service_data = {}
|
||||
|
||||
active_child = self.active_child_state
|
||||
active_child = self._child_state
|
||||
service_data[ATTR_ENTITY_ID] = active_child.entity_id
|
||||
|
||||
self.hass.services.call(DOMAIN, service_name, service_data,
|
||||
@ -222,11 +222,6 @@ class UniversalMediaPlayer(MediaPlayerDevice):
|
||||
return
|
||||
self._child_state = None
|
||||
|
||||
@property
|
||||
def active_child_state(self):
|
||||
""" the state of the active child or none """
|
||||
return self._child_state
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
""" name of universal player """
|
||||
@ -245,7 +240,7 @@ class UniversalMediaPlayer(MediaPlayerDevice):
|
||||
if master_state == STATE_OFF:
|
||||
return STATE_OFF
|
||||
|
||||
active_child = self.active_child_state
|
||||
active_child = self._child_state
|
||||
if active_child:
|
||||
return active_child.state
|
||||
|
||||
@ -366,7 +361,7 @@ class UniversalMediaPlayer(MediaPlayerDevice):
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
""" Extra attributes a device wants to expose. """
|
||||
active_child = self.active_child_state
|
||||
active_child = self._child_state
|
||||
return {ATTR_ACTIVE_CHILD: active_child.entity_id} \
|
||||
if active_child else {}
|
||||
|
||||
|
@ -193,25 +193,25 @@ class TestMediaPlayer(unittest.TestCase):
|
||||
ump.entity_id = media_player.ENTITY_ID_FORMAT.format(config['name'])
|
||||
ump.update_state()
|
||||
|
||||
self.assertEqual(None, ump.active_child_state)
|
||||
self.assertEqual(None, ump._child_state)
|
||||
|
||||
self.mock_mp_1._state = STATE_PLAYING
|
||||
self.mock_mp_1.update_ha_state()
|
||||
ump.update_state()
|
||||
self.assertEqual(self.mock_mp_1.entity_id,
|
||||
ump.active_child_state.entity_id)
|
||||
ump._child_state.entity_id)
|
||||
|
||||
self.mock_mp_2._state = STATE_PLAYING
|
||||
self.mock_mp_2.update_ha_state()
|
||||
ump.update_state()
|
||||
self.assertEqual(self.mock_mp_1.entity_id,
|
||||
ump.active_child_state.entity_id)
|
||||
ump._child_state.entity_id)
|
||||
|
||||
self.mock_mp_1._state = STATE_OFF
|
||||
self.mock_mp_1.update_ha_state()
|
||||
ump.update_state()
|
||||
self.assertEqual(self.mock_mp_2.entity_id,
|
||||
ump.active_child_state.entity_id)
|
||||
ump._child_state.entity_id)
|
||||
|
||||
def test_name(self):
|
||||
""" test name property """
|
||||
|
Loading…
x
Reference in New Issue
Block a user