From fb9d8c79b50e495706f896c0e284d10522b96d1a Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 19 Feb 2016 23:22:23 -0800 Subject: [PATCH] Bloomsky main component to load its platforms --- homeassistant/components/binary_sensor/__init__.py | 3 ++- homeassistant/components/bloomsky.py | 11 +++++++++++ homeassistant/components/camera/__init__.py | 5 ++++- homeassistant/components/sensor/__init__.py | 3 ++- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/binary_sensor/__init__.py b/homeassistant/components/binary_sensor/__init__.py index 0eefd853538..844bc609bfd 100644 --- a/homeassistant/components/binary_sensor/__init__.py +++ b/homeassistant/components/binary_sensor/__init__.py @@ -12,7 +12,7 @@ import logging from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.entity import Entity from homeassistant.const import (STATE_ON, STATE_OFF) -from homeassistant.components import (mysensors, ) +from homeassistant.components import (bloomsky, mysensors) DOMAIN = 'binary_sensor' SCAN_INTERVAL = 30 @@ -32,6 +32,7 @@ SENSOR_CLASSES = [ # Maps discovered services to their platforms DISCOVERY_PLATFORMS = { + bloomsky.DISCOVER_BINARY_SENSORS: 'bloomsky', mysensors.DISCOVER_BINARY_SENSORS: 'mysensors', } diff --git a/homeassistant/components/bloomsky.py b/homeassistant/components/bloomsky.py index f13b9ce85c9..44a90007725 100644 --- a/homeassistant/components/bloomsky.py +++ b/homeassistant/components/bloomsky.py @@ -11,6 +11,7 @@ from datetime import timedelta import requests +from homeassistant.components import discovery from homeassistant.const import CONF_API_KEY from homeassistant.helpers import validate_config from homeassistant.util import Throttle @@ -24,6 +25,10 @@ _LOGGER = logging.getLogger(__name__) # no point in polling the API more frequently MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=300) +DISCOVER_SENSORS = 'bloomsky.sensors' +DISCOVER_BINARY_SENSORS = 'bloomsky.binary_sensor' +DISCOVER_CAMERAS = 'bloomsky.camera' + # pylint: disable=unused-argument,too-few-public-methods def setup(hass, config): @@ -42,6 +47,12 @@ def setup(hass, config): except RuntimeError: return False + for component, discovery_service in ( + ('camera', DISCOVER_CAMERAS), ('sensor', DISCOVER_SENSORS), + ('binary_sensor', DISCOVER_BINARY_SENSORS)): + discovery.discover(hass, discovery_service, component=component, + hass_config=config) + return True diff --git a/homeassistant/components/camera/__init__.py b/homeassistant/components/camera/__init__.py index 7fab1fe3ae6..615554ae56f 100644 --- a/homeassistant/components/camera/__init__.py +++ b/homeassistant/components/camera/__init__.py @@ -13,6 +13,7 @@ import requests from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity_component import EntityComponent +from homeassistant.components import bloomsky from homeassistant.const import ( ATTR_ENTITY_PICTURE, HTTP_NOT_FOUND, @@ -26,7 +27,9 @@ SCAN_INTERVAL = 30 ENTITY_ID_FORMAT = DOMAIN + '.{}' # Maps discovered services to their platforms -DISCOVERY_PLATFORMS = {} +DISCOVERY_PLATFORMS = { + bloomsky.DISCOVER_CAMERAS: 'bloomsky', +} STATE_RECORDING = 'recording' STATE_STREAMING = 'streaming' diff --git a/homeassistant/components/sensor/__init__.py b/homeassistant/components/sensor/__init__.py index 88071c0b5fb..8dbaef0e118 100644 --- a/homeassistant/components/sensor/__init__.py +++ b/homeassistant/components/sensor/__init__.py @@ -10,7 +10,7 @@ import logging from homeassistant.helpers.entity_component import EntityComponent from homeassistant.components import ( - wink, zwave, isy994, verisure, ecobee, tellduslive, mysensors) + wink, zwave, isy994, verisure, ecobee, tellduslive, mysensors, bloomsky) DOMAIN = 'sensor' SCAN_INTERVAL = 30 @@ -19,6 +19,7 @@ ENTITY_ID_FORMAT = DOMAIN + '.{}' # Maps discovered services to their platforms DISCOVERY_PLATFORMS = { + bloomsky.DISCOVER_SENSORS: 'bloomsky', wink.DISCOVER_SENSORS: 'wink', zwave.DISCOVER_SENSORS: 'zwave', isy994.DISCOVER_SENSORS: 'isy994',