Removed dependencies property from universal media player

The dependencies property was only being called once by the __init__
method so it was removed and the code was moved to the __init__ method.
The tests were updated to reflect this.
This commit is contained in:
Ryan Kraus 2016-01-12 20:50:28 -05:00 committed by Paulus Schoutsen
parent 12da6f531e
commit 07953fb7e3
2 changed files with 5 additions and 26 deletions

View File

@ -146,7 +146,11 @@ class UniversalMediaPlayer(MediaPlayerDevice):
self._attrs = attributes
self._child_state = None
track_state_change(hass, self.dependencies, self.update_state)
depend = copy(children)
for entity in attributes.values():
depend.append(entity[0])
track_state_change(hass, depend, self.update_state)
def _entity_lkp(self, entity_id=None, state_attr=None):
""" Looks up an entity state from hass """
@ -196,14 +200,6 @@ class UniversalMediaPlayer(MediaPlayerDevice):
""" Indicates whether HA should poll for updates """
return False
@property
def dependencies(self):
""" List of entity ids of entities that the mp depends on for state """
depend = copy(self._children)
for entity in self._attrs.values():
depend.append(entity[0])
return depend
@property
def master_state(self):
""" gets the master state from entity or none """

View File

@ -135,23 +135,6 @@ class TestMediaPlayer(unittest.TestCase):
self.assertTrue(response)
self.assertEqual(config_start, self.config_children_and_attr)
def test_dependencies(self):
""" test dependencies property """
config = self.config_children_and_attr
universal.validate_config(config)
ump = universal.UniversalMediaPlayer(self.hass, **config)
depend = ump.dependencies
depend.sort()
check_depend = [media_player.ENTITY_ID_FORMAT.format('mock1'),
media_player.ENTITY_ID_FORMAT.format('mock2'),
self.mock_mute_switch_id, self.mock_state_switch_id]
check_depend.sort()
self.assertEqual(depend, check_depend)
def test_master_state(self):
""" test master state property """
config = self.config_children_only