Hotfix for Netatmo discovery (#3837)
This should definetly fix #2601 Signed-off-by: Hugo D. (jabesq) <jabesq@gmail.com>
This commit is contained in:
parent
d873a7baf0
commit
9a0bb62654
3 changed files with 28 additions and 24 deletions
|
@ -49,12 +49,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
import lnetatmo
|
||||
try:
|
||||
data = WelcomeData(netatmo.NETATMO_AUTH, home)
|
||||
if data.get_camera_names() == []:
|
||||
return None
|
||||
except lnetatmo.NoDevice:
|
||||
return None
|
||||
|
||||
if data.get_camera_names() == []:
|
||||
return None
|
||||
|
||||
sensors = config.get(CONF_MONITORED_CONDITIONS, SENSOR_TYPES)
|
||||
|
||||
for camera_name in data.get_camera_names():
|
||||
|
|
|
@ -36,16 +36,15 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
import lnetatmo
|
||||
try:
|
||||
data = WelcomeData(netatmo.NETATMO_AUTH, home)
|
||||
for camera_name in data.get_camera_names():
|
||||
if CONF_CAMERAS in config:
|
||||
if config[CONF_CAMERAS] != [] and \
|
||||
camera_name not in config[CONF_CAMERAS]:
|
||||
continue
|
||||
add_devices([WelcomeCamera(data, camera_name, home)])
|
||||
except lnetatmo.NoDevice:
|
||||
return None
|
||||
|
||||
for camera_name in data.get_camera_names():
|
||||
if CONF_CAMERAS in config:
|
||||
if config[CONF_CAMERAS] != [] and \
|
||||
camera_name not in config[CONF_CAMERAS]:
|
||||
continue
|
||||
add_devices([WelcomeCamera(data, camera_name, home)])
|
||||
|
||||
|
||||
class WelcomeCamera(Camera):
|
||||
"""Representation of the images published from Welcome camera."""
|
||||
|
|
|
@ -65,20 +65,26 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
data = NetAtmoData(netatmo.NETATMO_AUTH, config.get(CONF_STATION, None))
|
||||
|
||||
dev = []
|
||||
if CONF_MODULES in config:
|
||||
# Iterate each module
|
||||
for module_name, monitored_conditions in config[CONF_MODULES].items():
|
||||
# Test if module exist """
|
||||
if module_name not in data.get_module_names():
|
||||
_LOGGER.error('Module name: "%s" not found', module_name)
|
||||
continue
|
||||
# Only create sensor for monitored """
|
||||
for variable in monitored_conditions:
|
||||
dev.append(NetAtmoSensor(data, module_name, variable))
|
||||
else:
|
||||
for module_name in data.get_module_names():
|
||||
for variable in data.station_data.monitoredConditions(module_name):
|
||||
dev.append(NetAtmoSensor(data, module_name, variable))
|
||||
import lnetatmo
|
||||
try:
|
||||
if CONF_MODULES in config:
|
||||
# Iterate each module
|
||||
for module_name, monitored_conditions in\
|
||||
config[CONF_MODULES].items():
|
||||
# Test if module exist """
|
||||
if module_name not in data.get_module_names():
|
||||
_LOGGER.error('Module name: "%s" not found', module_name)
|
||||
continue
|
||||
# Only create sensor for monitored """
|
||||
for variable in monitored_conditions:
|
||||
dev.append(NetAtmoSensor(data, module_name, variable))
|
||||
else:
|
||||
for module_name in data.get_module_names():
|
||||
for variable in\
|
||||
data.station_data.monitoredConditions(module_name):
|
||||
dev.append(NetAtmoSensor(data, module_name, variable))
|
||||
except lnetatmo.NoDevice:
|
||||
return None
|
||||
|
||||
add_devices(dev)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue