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
|
import lnetatmo
|
||||||
try:
|
try:
|
||||||
data = WelcomeData(netatmo.NETATMO_AUTH, home)
|
data = WelcomeData(netatmo.NETATMO_AUTH, home)
|
||||||
|
if data.get_camera_names() == []:
|
||||||
|
return None
|
||||||
except lnetatmo.NoDevice:
|
except lnetatmo.NoDevice:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if data.get_camera_names() == []:
|
|
||||||
return None
|
|
||||||
|
|
||||||
sensors = config.get(CONF_MONITORED_CONDITIONS, SENSOR_TYPES)
|
sensors = config.get(CONF_MONITORED_CONDITIONS, SENSOR_TYPES)
|
||||||
|
|
||||||
for camera_name in data.get_camera_names():
|
for camera_name in data.get_camera_names():
|
||||||
|
|
|
@ -36,16 +36,15 @@ 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)
|
||||||
|
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:
|
except lnetatmo.NoDevice:
|
||||||
return None
|
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):
|
class WelcomeCamera(Camera):
|
||||||
"""Representation of the images published from Welcome 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))
|
data = NetAtmoData(netatmo.NETATMO_AUTH, config.get(CONF_STATION, None))
|
||||||
|
|
||||||
dev = []
|
dev = []
|
||||||
if CONF_MODULES in config:
|
import lnetatmo
|
||||||
# Iterate each module
|
try:
|
||||||
for module_name, monitored_conditions in config[CONF_MODULES].items():
|
if CONF_MODULES in config:
|
||||||
# Test if module exist """
|
# Iterate each module
|
||||||
if module_name not in data.get_module_names():
|
for module_name, monitored_conditions in\
|
||||||
_LOGGER.error('Module name: "%s" not found', module_name)
|
config[CONF_MODULES].items():
|
||||||
continue
|
# Test if module exist """
|
||||||
# Only create sensor for monitored """
|
if module_name not in data.get_module_names():
|
||||||
for variable in monitored_conditions:
|
_LOGGER.error('Module name: "%s" not found', module_name)
|
||||||
dev.append(NetAtmoSensor(data, module_name, variable))
|
continue
|
||||||
else:
|
# Only create sensor for monitored """
|
||||||
for module_name in data.get_module_names():
|
for variable in monitored_conditions:
|
||||||
for variable in data.station_data.monitoredConditions(module_name):
|
dev.append(NetAtmoSensor(data, module_name, variable))
|
||||||
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)
|
add_devices(dev)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue