Skip to content
Snippets Groups Projects
Commit 5f8d56ed authored by jkerdreu's avatar jkerdreu
Browse files

Added Network error stuff

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/trunk@2022 b32b6428-25c9-4566-ad07-03861ab6144f
parent 28bc1140
No related branches found
No related tags found
No related merge requests found
......@@ -72,7 +72,11 @@ class GW:
m.update_sensors(attr)
def readweatherstation(self):
netatmo_data = netatmo.API(self.cfg).get_data()
try:
netatmo_data = netatmo.API(self.cfg).get_data()
except:
logger.warn("Unable to connect to NA server")
return
main_indoor = netatmo_data["devices"][0] # dic
netatmo_modules= main_indoor["modules"] # list
......
......@@ -136,6 +136,9 @@ class ConfigParser: # netatmo weather station config
def update_devices(self):
modules= self.get_modules()
if modules == None:
return
for k in modules.keys():
if k not in self.cfg['devices'] :
self.cfg['devices'][k]={}
......@@ -151,7 +154,12 @@ class ConfigParser: # netatmo weather station config
self.cfg['devices'].inline_comments[k]='This device is removed !!!'
def get_modules(self):
data = data=API(self.cfg).get_data()
try:
data = data=API(self.cfg).get_data()
except:
logger.warn("Unable to connect to NA server")
return None
# NAMain is the first devices
main_module = data['devices'][0]
result = {main_module['_id'] : main_module['type']}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment