Migrate to generic discovery method (#2271)
* Migrate to generic discovery method * Add tests for discovery
This commit is contained in:
1 parent
c9756c40e2
commit
30f74bb3ca
32 files changed
+322
-540
No files matched your search
@@ -6,10 +6,9 @@ https://home-assistant.io/components/netatmo/
|
||||
"""
|
||||
import logging
|
||||
from urllib.error import HTTPError
|
||||
from homeassistant.components import discovery
|
||||
from homeassistant.const import (
|
||||
CONF_API_KEY, CONF_PASSWORD, CONF_USERNAME)
|
||||
from homeassistant.helpers import validate_config
|
||||
from homeassistant.helpers import validate_config, discovery
|
||||
|
||||
REQUIREMENTS = [
|
||||
'https://github.com/jabesq/netatmo-api-python/archive/'
|
||||
@@ -24,9 +23,6 @@ NETATMO_AUTH = None
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DISCOVER_SENSORS = 'netatmo.sensors'
|
||||
DISCOVER_CAMERAS = 'netatmo.cameras'
|
||||
|
||||
|
||||
def setup(hass, config):
|
||||
"""Setup the Netatmo devices."""
|
||||
@@ -54,9 +50,7 @@ def setup(hass, config):
|
||||
"Please check your settings for NatAtmo API.")
|
||||
return False
|
||||
|
||||
for component, discovery_service in (
|
||||
('camera', DISCOVER_CAMERAS), ('sensor', DISCOVER_SENSORS)):
|
||||
discovery.discover(hass, discovery_service, component=component,
|
||||
hass_config=config)
|
||||
for component in 'camera', 'sensor':
|
||||
discovery.load_platform(hass, component, DOMAIN, None, config)
|
||||
|
||||
return True
|
||||
Reference in new issue
Block a user