StevenLooman / home-assistant-dlna-dmr

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

integrating dlna player #13

Closed tennbaum closed 3 years ago

tennbaum commented 3 years ago

hey all / Steven Im new to Home assistant and was wondering is it possible to configure this module to control some generic DLNA player?

currently im using jriver on a number of computers to play music around my house. controlling it from my windows computer or my phone trough its own app is easy and simple - choose the right player, the song or playlist, and boom... works like a charm. is there any way of implementing that into home assistant panel? even just the basics like "play\pause" ?

any help will be gr8, just please elaborate as your patience will let you... :)

cheers

StevenLooman commented 3 years ago

Hey @tennbaum

Thank you for this issue. This component is already integrated in Home Assistant, so you'll only need to configure it. See https://www.home-assistant.io/integrations/dlna_dmr/ for options.

At this moment is has been disabled by default for discovery. If you with to enable discovery of this component you'll need to enable discovery, see https://www.home-assistant.io/integrations/discovery/#enable. You'll want to add something like this to your configuration.yaml file:

discovery:
  enable:
  - dlna_dmr

It has been disabled as many devices already have their own device-specific component while also being DLNA/DMR compatible. This resulted in multiple integrations being found for the same device. To not cause any confusion dicovery of dlna_dmr devices is disabled by default.

If you have any further questions feel free to reply here.

tennbaum commented 3 years ago

Untitled hey man

thanks for your replay i'd love some more hekp if possible. i added the discovery - and i get error when i check my configuration.yaml (though while writing to the file i can see the green V symbol that make you think all is ok...

when i add the url host to one of my jriver installation - it does not recognise any "new entity" of media. any help will be appreciated

i added my YAML file - maybe it will give you some more clues...

StevenLooman commented 3 years ago

By the looks of it, you need to add a - before dlna_dmr, like so:

discovery:
  enable:
    - dlna_dmr

Also, by looking at the dots before dlna_dmr, you need to add another space before it (4 spaces instead of 3.)

tennbaum commented 3 years ago

gotcha! thanks now i get all the different media players discovered as new entities - yey! however, i get an error trying to toggle play\pause button on the "jriver" side of the software, though the volume slider works fine. any idea?

StevenLooman commented 3 years ago

Can you provide the logging for this error, including a few message before and after the error? Only the messages regarding homeassistant.components.upnp and async_upnp_client are relevant. You'll see those terms near the beginning of the line.

tennbaum commented 3 years ago

i cleared the log, and than tried the "call command" under "developer tools". it generated this errors: Untitled

and i copied the one from "jriver" - hope that you ment, and that it helps you to help me :) (if not, just give me instructions better suited for dummies...)

