mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 14:27:07 +00:00
Fix universal mp service call wth no child (#5411)
This commit is contained in:
parent
2a362fd1ff
commit
eb06023aa5
@ -190,6 +190,10 @@ class UniversalMediaPlayer(MediaPlayerDevice):
|
||||
return
|
||||
|
||||
active_child = self._child_state
|
||||
if active_child is None:
|
||||
# No child to call service on
|
||||
return
|
||||
|
||||
service_data[ATTR_ENTITY_ID] = active_child.entity_id
|
||||
|
||||
self.hass.services.call(DOMAIN, service_name, service_data,
|
||||
|
@ -538,6 +538,25 @@ class TestMediaPlayer(unittest.TestCase):
|
||||
|
||||
self.assertEqual(check_flags, ump.supported_media_commands)
|
||||
|
||||
def test_service_call_no_active_child(self):
|
||||
"""Test a service call to children with no active child."""
|
||||
config = self.config_children_only
|
||||
universal.validate_config(config)
|
||||
|
||||
ump = universal.UniversalMediaPlayer(self.hass, **config)
|
||||
ump.entity_id = media_player.ENTITY_ID_FORMAT.format(config['name'])
|
||||
ump.update()
|
||||
|
||||
self.mock_mp_1._state = STATE_OFF
|
||||
self.mock_mp_1.update_ha_state()
|
||||
self.mock_mp_2._state = STATE_OFF
|
||||
self.mock_mp_2.update_ha_state()
|
||||
ump.update()
|
||||
|
||||
ump.turn_off()
|
||||
self.assertEqual(0, len(self.mock_mp_1.service_calls['turn_off']))
|
||||
self.assertEqual(0, len(self.mock_mp_2.service_calls['turn_off']))
|
||||
|
||||
def test_service_call_to_child(self):
|
||||
"""Test service calls that should be routed to a child."""
|
||||
config = self.config_children_only
|
||||
|
Loading…
x
Reference in New Issue
Block a user