summaryrefslogtreecommitdiff
path: root/netdisco/discoverables/denonavr.py
blob: d830aa667153a5ac3c153ee6bd792315308417bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""Discover Denon AVR devices."""
from urllib.parse import urlparse

from . import SSDPDiscoverable
from ..const import ATTR_HOST


class Discoverable(SSDPDiscoverable):
    """Add support for discovering Denon AVR devices."""

    def get_entries(self):
        """Get all Denon AVR uPnP entries."""
        return self.find_by_device_description({
            "manufacturer": "Denon",
            "deviceType": "urn:schemas-upnp-org:device:MediaRenderer:1"
        })

    def info_from_entry(self, entry):
        """Get most important info, which is name, model and host."""
        info = super().info_from_entry(entry)
        info[ATTR_HOST] = urlparse(
            entry.description['device']['presentationURL']).hostname
        return info