Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

media_player on/off services do not consider supported features of platform #22877

Closed
andrewsayre opened this issue Apr 8, 2019 · 0 comments · Fixed by #22878
Closed

media_player on/off services do not consider supported features of platform #22877

andrewsayre opened this issue Apr 8, 2019 · 0 comments · Fixed by #22878
Assignees

Comments

@andrewsayre
Copy link
Member

andrewsayre commented Apr 8, 2019

Home Assistant release with the issue: 0.91.0

Last working Home Assistant release (if known): None

Operating environment (Hass.io/Docker/Windows/etc.): Docker and venv

Component/platform: media_player

Description of problem:
When invoking the service media_player.turn_on and passing an entity_id: all, platforms that do not support turn_on will raise a NotImplementedError in the logs. This is also true of media_player.turn_off.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

# Anywhere the service is called, such as an animation action:
  action:
  - data:
      entity_id: all
    service: media_player.turn_off

Traceback (if applicable):

Error while executing automation automation.turn_off_devices_when_no_one_is_home. Unknown error for call_service at pos 3: 
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/components/automation/__init__.py", line 380, in action
    await script_obj.async_run(variables, context)
  File "/usr/src/app/homeassistant/helpers/script.py", line 131, in async_run
    await self._handle_action(action, variables, context)
  File "/usr/src/app/homeassistant/helpers/script.py", line 210, in _handle_action
    action, variables, context)
  File "/usr/src/app/homeassistant/helpers/script.py", line 299, in _async_call_service
    context=context
  File "/usr/src/app/homeassistant/helpers/service.py", line 88, in async_call_from_config
    domain, service_name, service_data, blocking=blocking, context=context)
  File "/usr/src/app/homeassistant/core.py", line 1138, in async_call
    self._execute_service(handler, service_call))
  File "/usr/src/app/homeassistant/core.py", line 1160, in _execute_service
    await handler.func(service_call)
  File "/usr/src/app/homeassistant/helpers/entity_component.py", line 188, in handle_service
    self._platforms.values(), func, call, service_name
  File "/usr/src/app/homeassistant/helpers/service.py", line 314, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/app/homeassistant/helpers/service.py", line 328, in _handle_service_platform_call
    await getattr(entity, func)(**data)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/helpers/entity.py", line 477, in turn_off
    raise NotImplementedError()
NotImplementedError

Additional information:
Platforms of the media_player component do not have to support turn_on and turn_off as not all devices have these capabilities (i.e. Roku). Support for these services are reflected in the state attribute supported_features represented by the constants SUPPORT_TURN_ON and SUPPORT_TURN_OFF.

Services should consider supported_features and only raise NotImplementedError if support was indicated and the method was not implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant