mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 01:38:02 +00:00
avoid key errors
This commit is contained in:
parent
ad549be353
commit
6afb846d04
@ -287,8 +287,8 @@ def setup(hass, config):
|
||||
|
||||
def play_media_service(service):
|
||||
""" Plays specified media_id on the media player. """
|
||||
media_type = service.data['media_type']
|
||||
media_id = service.data['media_id']
|
||||
media_type = service.data.get('media_type')
|
||||
media_id = service.data.get('media_id')
|
||||
|
||||
if media_type is None:
|
||||
return
|
||||
|
@ -63,7 +63,8 @@ def reproduce_state(hass, states, blocking=False):
|
||||
service = SERVICE_MEDIA_PAUSE
|
||||
elif state.domain == 'media_player' and state.state == STATE_PLAYING:
|
||||
service = SERVICE_MEDIA_PLAY
|
||||
elif state.domain == 'media_player' and state.attributes and state.attributes['media_type'] and state.attributes['media_id']:
|
||||
elif state.domain == 'media_player' and state.attributes and
|
||||
'media_type' in state.attributes and 'media_id' in state.attributes
|
||||
service = SERVICE_PLAY_MEDIA
|
||||
elif state.state == STATE_ON:
|
||||
service = SERVICE_TURN_ON
|
||||
|
Loading…
x
Reference in New Issue
Block a user