Logger: homeassistant.components.websocket_api.http.connection Source: components/dlna_dmr/media_player.py:318 Integration: Home Assistant WebSocket API (documentation https://www.home-assistant.io/integrations/websocket_api, issues https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+websocket_api%22 ) First occurred: 10:53:08 AM (1 occurrences) Last logged: 10:53:08 AM [139674863656816] 'JRiverSyncPlayTime'

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 135, in handle_call_service await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 1445, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1480, in _execute_service await handler.job.target(service_call) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service await self.hass.helpers.service.entity_service_call( File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 593, in entity_service_call future.result() # pop exception if have File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 664, in async_request_call await coro File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 630, in _handle_entity_call await result File "/usr/src/homeassistant/homeassistant/components/dlna_dmr/media_player.py", line 105, in wrapper return await func(self, *args, kwargs) File "/usr/src/homeassistant/homeassistant/components/dlna_dmr/media_player.py", line 318, in async_media_play await self._device.async_play() File "/usr/local/lib/python3.8/site-packages/async_upnp_client/profiles/dlna.py", line 478, in async_play await action.async_call(InstanceID=0, Speed='1') File "/usr/local/lib/python3.8/site-packages/async_upnp_client/client.py", line 512, in async_call url, headers, body = self.create_request(kwargs) File "/usr/local/lib/python3.8/site-packages/async_upnp_client/client.py", line 535, in create_request soap_args = self._format_request_args(kwargs) File "/usr/local/lib/python3.8/site-packages/async_upnp_client/client.py", line 558, in _format_request_args self.validate_arguments(kwargs) File "/usr/local/lib/python3.8/site-packages/async_upnp_client/client.py", line 486, in validate_arguments value = kwargs[arg.name] KeyError: 'JRiverSyncPlayTime'

On Thu, Dec 17, 2020 at 11:05 PM Steven Looman notifications@github.com wrote:

Can you provide the logging for this error, including a few message before and after the error? Only the messages regarding homeassistant.components.upnp and async_upnp_client are relevant. You'll see those terms near the beginning of the line.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/StevenLooman/home-assistant-dlna-dmr/issues/13#issuecomment-747701340, or unsubscribe https://github.com/notifications/unsubscribe-auth/AR2EGZI6QSC6NRGH23K4JBLSVJXBFANCNFSM4UQQWMOQ .

StevenLooman commented 3 years ago

Thank you for providing the error and the traceback.

I'm a bit surprised to see JRiverSyncPlayTime in the error. From the source files and line numbers I see that you're sending a play/resume command, is this correct?. Normally this should result in a command named Play with (at least) one argument (InstanceId, visible in the traceback at file dlna.py/line 478.

We need to investigate a bit more. You'll have to enable additional logging by adding the following to your configuration, see also the logger component:

logger:
  default: info
  logs:
    homeassistant.components.dlna_dmr: debug
    async_upnp_client: debug
    async_upnp_client.traffic: info

After you have done this, you'll see lots of additional logging, but don't be alarmed. The relevant logging includes either the term dlna_dmr or async_upnp_client. You should see some initialization lines. Some of these lines should include a URL, looking something like this: http://192.168.178.19:1400/xml/device_description.xml. This is just an example from one of my devices, yours will look differently, the IP will be different, as well as the port and the path.

Can you scan your logs for one of these lines, try to find the URL, download it and post it here?

tennbaum commented 3 years ago

hi steven

i added the logger command to the yaml file, made sure that the syntax was good and valid and restarted the server. now im not really sure about where to look for the extra logging info to send you. could you please be more specific as to what and where to look for? sorry for making this harder than you intended

StevenLooman commented 3 years ago

No problem. You'll be looking for lines which look like this:

2020-12-26 13:58:08 INFO (MainThread) [homeassistant.components.discovery] Found new service: dlna_dmr {'host': '192.168.178.19', 'port': 1400, 'ssdp_description': 'http://192.168.178.19:1400/xml/device_description.xml', 'name': '192.168.178.19 - Sonos SYMFONISK', 'model_name': 'Sonos SYMFONISK', 'model_number': 'S21', 'serial': None, 'manufacturer': 'Sonos, Inc.', 'udn': 'uuid:RINCON_347E5C3608F001400', 'upnp_device_type': 'urn:schemas-upnp-org:device:ZonePlayer:1'}
2020-12-26 13:58:08 INFO (MainThread) [homeassistant.setup] Setting up media_player
2020-12-26 13:58:08 INFO (MainThread) [homeassistant.setup] Setup of domain media_player took 0.0 seconds
2020-12-26 13:58:08 INFO (SyncWorker_2) [homeassistant.loader] Loaded dlna_dmr from homeassistant.components.dlna_dmr
2020-12-26 13:58:08 INFO (MainThread) [homeassistant.components.media_player] Setting up media_player.dlna_dmr
2020-12-26 13:58:08 INFO (MainThread) [homeassistant.components.dlna_dmr.media_player] UPNP/DLNA event handler listening, url: http://192.168.178.72:8301/notify
2020-12-26 13:58:08 DEBUG (MainThread) [homeassistant.components.dlna_dmr.media_player] Adding device: <Entity 192.168.178.19 - Sonos SYMFONISK: off>
2020-12-26 13:58:08 DEBUG (MainThread) [async_upnp_client.profiles.profile] Subscribing to service: <UpnpService(urn:upnp-org:serviceId:RenderingControl, uuid:RINCON_347E5C3608F001400)>
2020-12-26 13:58:08 DEBUG (MainThread) [async_upnp_client.event_handler] Subscribing to: <UpnpService(urn:upnp-org:serviceId:RenderingControl, uuid:RINCON_347E5C3608F001400)>, callback URL: http://192.168.178.72:8301/notify
2020-12-26 13:58:08 DEBUG (MainThread) [async_upnp_client.event_handler] Got SID: uuid:RINCON_347E5C3608F001400_sub0000001852, renewal_time: 2020-12-26 14:07:08.701709
2020-12-26 13:58:08 DEBUG (MainThread) [async_upnp_client.profiles.profile] Subscribing to service: <UpnpService(urn:upnp-org:serviceId:AVTransport, uuid:RINCON_347E5C3608F001400)>
2020-12-26 13:58:08 DEBUG (MainThread) [async_upnp_client.event_handler] Subscribing to: <UpnpService(urn:upnp-org:serviceId:AVTransport, uuid:RINCON_347E5C3608F001400)>, callback URL: http://192.168.178.72:8301/notify
2020-12-26 13:58:08 DEBUG (MainThread) [async_upnp_client.aiohttp] Received request: <BaseRequest NOTIFY /notify >

Now that I'm looking at it, the first line is the one we're looking for, there you can see the property ssdp_description with a URL.

tennbaum commented 3 years ago

I think i am missing something, or not fully understand where this "extended" log needs to be.

so far, this is what i thought i need to do:

  1. clear logs (so it will be easier to find the right log)
  2. generate the error, by trying to send the command to the j-river from the lovelace interface, with a "media player" card i added
  3. go to the "logs" under "configuration", and find the correct log.
  4. copy that log and post it.

unfortunately, when i do that. i thing that it generate the same log i have posted b4. i add a pics. 1 - the log that was generated 1

when i go into that, i get this:


Logger: homeassistant.components.websocket_api.http.connection Source: components/dlna_dmr/media_player.py:318 Integration: Home Assistant WebSocket API (documentation, issues) First occurred: 9:48:21 AM (1 occurrences) Last logged: 9:48:21 AM

[140673059362272] 'JRiverSyncPlayTime' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 135, in handle_call_service await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 1445, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1480, in _execute_service await handler.job.target(service_call) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service await self.hass.helpers.service.entity_service_call( File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 593, in entity_service_call future.result() # pop exception if have File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 664, in async_request_call await coro File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 630, in _handle_entity_call await result File "/usr/src/homeassistant/homeassistant/components/media_player/init.py", line 788, in async_media_play_pause await self.async_media_play() File "/usr/src/homeassistant/homeassistant/components/dlna_dmr/media_player.py", line 105, in wrapper return await func(self, *args, kwargs) File "/usr/src/homeassistant/homeassistant/components/dlna_dmr/media_player.py", line 318, in async_media_play await self._device.async_play() File "/usr/local/lib/python3.8/site-packages/async_upnp_client/profiles/dlna.py", line 478, in async_play await action.async_call(InstanceID=0, Speed='1') File "/usr/local/lib/python3.8/site-packages/async_upnp_client/client.py", line 512, in async_call url, headers, body = self.create_request(kwargs) File "/usr/local/lib/python3.8/site-packages/async_upnp_client/client.py", line 535, in create_request soap_args = self._format_request_args(kwargs) File "/usr/local/lib/python3.8/site-packages/async_upnp_client/client.py", line 558, in _format_request_args self.validate_arguments(kwargs) File "/usr/local/lib/python3.8/site-packages/async_upnp_client/client.py", line 486, in validate_arguments value = kwargs[arg.name] KeyError: 'JRiverSyncPlayTime'


that looks to me pretty much like the last one i posted, and not anything like you posted. so... what i need to do differently to help you to help me better...? :)

cheers

StevenLooman commented 3 years ago

If you press the button LOAD FULL HOME ASSISTANT LOGS you'll see the additional logging.

StevenLooman commented 3 years ago

I've installed JRiver myself and reproduced the problem. The point is that JRiver did originally properly implemented DLNA/DMR, but since MC24 they have made some changes for, I think, multi-room audio. See this answer in a thread on their forums.

The problem is that JRiver has added two (in-)parameters to the Play action, called JRiverSyncPlayTime and JRiverSyncServer. This Home Assistant component, and BubbleUPnP as seen in that thread, does not know about these parameters as these are not specified in the AVTransport standard and does not know what to send.

I suggest that you either open a new issue on the JRiver forums or write a reply to the existing thread, stating that JRiver does not implement the DLNA standard. The answer by AndrewFG is the solutions to these problems: JRiver should not change the Play action, but instead should implement something new.

If you have any questions, feel free to ask!

StevenLooman commented 3 years ago

I'm closing the issue here. You can still ask questions.

tennbaum commented 3 years ago

Hi man thank you do much for clearing that out (with the installation of jriver and all). ill do as you suggested, but really appreciate all your help. cheers

StevenLooman commented 3 years ago

You're welcome! I hope you can convince the people behind JRiver to change their DLNA implementation and they'll adhere to the standard again.

StevenLooman commented 3 years ago

Do you have a link to the forum thread you've created or a reply you've posted?

tennbaum commented 3 years ago

I'm assuming you're talking about the jriver thread - have not done that yet.

i need to better understand first that topic b4. and i'm not ruling out just switching to a more standart player (though i really like the jriver as a player\server), maybe it's time to look into other options, instead of fighting windmills... :)

On Mon, Dec 28, 2020 at 9:02 PM Steven Looman notifications@github.com wrote:

Do you have a link to the forum thread you've created or a reply you've posted?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/StevenLooman/home-assistant-dlna-dmr/issues/13#issuecomment-751830324, or unsubscribe https://github.com/notifications/unsubscribe-auth/AR2EGZJSVOESMOVVMHTCHP3SXDI5TANCNFSM4UQQWMOQ .

StevenLooman commented 3 years ago

If you really want to dive into the DLNA/DMR standard, you can look at the MediaRenderer spec. This describes that a DMR device provides three services:

The AVTransport service provides the Play-action, the one giving problems in our case. On page 26 of the AVTransport spec you'll see that it expects two parameters: InstanceID and Speed.

If you download the device description XML from your JRiver installation you'll see that the Play-action actually expects four parameters (InstanceID, Speed, as expected, and JRiverSyncPlayTime, JRiverSyncServer additionally.) You can download the XMLs using these URLs. Be sure to replace the IP in the link by the IP of the device running your JRiver installation. Not sure if ports are chosen at random, but worth a try:

Looking at the AVTransport service description, you'll see this (this is only the relevant action, I've indented this for readability):

<action>
  <name>Play</name>
  <argumentList>
    <argument>
      <name>InstanceID</name>
      <direction>in</direction>
      <relatedStateVariable>A_ARG_TYPE_InstanceID</relatedStateVariable>
    </argument>
    <argument>
      <name>Speed</name>
      <direction>in</direction>
      <relatedStateVariable>TransportPlaySpeed</relatedStateVariable>
    </argument>
    <argument>
      <name>JRiverSyncPlayTime</name>
      <direction>in</direction>
      <relatedStateVariable>NextSyncPlayTime</relatedStateVariable>
    </argument>
    <argument>
      <name>JRiverSyncServer</name>
      <direction>in</direction>
      <relatedStateVariable>NTPServerURL</relatedStateVariable>
    </argument>
  </argumentList>
</action>

Hope this helps/clarifies things for you. And yes, sometimes it can be hard to convince people to change. Understandably, I think JRiver is using this to do multi-room audio. If they need to change this, they need to build it and test it, possibly breaking (other) things.

tennbaum commented 3 years ago

I like your answers!

they show me how far my knowledge is from where i want it to be, but also points me in the right direction...

cheers

On Tue, Dec 29, 2020 at 11:49 AM Steven Looman notifications@github.com wrote:

If you really want to dive into the DLNA/DMR standard, you can look at the MediaRenderer spec http://upnp.org/specs/av/UPnP-av-MediaRenderer-v1-Device.pdf. This describes that a DMR device provides three services:

The AVTransport service provides the Play-action, the one giving problems in our case. On page 26 of the AVTransport spec you'll see that it expects two parameters: InstanceID and Speed.

If you download the device description XML from your JRiver installation you'll see that the Play-action actually expects four parameters ( InstanceID, Speed, as expected, and JRiverSyncPlayTime, JRiverSyncServer additionally.) You can download the XMLs using these URLs. Be sure to replace the IP in the link by the IP of the device running your JRiver installation. Not sure if ports are chosen at random, but worth a try:

Looking at the AVTransport service description, you'll see this:

Play InstanceID in A_ARG_TYPE_InstanceID Speed in TransportPlaySpeed JRiverSyncPlayTime in NextSyncPlayTime JRiverSyncServer in NTPServerURL

Hope this helps/clarifies things for you. And yes, sometimes it can be hard to convince people to change. Understandably, I think JRiver is using this to do multi-room audio. If they need to change this, they need to build it and test it, possibly breaking (other) things.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/StevenLooman/home-assistant-dlna-dmr/issues/13#issuecomment-752015900, or unsubscribe https://github.com/notifications/unsubscribe-auth/AR2EGZKH3VO2KYY5BSGYFS3SXGQ35ANCNFSM4UQQWMOQ .

StevenLooman commented 3 years ago

Thanks! Again, if you have further questions feel free to ask.