Skip to content

Commit

Permalink
Port netdisco from external to requirements.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob committed Jul 20, 2015
1 parent 43cc362 commit 3efb1e4
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 25 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[submodule "homeassistant/external/pywemo"]
path = homeassistant/external/pywemo
url = https://github.com/balloob/pywemo.git
[submodule "homeassistant/external/netdisco"]
path = homeassistant/external/netdisco
url = https://github.com/balloob/netdisco.git
[submodule "homeassistant/external/noop"]
path = homeassistant/external/noop
url = https://github.com/balloob/noop.git
Expand Down
26 changes: 11 additions & 15 deletions homeassistant/components/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,27 @@
import logging
import threading

# pylint: disable=no-name-in-module, import-error
import homeassistant.external.netdisco.netdisco.const as services

from homeassistant import bootstrap
from homeassistant.const import (
EVENT_HOMEASSISTANT_START, EVENT_PLATFORM_DISCOVERED,
ATTR_SERVICE, ATTR_DISCOVERED)

DOMAIN = "discovery"
DEPENDENCIES = []
REQUIREMENTS = ['zeroconf>=0.16.0']
REQUIREMENTS = ['netdisco>=0.1']

SCAN_INTERVAL = 300 # seconds

# Next 3 lines for now a mirror from netdisco.const
# Should setup a mapping netdisco.const -> own constants
SERVICE_WEMO = 'belkin_wemo'
SERVICE_HUE = 'philips_hue'
SERVICE_CAST = 'google_cast'

SERVICE_HANDLERS = {
services.BELKIN_WEMO: "switch",
services.GOOGLE_CAST: "media_player",
services.PHILIPS_HUE: "light",
SERVICE_WEMO: "switch",
SERVICE_CAST: "media_player",
SERVICE_HUE: "light",
}


Expand All @@ -56,14 +59,7 @@ def setup(hass, config):
""" Starts a discovery service. """
logger = logging.getLogger(__name__)

try:
from homeassistant.external.netdisco.netdisco.service import \
DiscoveryService
except ImportError:
logger.exception(
"Unable to import netdisco. "
"Did you install all the zeroconf dependency?")
return False
from netdisco.service import DiscoveryService

# Disable zeroconf logging, it spams
logging.getLogger('zeroconf').setLevel(logging.CRITICAL)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/light/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
DISCOVERY_PLATFORMS = {
wink.DISCOVER_LIGHTS: 'wink',
isy994.DISCOVER_LIGHTS: 'isy994',
discovery.services.PHILIPS_HUE: 'hue',
discovery.SERVICE_HUE: 'hue',
}

PROP_TO_ATTR = {
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/media_player/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
ENTITY_ID_FORMAT = DOMAIN + '.{}'

DISCOVERY_PLATFORMS = {
discovery.services.GOOGLE_CAST: 'cast',
discovery.SERVICE_CAST: 'cast',
}

SERVICE_YOUTUBE_VIDEO = 'play_youtube_video'
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/switch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

# Maps discovered services to their platforms
DISCOVERY_PLATFORMS = {
discovery.services.BELKIN_WEMO: 'wemo',
discovery.SERVICE_WEMO: 'wemo',
wink.DISCOVER_SWITCHES: 'wink',
isy994.DISCOVER_SWITCHES: 'isy994',
}
Expand Down
1 change: 0 additions & 1 deletion homeassistant/external/netdisco
Submodule netdisco deleted from b2cad7
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ pytz>=2015.2

# Optional, needed for specific components

# Discovery platform (discovery)
zeroconf>=0.16.0

# Sun (sun)
astral>=0.8.1

Expand Down Expand Up @@ -82,3 +79,6 @@ https://github.com/theolind/pymysensors/archive/master.zip#egg=pymysensors-0.1

# Netgear (device_tracker.netgear)
pynetgear>=0.1

# Netdisco (discovery)
netdisco>=0.1

0 comments on commit 3efb1e4

Please sign in to comment.