home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.8k stars 30.89k forks source link

EventListenAddr for DLNA DMR Integration #127041

Closed ncasaux closed 1 month ago

ncasaux commented 1 month ago

The problem

Hello,

I'm trying to run the DLNA integration (https://www.home-assistant.io/integrations/dlna_dmr) on Docker HA (on kubernetes), behind a reverse proxy. I have an issue to expose the callback url of the integration.

I can see this in the log: DEBUG (MainThread) [homeassistant.components.dlna_dmr] Getting event handler for EventListenAddr(host='10.42.3.40', port=5678, callback_url=None)

Obviously the listening addresse is the one of the pod, which make it unreachable from outside. How could I change the value of the host ? I would need to set it to 0.0.0.0 The port can be changed in the configuration section of the integration, but not the host.

Would it be possible to add this option or provide some workaround ?

Thanks !

What version of Home Assistant Core has the issue?

core-2024.9.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

dlna_dmr

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 month ago

Hey there @chishm, mind taking a look at this issue as it has been labeled with an integration (dlna_dmr) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `dlna_dmr` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign dlna_dmr` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


dlna_dmr documentation dlna_dmr source (message by IssueLinks)

chishm commented 1 month ago

Hi,

Ignore the host part of that message, and take a look at the callback_url instead. See https://www.home-assistant.io/integrations/dlna_dmr#options for the format. The host should be the external IP address of the Home Assistant container, and definitely not 0.0.0.0 (which is the "listen on any interface" address).

Also set the port explicitly so it doesn't change, since it's normally allocated randomly and that won't do when forwarding ports.

I hope this helps.

-------- Original Message -------- From: Nicolas CASAUX @.> Sent: 30 September 2024 1:34:01 am AEST To: home-assistant/core @.> Cc: Michael Chisholm @.>, Mention @.> Subject: [home-assistant/core] EventListenAddr for DLNA DMR Integration (Issue #127041)

The problem

Hello,

I'm trying to run the DLNA integration (https://www.home-assistant.io/integrations/dlna_dmr) on Docker HA (on kubernetes), behind a reverse proxy. I have an issue to expose the callback url of the integration.

I can see in the log this line: DEBUG (MainThread) [homeassistant.components.dlna_dmr] Getting event handler for EventListenAddr(host='10.42.3.40', port=5678, callback_url=None)

How can I change the value of the host ? I would need to set it to 0.0.0.0 The port can be changed in the configuration section of the integration, but not the host. Would it be possible to add this option or provide some workaround ?

Thanks !

What version of Home Assistant Core has the issue?

core-2024.9.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

dlna_dmr

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

-- Reply to this email directly or view it on GitHub: https://github.com/home-assistant/core/issues/127041 You are receiving this because you were mentioned.

Message ID: @.***>

ncasaux commented 1 month ago

Hi @chishm

Thank you for your feedback. I think I was not clear enough in my first explanation, and also I'm not an expert in DLNA πŸ˜‰

From what I understand, the idea is that my DLNA device will update HA DLNA integration using the callback URL. So far I have not set up this callback URL, neither the port as you noticed:

2024-09-30 09:05:32.732 DEBUG (MainThread) [homeassistant.components.dlna_dmr] Getting event handler for EventListenAddr(host='10.42.3.14', port=0, callback_url=None)
2024-09-30 09:05:32.738 DEBUG (MainThread) [async_upnp_client.aiohttp] New source for UpnpNotifyServer: ('10.42.3.14', 43461)
2024-09-30 09:05:32.740 DEBUG (MainThread) [homeassistant.components.dlna_dmr] Started event handler at http://10.42.3.14:43461/notify

I will have to set this URL with something like http://my.k3s.cluster:5555/notify (I also will have to configure the HA Ingress of my k3s cluster to route the /notify requests from my device to reach the HA DLNA integration, but that's another topic πŸ˜‰).

Howerver, I already know that my device won't be able to reach the HA DLNA integration because the integration is not reachable from a network point of view, as it does not listen on 0.0.0.0: Started event handler at http://10.42.3.14:43461/notify I actually have to double check that, maybe that won't be a problem after all... I'll set up the all thing and let you know 😊

Hopefully my explanation are better this time!😊

ncasaux commented 1 month ago

Well, I'm not really sure what is wrong actually...

Here what I did so far:

How could I be sure that my device is compatible ? The description seems ok, but I'm not sure:

<?xml version="1.0"?>
<root
    xmlns="urn:schemas-upnp-org:device-1-0"
    xmlns:qq="http://www.tencent.com">
    <specVersion>
        <major>1</major>
        <minor>0</minor>
    </specVersion>
    <device>
        <deviceType>urn:schemas-upnp-org:device:MediaRenderer:1</deviceType>
        <presentationURL></presentationURL>
        <dlna:X_DLNADOC
            xmlns:dlna="urn:schemas-dlna-org:device-1-0">DMR-1.50
        </dlna:X_DLNADOC>
        <friendlyName>LibratoneZippMini</friendlyName>
        <manufacturer>Libratone</manufacturer>
        <manufacturerURL>http://www.libratone.com/</manufacturerURL>
        <modelDescription>Libratone ZippMini</modelDescription>
        <modelName>LTH</modelName>
        <modelNumber>200</modelNumber>
        <modelURL>http://www.libratone.com/home/products/zippmini/#intro</modelURL>
        <UDN>uuid:be46d705-7937-44ed-8c85-9b1b26c7da7c</UDN>
        <serialNumber>1719-H0020000-07-36555</serialNumber>
        <UPC>123810928305</UPC>
        <iconList>
            <icon>
                <mimetype>image/jpeg</mimetype>
                <width>48</width>
                <height>48</height>
                <depth>24</depth>
                <url>/upnp/grender-48x48.jpg</url>
            </icon>
            <icon>
                <mimetype>image/jpeg</mimetype>
                <width>120</width>
                <height>120</height>
                <depth>24</depth>
                <url>/upnp/grender-120x120.jpg</url>
            </icon>
            <icon>
                <mimetype>image/png</mimetype>
                <width>48</width>
                <height>48</height>
                <depth>24</depth>
                <url>/upnp/grender-48x48.png</url>
            </icon>
            <icon>
                <mimetype>image/png</mimetype>
                <width>120</width>
                <height>120</height>
                <depth>24</depth>
                <url>/upnp/grender-120x120.png</url>
            </icon>
        </iconList>
        <serviceList>
            <service>
                <serviceType>urn:schemas-upnp-org:service:AVTransport:1</serviceType>
                <serviceId>urn:upnp-org:serviceId:AVTransport</serviceId>
                <SCPDURL>/upnp/rendertransportSCPD.xml</SCPDURL>
                <controlURL>/upnp/control/rendertransport1</controlURL>
                <eventSubURL>/upnp/event/rendertransport1</eventSubURL>
            </service>
            <service>
                <serviceType>urn:schemas-upnp-org:service:ConnectionManager:1</serviceType>
                <serviceId>urn:upnp-org:serviceId:ConnectionManager</serviceId>
                <SCPDURL>/upnp/renderconnmgrSCPD.xml</SCPDURL>
                <controlURL>/upnp/control/renderconnmgr1</controlURL>
                <eventSubURL>/upnp/event/renderconnmgr1</eventSubURL>
            </service>
            <service>
                <serviceType>urn:schemas-upnp-org:service:RenderingControl:1</serviceType>
                <serviceId>urn:upnp-org:serviceId:RenderingControl</serviceId>
                <SCPDURL>/upnp/rendercontrolSCPD.xml</SCPDURL>
                <controlURL>/upnp/control/rendercontrol1</controlURL>
                <eventSubURL>/upnp/event/rendercontrol1</eventSubURL>
            </service>
            <service>
                <serviceType>urn:schemas-tencent-com:service:QPlay:1</serviceType>
                <serviceId>urn:tencent-com:serviceId:QPlay</serviceId>
                <SCPDURL>/upnp/qplaySCPD.xml</SCPDURL>
                <controlURL>/upnp/control/qplaycontrol</controlURL>
                <eventSubURL></eventSubURL>
            </service>
        </serviceList>
        <qq:X_QPlay_SoftwareCapability>QPlay:2</qq:X_QPlay_SoftwareCapability>
    </device>
    <URLBase>http://192.168.1.26:49152/</URLBase>
</root>

Is there anything I could do to ensure that my device is compatible with the integration ?

chishm commented 1 month ago

Hi @chishm

Thank you for your feedback. I think I was not clear enough in my first explanation, and also I'm not an expert in DLNA πŸ˜‰

You're welcome :smile:

From what I understand, the idea is that my DLNA device will update HA DLNA integration using the callback URL.

Correct.

So far I have not set up this callback URL, neither the port as you noticed:

2024-09-30 09:05:32.732 DEBUG (MainThread) [homeassistant.components.dlna_dmr] Getting event handler for EventListenAddr(host='10.42.3.14', port=0, callback_url=None)
2024-09-30 09:05:32.738 DEBUG (MainThread) [async_upnp_client.aiohttp] New source for UpnpNotifyServer: ('10.42.3.14', 43461)
2024-09-30 09:05:32.740 DEBUG (MainThread) [homeassistant.components.dlna_dmr] Started event handler at http://10.42.3.14:43461/notify

I will have to set this URL with something like http://my.k3s.cluster:5555/notify (I also will have to configure the HA Ingress of my k3s cluster to route the /notify requests from my device to reach the HA DLNA integration, but that's another topic πŸ˜‰).

You'll notice that the listening address uses the container's outgoing IP address, which is probably not the same as what you need to set for incoming connections. You'll have to set the port so it isn't randomly generated every time, and set the callback_url to the externally accessible IP address & port combination, as configured in Kubernetes to route to your container.

Note: you'll have to use an IP in the callback URL, not a hostname, as many DLNA devices can't or won't do DNS lookups for that part.

ncasaux commented 1 month ago

I managed to make it work once I used only http and IP. Thanks for your support @chishm !