Skip to content

Commit 524f2a5

Browse files
committed
Handle missing module name and auth data file case mix
1 parent b7acec6 commit 524f2a5

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

lnetatmo.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def getParameter(key, default):
5858

5959
# 2 : Override hard coded values with credentials file if any
6060
if exists(CREDENTIALS) :
61-
with open(CREDENTIALS, "r") as f: cred = json.loads(f.read())
61+
with open(CREDENTIALS, "r") as f:
62+
cred.update({k.upper():v for k,v in json.loads(f.read()).items()})
6263

6364
# 3 : Override final value with content of env variables if defined
6465
_CLIENT_ID = getParameter("CLIENT_ID", cred)
@@ -228,6 +229,8 @@ def lastData(self, station=None, exclude=0):
228229
for module in s["modules"]:
229230
ds = module['dashboard_data']
230231
if ds['time_utc'] > limit :
232+
# If no module_name has been setup, use _id by default
233+
if "module_name" not in module : module['module_name'] = module["_id"]
231234
lastD[module['module_name']] = ds.copy()
232235
lastD[module['module_name']]['When'] = lastD[module['module_name']].pop("time_utc")
233236
# For potential use, add battery and radio coverage information to module data if present

0 commit comments

Comments
 (0)