-
Notifications
You must be signed in to change notification settings - Fork 2
/
fitbit.sh
409 lines (317 loc) · 19.1 KB
/
fitbit.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
#!/bin/bash
# ----------------------------------------------------------------------------------
# Fitbit Configuration obtained from your app at: https://dev.fitbit.com/apps
clientid="xxxxxx" #OAuth 2.0 Client ID
clientsecret="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" #Client Secret
callbackurl="https://mike-greene.com" #Callback URL, eg: https://domoticz.com
# Fitbit Configuration obtained from the browser redirect
code="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# Fitbit Configuration set your units
units="en_US" #Options are: Metric, en_US, en_GB
today=$(date -d "00:00 today" +"%Y-%m-%d")
yesterday=$(date -d "00:00 today" +"%Y-%m-%d")
sevenDaysAgo=$(date -d "00:00 7 days ago" +"%Y-%m-%d")
# Global tags for influxdb
globalTags="platform=Fitbit"
# Path to folder containing this script
cd /var/scripts/fitbit
# ----------------------------------------------------------------------------------
# Create fitbit basic auth token
basicauthtoken=$(echo -n "${clientid}:${clientsecret}" | openssl base64)
# Get a Fitbit oauth2 token
refreshtoken=$(cat refreshtoken.txt 2> /dev/null)
# If we already have a stored token, get a new one.
if [ ! -f refreshtoken.txt ]; then
#echo "Getting access token for the first time..."
oauth=$(curl --max-time 60 -s -X POST -H "Content-Type: application/x-www-form-urlencoded" -H "Authorization: Basic ${basicauthtoken}" "https://api.fitbit.com/oauth2/token?client_id=${clientid}&grant_type=authorization_code&redirect_uri=${callbackurl}&code=${code}")
else
#echo "Detected existing refresh token, getting a new access token..."
oauth=$(curl --max-time 60 -s -X POST --header "Content-Type: application/x-www-form-urlencoded" --header "Authorization: Basic ${basicauthtoken}" "https://api.fitbit.com/oauth2/token?client_id=${clientid}&grant_type=refresh_token&refresh_token=${refreshtoken}")
fi
# Put oauth2 token into easy to use variables and store the refresh token
accesstoken=$(echo "$oauth" | jq ".access_token" | sed 's/["]*//g')
newrefreshtoken=$(echo "$oauth" | jq ".refresh_token" | sed 's/["]*//g')
echo "$newrefreshtoken" > refreshtoken.txt
echo -n "" > fitbit.txt
# Get profile from Fitbit
getProfile=$(curl --max-time 60 -s -X GET -H "Authorization: Bearer ${accesstoken}" -H "Accept-Language: ${units}" "https://api.fitbit.com/1/user/-/profile.json")
echo -e "$getProfile" >> fitbit.txt
# Get data from Fitbit
getWeight=$(curl --max-time 60 -s -X GET -H "Authorization: Bearer ${accesstoken}" -H "Accept-Language: ${units}" "https://api.fitbit.com/1/user/-/body/log/weight/date/${today}/7d.json")
getSteps=$(curl --max-time 60 -s -X GET -H "Authorization: Bearer ${accesstoken}" -H "Accept-Language: ${units}" "https://api.fitbit.com/1/user/-/activities/steps/date/${today}/7d.json")
getDistance=$(curl --max-time 60 -s -X GET -H "Authorization: Bearer ${accesstoken}" -H "Accept-Language: ${units}" "https://api.fitbit.com/1/user/-/activities/distance/date/${today}/7d.json")
getFloors=$(curl --max-time 60 -s -X GET -H "Authorization: Bearer ${accesstoken}" -H "Accept-Language: ${units}" "https://api.fitbit.com/1/user/-/activities/floors/date/${today}/7d.json")
getMinutesSedentary=$(curl --max-time 60 -s -X GET -H "Authorization: Bearer ${accesstoken}" -H "Accept-Language: ${units}" "https://api.fitbit.com/1/user/-/activities/minutesSedentary/date/${today}/7d.json")
getMinutesLightlyActive=$(curl --max-time 60 -s -X GET -H "Authorization: Bearer ${accesstoken}" -H "Accept-Language: ${units}" "https://api.fitbit.com/1/user/-/activities/minutesLightlyActive/date/${today}/7d.json")
getMinutesFairlyActive=$(curl --max-time 60 -s -X GET -H "Authorization: Bearer ${accesstoken}" -H "Accept-Language: ${units}" "https://api.fitbit.com/1/user/-/activities/minutesFairlyActive/date/${today}/7d.json")
getMinutesVeryActive=$(curl --max-time 60 -s -X GET -H "Authorization: Bearer ${accesstoken}" -H "Accept-Language: ${units}" "https://api.fitbit.com/1/user/-/activities/minutesVeryActive/date/${today}/7d.json")
getCalories=$(curl --max-time 60 -s -X GET -H "Authorization: Bearer ${accesstoken}" -H "Accept-Language: ${units}" "https://api.fitbit.com/1/user/-/activities/calories/date/${today}/7d.json")
getSleep=$(curl --max-time 60 -s -X GET -H "Authorization: Bearer ${accesstoken}" -H "Accept-Language: ${units}" "https://api.fitbit.com/1.2/user/-/sleep/date/${sevenDaysAgo}/${today}.json")
getHeartrate=$(curl --max-time 60 -s -X GET -H "Authorization: Bearer ${accesstoken}" -H "Accept-Language: ${units}" "https://api.fitbit.com/1/user/-/activities/heart/date/${today}/7d.json")
# Get UTC offset for user
userOffsetFromUTCMillis=$(echo "$getProfile" | jq ".user.offsetFromUTCMillis")
# Weight
#echo -e "$getWeight" >> fitbit.txt
for row in $(echo "${getWeight}" | jq -r '.weight[] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}
measurementDate=$(echo $(_jq '.date'))
measurementTime=$(echo $(_jq '.time'))
measurementFullDate="${measurementDate} ${measurementTime} UTC"
measurementTS=$(date --date "${measurementDate}" +%s)
measurementCorrectedTS=$((((measurementTS - $((userOffsetFromUTCMillis / 1000)))) * 1000000000))
dateTodayShortDay=$(date --date "${measurementFullDate}" +%a)
dateTodayLongDay=$(date --date "${measurementFullDate}" +%A)
tags="${globalTags},shortDay=${dateTodayShortDay},longDay=${dateTodayLongDay}"
weight=$(echo $(_jq '.weight'))
bmi=$(echo $(_jq '.bmi'))
fat=$(echo $(_jq '.fat'))
echo -e "weight,$tags weight=$weight $measurementCorrectedTS" >> fitbit.txt
echo -e "weight,$tags bmi=$bmi$measurementCorrectedTS" >> fitbit.txt
echo -e "weight,$tags fat=$fat $measurementCorrectedTS" >> fitbit.txt
echo -e "weight,${tags} weight=${weight} $measurementCorrectedTS"
echo -e "weight,${tags} bmi=${bmi} $measurementCorrectedTS"
echo -e "weight,${tags} fat=${fat} $measurementCorrectedTS"
done
# Steps
#echo -e "$getSteps" >> fitbit.txt
for row in $(echo "${getSteps}" | jq -r '.["activities-steps"][] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}
measurementDate=$(echo $(_jq '.dateTime'))
measurementFullDate="${measurementDate} 0000 UTC"
measurementTS=$(date --date "${measurementDate}" +%s)
measurementCorrectedTS=$((((measurementTS - $((userOffsetFromUTCMillis / 1000)))) * 1000000000))
dateTodayShortDay=$(date --date "${measurementFullDate}" +%a)
dateTodayLongDay=$(date --date "${measurementFullDate}" +%A)
tags="${globalTags},shortDay=${dateTodayShortDay},longDay=${dateTodayLongDay}"
steps=$(echo $(_jq '.value'))
echo -e "activity,$tags steps=$steps $measurementCorrectedTS" >> fitbit.txt
echo -e "activity,${tags} steps=${steps} $measurementCorrectedTS"
done
# Calories
#echo -e "$getCalories" >> fitbit.txt
for row in $(echo "${getCalories}" | jq -r '.["activities-calories"][] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}
measurementDate=$(echo $(_jq '.dateTime'))
measurementFullDate="${measurementDate} 0000 UTC"
measurementTS=$(date --date "${measurementDate}" +%s)
measurementCorrectedTS=$((((measurementTS - $((userOffsetFromUTCMillis / 1000)))) * 1000000000))
dateTodayShortDay=$(date --date "${measurementFullDate}" +%a)
dateTodayLongDay=$(date --date "${measurementFullDate}" +%A)
tags="${globalTags},shortDay=${dateTodayShortDay},longDay=${dateTodayLongDay}"
calories=$(echo $(_jq '.value'))
echo -e "activity,$tags calories=$calories $measurementCorrectedTS" >> fitbit.txt
echo -e "activity,${tags} calories=${calories} $measurementCorrectedTS"
done
# Distance
#echo -e "$getDistance" >> fitbit.txt
for row in $(echo "${getDistance}" | jq -r '.["activities-distance"][] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}
measurementDate=$(echo $(_jq '.dateTime'))
measurementFullDate="${measurementDate} 0000 UTC"
measurementTS=$(date --date "${measurementDate}" +%s)
measurementCorrectedTS=$((((measurementTS - $((userOffsetFromUTCMillis / 1000)))) * 1000000000))
dateTodayShortDay=$(date --date "${measurementFullDate}" +%a)
dateTodayLongDay=$(date --date "${measurementFullDate}" +%A)
tags="${globalTags},shortDay=${dateTodayShortDay},longDay=${dateTodayLongDay}"
distance=$(echo $(_jq '.value'))
echo -e "activity,$tags distance=$distance $measurementCorrectedTS" >> fitbit.txt
echo -e "activity,${tags} distance=${distance} $measurementCorrectedTS"
done
# Floors
#echo -e "$getFloors" >> fitbit.txt
for row in $(echo "${getFloors}" | jq -r '.["activities-floors"][] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}
measurementDate=$(echo $(_jq '.dateTime'))
measurementFullDate="${measurementDate} 0000 UTC"
measurementTS=$(date --date "${measurementDate}" +%s)
measurementCorrectedTS=$((((measurementTS - $((userOffsetFromUTCMillis / 1000)))) * 1000000000))
dateTodayShortDay=$(date --date "${measurementFullDate}" +%a)
dateTodayLongDay=$(date --date "${measurementFullDate}" +%A)
tags="${globalTags},shortDay=${dateTodayShortDay},longDay=${dateTodayLongDay}"
floors=$(echo $(_jq '.value'))
echo -e "activity,$tags floors=$floors $measurementCorrectedTS" >> fitbit.txt
echo -e "activity,${tags} floors=${floors} $measurementCorrectedTS"
done
# Sedentary Minutes
#echo -e "$getMinutesSedentary" >> fitbit.txt
for row in $(echo "${getMinutesSedentary}" | jq -r '.["activities-minutesSedentary"][] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}
measurementDate=$(echo $(_jq '.dateTime'))
measurementFullDate="${measurementDate} 0000 UTC"
measurementTS=$(date --date "${measurementDate}" +%s)
measurementCorrectedTS=$((((measurementTS - $((userOffsetFromUTCMillis / 1000)))) * 1000000000))
dateTodayShortDay=$(date --date "${measurementFullDate}" +%a)
dateTodayLongDay=$(date --date "${measurementFullDate}" +%A)
tags="${globalTags},shortDay=${dateTodayShortDay},longDay=${dateTodayLongDay}"
minutesSedentary=$(echo $(_jq '.value'))
echo -e "activity,$tags minutesSedentary=$minutesSedentary $measurementCorrectedTS" >> fitbit.txt
echo -e "activity,${tags} minutesSedentary=${minutesSedentary} $measurementCorrectedTS"
done
# Lightly Active Minutes
#echo -e "$getMinutesLightlyActive" >> fitbit.txt
for row in $(echo "${getMinutesLightlyActive}" | jq -r '.["activities-minutesLightlyActive"][] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}
measurementDate=$(echo $(_jq '.dateTime'))
measurementFullDate="${measurementDate} 0000 UTC"
measurementTS=$(date --date "${measurementDate}" +%s)
measurementCorrectedTS=$((((measurementTS - $((userOffsetFromUTCMillis / 1000)))) * 1000000000))
dateTodayShortDay=$(date --date "${measurementFullDate}" +%a)
dateTodayLongDay=$(date --date "${measurementFullDate}" +%A)
tags="${globalTags},shortDay=${dateTodayShortDay},longDay=${dateTodayLongDay}"
minutesLightlyActive=$(echo $(_jq '.value'))
echo -e "activity,$tags minutesLightlyActive=$minutesLightlyActive $measurementCorrectedTS" >> fitbit.txt
echo -e "activity,${tags} minutesLightlyActive=${minutesLightlyActive} $measurementCorrectedTS"
done
# Fairly Active Minutes
#echo -e "$getMinutesFairlyActive" >> fitbit.txt
for row in $(echo "${getMinutesFairlyActive}" | jq -r '.["activities-minutesFairlyActive"][] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}
measurementDate=$(echo $(_jq '.dateTime'))
measurementFullDate="${measurementDate} 0000 UTC"
measurementTS=$(date --date "${measurementDate}" +%s)
measurementCorrectedTS=$((((measurementTS - $((userOffsetFromUTCMillis / 1000)))) * 1000000000))
dateTodayShortDay=$(date --date "${measurementFullDate}" +%a)
dateTodayLongDay=$(date --date "${measurementFullDate}" +%A)
tags="${globalTags},shortDay=${dateTodayShortDay},longDay=${dateTodayLongDay}"
minutesFairlyActive=$(echo $(_jq '.value'))
echo -e "activity,$tags minutesFairlyActive=$minutesFairlyActive $measurementCorrectedTS" >> fitbit.txt
echo -e "activity,${tags} minutesFairlyActive=${minutesFairlyActive} $measurementCorrectedTS"
done
# Very Active Minutes
#echo -e "$getMinutesVeryActive" >> fitbit.txt
for row in $(echo "${getMinutesVeryActive}" | jq -r '.["activities-minutesVeryActive"][] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}
measurementDate=$(echo $(_jq '.dateTime'))
measurementFullDate="${measurementDate} 0000 UTC"
measurementTS=$(date --date "${measurementDate}" +%s)
measurementCorrectedTS=$((((measurementTS - $((userOffsetFromUTCMillis / 1000)))) * 1000000000))
dateTodayShortDay=$(date --date "${measurementFullDate}" +%a)
dateTodayLongDay=$(date --date "${measurementFullDate}" +%A)
tags="${globalTags},shortDay=${dateTodayShortDay},longDay=${dateTodayLongDay}"
minutesVeryActive=$(echo $(_jq '.value'))
echo -e "activity,$tags minutesVeryActive=$minutesVeryActive $measurementCorrectedTS" >> fitbit.txt
echo -e "activity,${tags} minutesVeryActive=${minutesVeryActive} $measurementCorrectedTS"
done
# Sleep
#echo -e "$getSleep" >> fitbit.txt
for row in $(echo "${getSleep}" | jq -r '.sleep[] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}
measurementDate=$(echo $(_jq '.dateOfSleep'))
measurementFullDate="${measurementDate} 0000 UTC"
measurementTS=$(date --date "${measurementDate}" +%s)
measurementCorrectedTS=$((((measurementTS - $((userOffsetFromUTCMillis / 1000)))) * 1000000000))
dateTodayShortDay=$(date --date "${measurementFullDate}" +%a)
dateTodayLongDay=$(date --date "${measurementFullDate}" +%A)
tags="${globalTags},shortDay=${dateTodayShortDay},longDay=${dateTodayLongDay}"
deepSleepMinutes=$(echo $(_jq '.levels.summary.deep.minutes'))
lightSleepMinutes=$(echo $(_jq '.levels.summary.light.minutes'))
remSleepMinutes=$(echo $(_jq '.levels.summary.rem.minutes'))
wakeMinutes=$(echo $(_jq '.levels.summary.wake.minutes'))
durationMillis=$(echo $(_jq '.duration'))
efficiency=$(echo $(_jq '.efficiency'))
minutesAfterWakeup=$(echo $(_jq '.minutesAfterWakeup'))
minutesAsleep=$(echo $(_jq '.minutesAsleep'))
minutesAwake=$(echo $(_jq '.minutesAwake'))
minutesToFallAsleep=$(echo $(_jq '.minutesToFallAsleep'))
startTime=$(date --date $(echo $(_jq '.startTime')) +%s)
timeInBedMinutes=$(echo $(_jq '.timeInBed'))
if [ -n "$deepSleepMinutes" ]; then
deepSleepMinutes="0"
fi
if [ -n "$lightSleepMinutes" ]; then
lightSleepMinutes="0"
fi
if [ -n "$remSleepMinutes" ]; then
remSleepMinutes="0"
fi
if [ -n "$wakeMinutes" ]; then
wakeMinutes="0"
fi
echo -e "sleep,$tags deepSleepMinutes=$deepSleepMinutes $measurementCorrectedTS" >> fitbit.txt
echo -e "sleep,$tags lightSleepMinutes=$lightSleepMinutes $measurementCorrectedTS" >> fitbit.txt
echo -e "sleep,$tags remSleepMinutes=$remSleepMinutes $measurementCorrectedTS" >> fitbit.txt
echo -e "sleep,$tags wakeMinutes=$wakeMinutes $measurementCorrectedTS" >> fitbit.txt
echo -e "sleep,$tags durationMillis=$durationMillis $measurementCorrectedTS" >> fitbit.txt
echo -e "sleep,$tags efficiency=$efficiency $measurementCorrectedTS" >> fitbit.txt
echo -e "sleep,$tags minutesAfterWakeup=$minutesAfterWakeup $measurementCorrectedTS" >> fitbit.txt
echo -e "sleep,$tags minutesAsleep=$minutesAsleep $measurementCorrectedTS" >> fitbit.txt
echo -e "sleep,$tags minutesAwake=$minutesAwake $measurementCorrectedTS" >> fitbit.txt
echo -e "sleep,$tags minutesToFallAsleep=$minutesToFallAsleep $measurementCorrectedTS" >> fitbit.txt
echo -e "sleep,$tags startTime=$startTime $measurementCorrectedTS" >> fitbit.txt
echo -e "sleep,$tags timeInBedMinutes=$timeInBedMinutes $measurementCorrectedTS" >> fitbit.txt
echo -e "sleep,${tags} deepSleepMinutes=${deepSleepMinutes} $measurementCorrectedTS"
echo -e "sleep,${tags} lightSleepMinutes=${lightSleepMinutes} $measurementCorrectedTS"
echo -e "sleep,${tags} remSleepMinutes=${remSleepMinutes} $measurementCorrectedTS"
echo -e "sleep,${tags} wakeMinutes=${wakeMinutes} $measurementCorrectedTS"
echo -e "sleep,${tags} durationMillis=${durationMillis} $measurementCorrectedTS"
echo -e "sleep,${tags} efficiency=${efficiency} $measurementCorrectedTS"
echo -e "sleep,${tags} minutesAfterWakeup=${minutesAfterWakeup} $measurementCorrectedTS"
echo -e "sleep,${tags} minutesAsleep=${minutesAsleep} $measurementCorrectedTS"
echo -e "sleep,${tags} minutesAwake=${minutesAwake} $measurementCorrectedTS"
echo -e "sleep,${tags} minutesToFallAsleep=${minutesToFallAsleep} $measurementCorrectedTS"
echo -e "sleep,${tags} startTime=${startTime} $measurementCorrectedTS"
echo -e "sleep,${tags} timeInBedMinutes=${timeInBedMinutes} $measurementCorrectedTS"
done
# Heartrate
#echo -e "$getHeartrate" >> fitbit.txt
for row in $(echo "${getHeartrate}" | jq -r '.["activities-heart"][] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}
measurementDate=$(echo $(_jq '.dateTime'))
measurementFullDate="${measurementDate} 0000 UTC"
measurementTS=$(date --date "${measurementDate}" +%s)
measurementCorrectedTS=$((((measurementTS - $((userOffsetFromUTCMillis / 1000)))) * 1000000000))
dateTodayShortDay=$(date --date "${measurementFullDate}" +%a)
dateTodayLongDay=$(date --date "${measurementFullDate}" +%A)
tags="${globalTags},shortDay=${dateTodayShortDay},longDay=${dateTodayLongDay},resolution=day"
restingHeartrate=$(echo $(_jq '.value.restingHeartRate'))
if [ "$restingHeartrate" -eq "$restingHeartrate" ] 2>/dev/null; then
echo -e "heartrate,$tags restingHeartrate=$restingHeartrate $measurementCorrectedTS" >> fitbit.txt
echo -e "heartrate,${tags} restingHeartrate=${restingHeartrate} $measurementCorrectedTS"
fi
for zone in $(echo $(_jq '.value') | jq -r '.heartRateZones[] | @base64'); do
_zone() {
echo ${zone} | base64 --decode | jq -r ${1}
}
caloriesOut=$(echo $(_zone '.caloriesOut'))
max=$(echo $(_zone '.max'))
min=$(echo $(_zone '.min'))
minutes=$(echo $(_zone '.minutes'))
name=$(echo $(_zone '.name') | tr -d '[:space:]')
if [ "$caloriesOut" = "null" ]; then
caloriesOut=0
fi
if [ "$minutes" = "null" ]; then
minutes=0
fi
echo -e "heartrate,$tags,zone=$name caloriesOut=$caloriesOut $measurementCorrectedTS" >> fitbit.txt
echo -e "heartrate,$tags,zone=$name max=$max $measurementCorrectedTS" >> fitbit.txt
echo -e "heartrate,$tags,zone=$name min=$min $measurementCorrectedTS" >> fitbit.txt
echo -e "heartrate,$tags,zone=$name minutes=$minutes $measurementCorrectedTS" >> fitbit.txt
echo -e "heartrate,${tags},zone=${name} caloriesOut=${caloriesOut} $measurementCorrectedTS"
echo -e "heartrate,${tags},zone=${name} max=${max} $measurementCorrectedTS"
echo -e "heartrate,${tags},zone=${name} min=${min} $measurementCorrectedTS"
echo -e "heartrate,${tags},zone=${name} minutes=${minutes} $measurementCorrectedTS"
done
done