Hotfix for Netatmo discovery (#3837)

This should definetly fix #2601

Signed-off-by: Hugo D. (jabesq) <jabesq@gmail.com>
This commit is contained in:
Hugo Dupras 2016-10-13 18:21:22 +02:00 committed by Paulus Schoutsen
parent d873a7baf0
commit 9a0bb62654
3 changed files with 28 additions and 24 deletions

View File

@ -49,11 +49,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
import lnetatmo import lnetatmo
try: try:
data = WelcomeData(netatmo.NETATMO_AUTH, home) data = WelcomeData(netatmo.NETATMO_AUTH, home)
except lnetatmo.NoDevice:
return None
if data.get_camera_names() == []: if data.get_camera_names() == []:
return None return None
except lnetatmo.NoDevice:
return None
sensors = config.get(CONF_MONITORED_CONDITIONS, SENSOR_TYPES) sensors = config.get(CONF_MONITORED_CONDITIONS, SENSOR_TYPES)

View File

@ -36,15 +36,14 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
import lnetatmo import lnetatmo
try: try:
data = WelcomeData(netatmo.NETATMO_AUTH, home) data = WelcomeData(netatmo.NETATMO_AUTH, home)
except lnetatmo.NoDevice:
return None
for camera_name in data.get_camera_names(): for camera_name in data.get_camera_names():
if CONF_CAMERAS in config: if CONF_CAMERAS in config:
if config[CONF_CAMERAS] != [] and \ if config[CONF_CAMERAS] != [] and \
camera_name not in config[CONF_CAMERAS]: camera_name not in config[CONF_CAMERAS]:
continue continue
add_devices([WelcomeCamera(data, camera_name, home)]) add_devices([WelcomeCamera(data, camera_name, home)])
except lnetatmo.NoDevice:
return None
class WelcomeCamera(Camera): class WelcomeCamera(Camera):

View File

@ -65,9 +65,12 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
data = NetAtmoData(netatmo.NETATMO_AUTH, config.get(CONF_STATION, None)) data = NetAtmoData(netatmo.NETATMO_AUTH, config.get(CONF_STATION, None))
dev = [] dev = []
import lnetatmo
try:
if CONF_MODULES in config: if CONF_MODULES in config:
# Iterate each module # Iterate each module
for module_name, monitored_conditions in config[CONF_MODULES].items(): for module_name, monitored_conditions in\
config[CONF_MODULES].items():
# Test if module exist """ # Test if module exist """
if module_name not in data.get_module_names(): if module_name not in data.get_module_names():
_LOGGER.error('Module name: "%s" not found', module_name) _LOGGER.error('Module name: "%s" not found', module_name)
@ -77,8 +80,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
dev.append(NetAtmoSensor(data, module_name, variable)) dev.append(NetAtmoSensor(data, module_name, variable))
else: else:
for module_name in data.get_module_names(): for module_name in data.get_module_names():
for variable in data.station_data.monitoredConditions(module_name): for variable in\
data.station_data.monitoredConditions(module_name):
dev.append(NetAtmoSensor(data, module_name, variable)) dev.append(NetAtmoSensor(data, module_name, variable))
except lnetatmo.NoDevice:
return None
add_devices(dev) add_devices(dev)