Skip to content
This repository was archived by the owner on Oct 1, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion netdisco/discoverables/yamaha.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
class Discoverable(SSDPDiscoverable):
"""Add support for discovering Yamaha Receivers."""

INCOMPATIBLE_MODELS = set('N301')

REMOTE_CONTROL_SPEC_TYPE =\
'urn:schemas-yamaha-com:service:X_YamahaRemoteControl:1'

Expand All @@ -30,7 +32,11 @@ def info_from_entry(self, entry):

def get_entries(self):
"""Get all the Yamaha uPnP entries."""
return self.find_by_device_description({
devices = self.find_by_device_description({
"manufacturer": "Yamaha Corporation",
"deviceType": "urn:schemas-upnp-org:device:MediaRenderer:1"
})

return [device for device in devices if
device.description['device'].get('modelNumber', '') not in
self.INCOMPATIBLE_MODELS]
14 changes: 14 additions & 0 deletions tests/discoverables/test_yamaha.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""The tests for discovering Yamaha Receivers."""
import unittest
from unittest.mock import MagicMock
import xml.etree.ElementTree as ElementTree

from netdisco.discoverables.yamaha import Discoverable
Expand Down Expand Up @@ -107,3 +108,16 @@ def test_info_from_entry_multiple_services_no_remote_control(self):
'udn': None,
'upnp_device_type': None,
})

def test_get_entries_incompatible_models(self):
supported_model = MockUPNPEntry("desc_multiple_services_no_remote_control.xml")
devices = [
supported_model,
MockUPNPEntry("desc_incompatible_device.xml")
]

discoverable = Discoverable(None)
discoverable.INCOMPATIBLE_MODELS = ["aaa"]
discoverable.find_by_device_description = MagicMock(return_value=devices)

self.assertEqual(discoverable.get_entries(), [supported_model])
26 changes: 26 additions & 0 deletions tests/discoverables/yamaha_files/desc_incompatible_device.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<root xmlns="urn:schemas-upnp-org:device-1-0" xmlns:yamaha="urn:schemas-yamaha-com:device-1-0">
<device>
<friendlyName>multi service friendly name</friendlyName>
<modelName>multi service model name</modelName>
<modelNumber>aaa</modelNumber>
</device>
<yamaha:X_device>
<yamaha:X_URLBase>http://192.168.1.2:80/</yamaha:X_URLBase>
<yamaha:X_serviceList>
<yamaha:X_service>
<yamaha:X_specType>
urn:schemas-yamaha-com:service:X_YamahaNewControl:1
</yamaha:X_specType>
<yamaha:X_controlURL>/YamahaNewControl/ctrl</yamaha:X_controlURL>
<yamaha:X_unitDescURL>/YamahaNewControl/desc.xml</yamaha:X_unitDescURL>
</yamaha:X_service>
<yamaha:X_service>
<yamaha:X_specType>
urn:schemas-yamaha-com:service:X_YamahaExtendedControl:1
</yamaha:X_specType>
<yamaha:X_yxcControlURL>/YamahaExtendedControl/v1/</yamaha:X_yxcControlURL>
<yamaha:X_yxcVersion>1131</yamaha:X_yxcVersion>
</yamaha:X_service>
</yamaha:X_serviceList>
</yamaha:X_device>
</root>