Skip to content
This repository has been archived by the owner on Oct 1, 2021. It is now read-only.

Commit

Permalink
Remove Philips Hue nupnp (#121)
Browse files Browse the repository at this point in the history
* Remove Philips Hue nupnp

* Make ssdp match_device_description only match each url once
  • Loading branch information
balloob authored May 12, 2017
1 parent 9803581 commit 2b4eb21
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 126 deletions.
25 changes: 1 addition & 24 deletions netdisco/discoverables/philips_hue.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,7 @@ class Discoverable(SSDPDiscoverable):

def get_entries(self):
"""Get all the Hue bridge uPnP entries."""
nupnp_entries = self.netdis.phue.entries

# Hub models for year 2012 and 2015
ssdp_entries = self.find_by_device_description({
return self.find_by_device_description({
"manufacturer": "Royal Philips Electronics",
"modelNumber": ["929000226503", "BSB002"]
})

return self.merge_entries(nupnp_entries, ssdp_entries)

# pylint: disable=no-self-use
def merge_entries(self, nupnp_entries, ssdp_entries):
"""Takes lists of device entries found using N-UPnP & SSDP lookups and
merges them making sure that same device is only discoverd once.
"""
entries = {
nupn_entry.description['URLBase']: nupn_entry
for nupn_entry in nupnp_entries
}

for ssdp_entry in ssdp_entries:
url_base = ssdp_entry.description['URLBase']
if url_base not in entries:
entries[url_base] = ssdp_entry

return list(entries.values())
10 changes: 0 additions & 10 deletions netdisco/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
from .lms import LMS
from .tellstick import Tellstick
from .daikin import Daikin
# from .samsungac import SamsungAC
from .philips_hue_nupnp import PHueNUPnPDiscovery

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -40,7 +38,6 @@ def __init__(self):
self.lms = None
self.tellstick = None
self.daikin = None
self.phue = None

self.is_discovering = False
self.discoverables = None
Expand Down Expand Up @@ -71,9 +68,6 @@ def scan(self):
self.daikin = Daikin()
self.daikin.scan()

self.phue = PHueNUPnPDiscovery()
self.phue.scan()

def stop(self):
"""Turn discovery off."""
if not self.is_discovering:
Expand All @@ -87,7 +81,6 @@ def stop(self):
self.lms = None
self.tellstick = None
self.daikin = None
self.phue = None
self.discoverables = None
self.is_discovering = False

Expand Down Expand Up @@ -143,6 +136,3 @@ def print_raw_data(self):
print("")
print("Tellstick")
pprint(self.tellstick.entries)
print("")
print("Philips Hue N-UPnP")
pprint(self.phue.entries)
90 changes: 0 additions & 90 deletions netdisco/philips_hue_nupnp.py

This file was deleted.

14 changes: 12 additions & 2 deletions netdisco/ssdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,18 @@ def find_by_device_description(self, values):
"""
self.update()

return [entry for entry in self.entries
if entry.match_device_description(values)]
seen = set()
results = []

# Make unique based on the location since we don't care about ST here
for entry in self.entries:
location = entry.location

if location not in seen and entry.match_device_description(values):
results.append(entry)
seen.add(location)

return results

def update(self, force_update=False):
"""Scan for new uPnP devices and services."""
Expand Down

0 comments on commit 2b4eb21

Please sign in to comment.