StevenLooman / home-assistant-dlna-dmr

DLNA/DMR component for home-assistant
Other
14 stars 1 forks source link

Firing service call throws errors #1

Closed acateon closed 6 years ago

acateon commented 7 years ago

First of all, great initiative!

My TV gets registered with the new media player platform and shows the following.

`

media_player.unnamed_device idle volume_level: 0.2 is_volume_muted: false media_duration: 0 friendly_name: HITACHI TV supported_features: 12

`

But when I fire a service call to turn it off it throws the following errors:


2017-08-02 17:39:47 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 181, in _step
    result = coro.throw(exc)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/core.py", line 1025, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 409, in async_service_handler
    yield from getattr(player, method['method'])(**params)
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 331, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 244, in _wakeup
    future.result()
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 244, in result
    raise self._exception
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 610, in turn_off
    raise NotImplementedError()
NotImplementedError
2017-08-02 17:39:55 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 181, in _step
    result = coro.throw(exc)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/core.py", line 1025, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 409, in async_service_handler
    yield from getattr(player, method['method'])(**params)
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 331, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 244, in _wakeup
    future.result()
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 244, in result
    raise self._exception
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 610, in turn_off
    raise NotImplementedError()
NotImplementedError```
StevenLooman commented 7 years ago

The turn off button shouldn't be there at all, as the DLNA DMR spec doesn't support this call.

Did other controls work, though, like previous/next/pause/volume/...?

acateon commented 7 years ago

Nope... Volume shows up but does not work, no play/pause etc show, neither any playing info.

Included a zip with all the xml's while playing audio.

DMR.zip

StevenLooman commented 7 years ago

Sorry for the late reply. Thank you for sending the XMLs. This is a first step of troubleshooting.

I need a bit more information though. The XMLs seem to be ok/the device should work. However, it is strange that you're seeing supported_features: 12.

Can you change alter the DlnaDmrDevice.supported_features() method by replacing it with this:

    @property
    def supported_features(self):
        """Flag media player features that are supported."""
        supported_features = 0

        if not self._device:
            return supported_features

        rc_service = self._service('RC')
        if rc_service:
            if rc_service.state_variable('Mute'):
                supported_features |= SUPPORT_VOLUME_MUTE
            if rc_service.state_variable('Volume'):
                supported_features |= SUPPORT_VOLUME_SET

        avt_service = self._service('AVT')
        if avt_service:
            state_var = avt_service.state_variable('CurrentTransportActions')
            _LOGGER.debug('%s.supported_features(): %s: %s', self, state_var, state_var.value if state_var else "xxx")
            if state_var:
                value = state_var.value or ''
                actions = value.split(',')
                if 'Play' in actions:
                    supported_features |= SUPPORT_PLAY
                if 'Stop' in actions:
                    supported_features |= SUPPORT_STOP
                if 'Pause' in actions:
                    supported_features |= SUPPORT_PAUSE

            current_track_var = avt_service.state_variable('CurrentTrack')
            num_tracks_var = avt_service.state_variable('NumberOfTracks')
            if current_track_var and num_tracks_var and \
               current_track_var.value is not None and num_tracks_var.value is not None:
                current_track = current_track_var.value
                num_tracks = num_tracks_var.value
                if current_track > 1:
                    supported_features |= SUPPORT_PREVIOUS_TRACK

                if num_tracks > current_track:
                    supported_features |= SUPPORT_NEXT_TRACK

        return supported_features

Actually, the line which starts with _LOGGER.debug() is the only one you need to add.

Then, in your ~/.homeassistant/configuration.yaml add this:

logger:
  default: info
  logs:
    custom_components.media_player.dlna_dmr: debug
    custom_components.media_player.upnp_client: debug

This should give debugging information, which in turn might help finding the problem.

Also, can you try playing something with a UPnP client, such as the app BubbleUPnP.

Again, sorry for the late reply.

StevenLooman commented 6 years ago

This component is now integrated into home assistant itself. You should use that instead. Netdisco/discovery will discover the device for you without any manual configuration.

Still, you still have to enable discovery of it explicitly. You can do this by opting-in discovery of dlna_dmr devices, like so in your config:

discovery:
  enable:
    - dlna_dmr