@@ -120,6 +120,25 @@ def getParameter(key, default):
120
120
# Not working yet
121
121
#_CAM_FTP_ACTIVE = "/command/ftp_set_config?config=on_off:%s" # "on"|"off"
122
122
123
+ # UNITS used by Netatmo services
124
+ UNITS = {
125
+ "unit" : {
126
+ 0 : "metric" ,
127
+ 1 : "imperial"
128
+ },
129
+ "windunit" : {
130
+ 0 : "kph" ,
131
+ 1 : "mph" ,
132
+ 2 : "ms" ,
133
+ 3 : "beaufort" ,
134
+ 4 : "knot"
135
+ },
136
+ "pressureunit" : {
137
+ 0 : "mbar" ,
138
+ 1 : "inHg" ,
139
+ 2 : "mmHg"
140
+ }
141
+ }
123
142
124
143
# Logger context
125
144
logger = logging .getLogger ("lnetatmo" )
@@ -198,6 +217,8 @@ class User:
198
217
Args:
199
218
authData (ClientAuth): Authentication information with a working access Token
200
219
"""
220
+ warnings .warn ("The 'User' class is no longer maintained by Netatmo" ,
221
+ DeprecationWarning )
201
222
def __init__ (self , authData ):
202
223
postParams = {
203
224
"access_token" : authData .accessToken
@@ -208,6 +229,14 @@ def __init__(self, authData):
208
229
self .ownerMail = self .rawData ['user' ]['mail' ]
209
230
210
231
232
+ class UserInfo :
233
+ """
234
+ This class is populated with data from various Netatmo requests to provide
235
+ complimentary data (eg Units for Weatherdata)
236
+ """
237
+ pass
238
+
239
+
211
240
class ThermostatData :
212
241
"""
213
242
List the Thermostat and temperature modules
@@ -269,6 +298,7 @@ def __init__(self, authData):
269
298
}
270
299
resp = postRequest (_GETSTATIONDATA_REQ , postParams )
271
300
self .rawData = resp ['body' ]['devices' ]
301
+ # Weather data
272
302
if not self .rawData : raise NoDevice ("No weather station available" )
273
303
self .stations = { d ['_id' ] : d for d in self .rawData }
274
304
self .modules = dict ()
@@ -278,6 +308,16 @@ def __init__(self, authData):
278
308
for m in self .rawData [i ]['modules' ]:
279
309
self .modules [ m ['_id' ] ] = m
280
310
self .default_station = list (self .stations .values ())[0 ]['station_name' ]
311
+ # User data
312
+ userData = resp ['body' ]['user' ]
313
+ self .user = UserInfo ()
314
+ setattr (self .user , "mail" , userData ['mail' ])
315
+ for k ,v in userData ['administrative' ].items ():
316
+ if k in UNITS :
317
+ setattr (self .user , k , UNITS [k ][v ])
318
+ else :
319
+ setattr (self .user , k , v )
320
+
281
321
282
322
def modulesNamesList (self , station = None ):
283
323
res = [m ['module_name' ] for m in self .modules .values ()]
0 commit comments