Skip to content

Commit

Permalink
Add DLNA/DMR discovery (home-assistant-libs#196)
Browse files Browse the repository at this point in the history
* Add DLNA/DMR discovery

* Fix tests
  • Loading branch information
StevenLooman authored and balloob committed Jun 2, 2018
1 parent 317c3b0 commit 13c8d67
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions netdisco/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@
ATTR_UDN = 'udn'
ATTR_PROPERTIES = 'properties'
ATTR_SSDP_DESCRIPTION = 'ssdp_description'
ATTR_UPNP_DEVICE_TYPE = 'upnp_device_type'
ATTR_SERIAL = 'serial'
ATTR_MAC_ADDRESS = 'mac_address'
3 changes: 2 additions & 1 deletion netdisco/discoverables/DLNA.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ class Discoverable(SSDPDiscoverable):

def get_entries(self):
"""Get all the DLNA service uPnP entries."""
return self.find_by_st("urn:schemas-upnp-org:device:MediaServer:1")
return self.find_by_st("urn:schemas-upnp-org:device:MediaServer:1") + \
self.find_by_st("urn:schemas-upnp-org:device:MediaRenderer:1")
3 changes: 2 additions & 1 deletion netdisco/discoverables/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ..const import (
ATTR_NAME, ATTR_MODEL_NAME, ATTR_HOST, ATTR_PORT, ATTR_SSDP_DESCRIPTION,
ATTR_SERIAL, ATTR_MODEL_NUMBER, ATTR_HOSTNAME, ATTR_MAC_ADDRESS,
ATTR_PROPERTIES, ATTR_MANUFACTURER, ATTR_UDN)
ATTR_PROPERTIES, ATTR_MANUFACTURER, ATTR_UDN, ATTR_UPNP_DEVICE_TYPE)


class BaseDiscoverable(object):
Expand Down Expand Up @@ -58,6 +58,7 @@ def info_from_entry(self, entry):
info[ATTR_SERIAL] = device.get('serialNumber')
info[ATTR_MANUFACTURER] = device.get('manufacturer')
info[ATTR_UDN] = device.get('UDN')
info[ATTR_UPNP_DEVICE_TYPE] = device.get('deviceType')

return info

Expand Down
12 changes: 8 additions & 4 deletions tests/discoverables/test_yamaha.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def test_info_from_entry_rx_v481(self):
'port': 80,
'serial': 'XXXXXXXX',
'ssdp_description': 'http:https://192.168.XXX.XXX:80/desc.xml',
'udn': 'uuid:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
'udn': 'uuid:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
'upnp_device_type': 'urn:schemas-upnp-org:device:MediaRenderer:1',
})

def test_info_from_entry_single_service(self):
Expand All @@ -61,7 +62,8 @@ def test_info_from_entry_single_service(self):
'port': 80,
'serial': None,
'ssdp_description': 'http:https://192.168.XXX.XXX:80/desc.xml',
'udn': None
'udn': None,
'upnp_device_type': None,
})

def test_info_from_entry_multiple_services_remote_control_last(self):
Expand All @@ -81,7 +83,8 @@ def test_info_from_entry_multiple_services_remote_control_last(self):
'port': 80,
'serial': None,
'ssdp_description': 'http:https://192.168.XXX.XXX:80/desc.xml',
'udn': None
'udn': None,
'upnp_device_type': None,
})

def test_info_from_entry_multiple_services_no_remote_control(self):
Expand All @@ -101,5 +104,6 @@ def test_info_from_entry_multiple_services_no_remote_control(self):
'port': 80,
'serial': None,
'ssdp_description': 'http:https://192.168.XXX.XXX:80/desc.xml',
'udn': None
'udn': None,
'upnp_device_type': None,
})

0 comments on commit 13c8d67

Please sign in to comment.