File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -363,6 +363,35 @@ def get_daily_data_limit_30d(start_date_str, end_date_str):
363
363
else :
364
364
logging .error ("Recording failed : SPO2 intraday for date " + start_date_str + " to " + end_date_str )
365
365
366
+ weight_data_list = request_data_from_fitbit ('https://api.fitbit.com/1/user/-/body/log/weight/date/' + start_date_str + '/' + end_date_str + '.json' )["weight" ]
367
+ if weight_data_list != None :
368
+ for entry in weight_data_list :
369
+ log_time = datetime .fromisoformat (entry ["date" ] + "T" + entry ["time" ])
370
+ utc_time = LOCAL_TIMEZONE .localize (log_time ).astimezone (pytz .utc ).isoformat ()
371
+ collected_records .append ({
372
+ "measurement" : "weight" ,
373
+ "time" : utc_time ,
374
+ "tags" : {
375
+ "Device" : DEVICENAME
376
+ },
377
+ "fields" : {
378
+ "value" : float (entry ["weight" ]),
379
+ }
380
+ })
381
+ collected_records .append ({
382
+ "measurement" : "bmi" ,
383
+ "time" : utc_time ,
384
+ "tags" : {
385
+ "Device" : DEVICENAME
386
+ },
387
+ "fields" : {
388
+ "value" : float (entry ["bmi" ]),
389
+ }
390
+ })
391
+ logging .info ("Recorded weight and BMI for date " + start_date_str + " to " + end_date_str )
392
+ else :
393
+ logging .error ("Recording failed : weight and BMI for date " + start_date_str + " to " + end_date_str )
394
+
366
395
# Only for sleep data - limit 100 days - 1 query
367
396
def get_daily_data_limit_100d (start_date_str , end_date_str ):
368
397
You can’t perform that action at this time.
0 commit comments