|
mrg@TPXT:~/mc$ # http - https://httpie.org/ - a user-friendly command-line HTTP client for the API era |
|
mrg@TPXT:~/mc$ # jq - https://stedolan.github.io/jq/ - a lightweight and flexible command-line JSON processor |
|
mrg@TPXT:~/mc$ # starting with a clean profile, restored defaults watch values at movescount.com |
|
mrg@TPXT:~/mc$ # load variables |
|
mrg@TPXT:~/mc$ . mc_env.sh |
|
mrg@TPXT:~/mc$ # encode Workout json |
|
mrg@TPXT:~/mc$ jq -rc . 00-myworkout.json | base64 -w0 > 01-myworkout.base64 |
|
mrg@TPXT:~/mc$ # replace Name and Source in rule template |
|
mrg@TPXT:~/mc$ sed -e "s/RULE_NAME/My Workout/g" -e "s/RULE_SRC/$(<01-myworkout.base64)/g" < 10-rule_template.json > 02-myworkout_rule.json |
|
mrg@TPXT:~/mc$ # list active Workouts (guidance type rules) |
|
mrg@TPXT:~/mc$ http get https://uiservices.movescount.com/userdevices/$AMBIT_SN/rules type==guidance appkey=="$APPKEY" userkey=="$USERKEY" email=="$MCUMAIL" User-Agent:"$MCUAGENT" | jq ".[] | del(.Binary, .Source)" |
|
{ |
|
"ActivityID": 1, |
|
"Category": "guidance", |
|
"Description": null, |
|
"IsPublic": false, |
|
"LastModifiedDate": "2020-08-01T19:02:04.3", |
|
"Name": "uus", |
|
"OutputFormat": "onedecimal", |
|
"Postfix": null, |
|
"Prefix": null, |
|
"RuleID": 13644506, |
|
"SelfURI": "rules/13644506", |
|
"TargetVirtualMachineVersion": "0.08, build 15.8.18.0", |
|
"Type": "guidance" |
|
} |
|
{ |
|
"ActivityID": 1, |
|
"Category": "guidance", |
|
"Description": null, |
|
"IsPublic": false, |
|
"LastModifiedDate": "2020-08-01T13:37:36.0", |
|
"Name": "goobay", |
|
"OutputFormat": "onedecimal", |
|
"Postfix": null, |
|
"Prefix": null, |
|
"RuleID": 13644368, |
|
"SelfURI": "rules/13644368", |
|
"TargetVirtualMachineVersion": "0.08, build 15.8.18.0", |
|
"Type": "guidance" |
|
} |
|
mrg@TPXT:~/mc$ # list all Workouts (guidance type rules) |
|
mrg@TPXT:~/mc$ http get https://uiservices.movescount.com/rules/private type==guidance appkey=="$APPKEY" userkey=="$USERKEY" email=="$MCUMAIL" User-Agent:"$MCUAGENT" | jq ".[] | del(.Binary, .Source)" |
|
{ |
|
"ActivityID": 1, |
|
"Category": "guidance", |
|
"Description": null, |
|
"IsPublic": false, |
|
"LastModifiedDate": "2020-08-01T20:29:25.9", |
|
"Name": "k6igeuuem", |
|
"OutputFormat": "onedecimal", |
|
"Postfix": null, |
|
"Prefix": null, |
|
"RuleID": 13644540, |
|
"SelfURI": "rules/13644540", |
|
"TargetVirtualMachineVersion": "0.08, build 15.8.18.0", |
|
"Type": "guidance" |
|
} |
|
{ |
|
"ActivityID": 1, |
|
"Category": "guidance", |
|
"Description": null, |
|
"IsPublic": false, |
|
"LastModifiedDate": "2020-08-01T19:02:04.3", |
|
"Name": "uus", |
|
"OutputFormat": "onedecimal", |
|
"Postfix": null, |
|
"Prefix": null, |
|
"RuleID": 13644506, |
|
"SelfURI": "rules/13644506", |
|
"TargetVirtualMachineVersion": "0.08, build 15.8.18.0", |
|
"Type": "guidance" |
|
} |
|
{ |
|
"ActivityID": 1, |
|
"Category": "guidance", |
|
"Description": null, |
|
"IsPublic": false, |
|
"LastModifiedDate": "2020-08-01T13:37:36.0", |
|
"Name": "goobay", |
|
"OutputFormat": "onedecimal", |
|
"Postfix": null, |
|
"Prefix": null, |
|
"RuleID": 13644368, |
|
"SelfURI": "rules/13644368", |
|
"TargetVirtualMachineVersion": "0.08, build 15.8.18.0", |
|
"Type": "guidance" |
|
} |
|
mrg@TPXT:~/mc$ # add new workout |
|
mrg@TPXT:~/mc$ jq -cr . 02-myworkout_rule.json | http post https://uiservices.movescount.com/rules/ appkey=="$APPKEY" userkey=="$USERKEY" email=="$MCUMAIL" User-Agent:"$MCUAGENT" |
|
HTTP/1.1 201 Created |
|
Cache-Control: no-cache |
|
Connection: keep-alive |
|
Content-Length: 47 |
|
Content-Type: application/json; charset=utf-8 |
|
Date: Wed, 30 Sep 2020 19:15:57 GMT |
|
Expires: -1 |
|
Pragma: no-cache |
|
Server: Microsoft-IIS/8.5 |
|
Via: 1.1 f9fdb36a35b271b2043714f4c4655495.cloudfront.net (CloudFront) |
|
X-Amz-Cf-Id: kPMYYmeCvnvHqK7gHRmkdUwvDiwEeTTyiw8AB3V3NM8Rp58Kc21TjQ== |
|
X-Amz-Cf-Pop: ARN53 |
|
X-AspNet-Version: 4.0.30319 |
|
X-Cache: Miss from cloudfront |
|
X-Powered-By: ASP.NET |
|
|
|
{ |
|
"RuleID": 13670761, |
|
"RuleURI": "rules/13670761" |
|
} |
|
|
|
mrg@TPXT:~/mc$ # list all Workouts (guidance type rules), new rule should be added |
|
mrg@TPXT:~/mc$ http get https://uiservices.movescount.com/rules/private type==guidance appkey=="$APPKEY" userkey=="$USERKEY" email=="$MCUMAIL" User-Agent:"$MCUAGENT" | jq ".[] | del(.Binary, .Source)" |
|
{ |
|
"ActivityID": 1, |
|
"Category": "guidance", |
|
"Description": null, |
|
"IsPublic": false, |
|
"LastModifiedDate": "2020-09-30T19:15:56.4", |
|
"Name": "My Workout", |
|
"OutputFormat": "onedecimal", |
|
"Postfix": null, |
|
"Prefix": null, |
|
"RuleID": 13670761, |
|
"SelfURI": "rules/13670761", |
|
"TargetVirtualMachineVersion": "0.08, build 15.8.18.0", |
|
"Type": "guidance" |
|
} |
|
{ |
|
"ActivityID": 1, |
|
"Category": "guidance", |
|
"Description": null, |
|
"IsPublic": false, |
|
"LastModifiedDate": "2020-08-01T20:29:25.9", |
|
"Name": "k6igeuuem", |
|
"OutputFormat": "onedecimal", |
|
"Postfix": null, |
|
"Prefix": null, |
|
"RuleID": 13644540, |
|
"SelfURI": "rules/13644540", |
|
"TargetVirtualMachineVersion": "0.08, build 15.8.18.0", |
|
"Type": "guidance" |
|
} |
|
{ |
|
"ActivityID": 1, |
|
"Category": "guidance", |
|
"Description": null, |
|
"IsPublic": false, |
|
"LastModifiedDate": "2020-08-01T19:02:04.3", |
|
"Name": "uus", |
|
"OutputFormat": "onedecimal", |
|
"Postfix": null, |
|
"Prefix": null, |
|
"RuleID": 13644506, |
|
"SelfURI": "rules/13644506", |
|
"TargetVirtualMachineVersion": "0.08, build 15.8.18.0", |
|
"Type": "guidance" |
|
} |
|
{ |
|
"ActivityID": 1, |
|
"Category": "guidance", |
|
"Description": null, |
|
"IsPublic": false, |
|
"LastModifiedDate": "2020-08-01T13:37:36.0", |
|
"Name": "goobay", |
|
"OutputFormat": "onedecimal", |
|
"Postfix": null, |
|
"Prefix": null, |
|
"RuleID": 13644368, |
|
"SelfURI": "rules/13644368", |
|
"TargetVirtualMachineVersion": "0.08, build 15.8.18.0", |
|
"Type": "guidance" |
|
} |
|
mrg@TPXT:~/mc$ # list active Workouts (guidance type rules), same - adding a rule does not change device settings |
|
mrg@TPXT:~/mc$ http get https://uiservices.movescount.com/userdevices/$AMBIT_SN/rules type==guidance appkey=="$APPKEY" userkey=="$USERKEY" email=="$MCUMAIL" User-Agent:"$MCUAGENT" | jq ".[] | del(.Binary, .Source)" |
|
{ |
|
"ActivityID": 1, |
|
"Category": "guidance", |
|
"Description": null, |
|
"IsPublic": false, |
|
"LastModifiedDate": "2020-08-01T19:02:04.3", |
|
"Name": "uus", |
|
"OutputFormat": "onedecimal", |
|
"Postfix": null, |
|
"Prefix": null, |
|
"RuleID": 13644506, |
|
"SelfURI": "rules/13644506", |
|
"TargetVirtualMachineVersion": "0.08, build 15.8.18.0", |
|
"Type": "guidance" |
|
} |
|
{ |
|
"ActivityID": 1, |
|
"Category": "guidance", |
|
"Description": null, |
|
"IsPublic": false, |
|
"LastModifiedDate": "2020-08-01T13:37:36.0", |
|
"Name": "goobay", |
|
"OutputFormat": "onedecimal", |
|
"Postfix": null, |
|
"Prefix": null, |
|
"RuleID": 13644368, |
|
"SelfURI": "rules/13644368", |
|
"TargetVirtualMachineVersion": "0.08, build 15.8.18.0", |
|
"Type": "guidance" |
|
} |
|
mrg@TPXT:~/mc$ # replace old workout list with a new rule 13670761 |
|
mrg@TPXT:~/mc$ # set watch S/N and rule list in settings template, pipe through httpie |
|
mrg@TPXT:~/mc$ sed -e "s/AMBIT_SN/$AMBIT_SN/g" -e "s/RULE_ID_LIST/13670761/g" < 20-settings_template.json | jq -cr . | |
|
> http put https://uiservices.movescount.com/userdevices/$AMBIT_SN/ resetchangedsettings==true appkey=="$APPKEY" userkey=="$USERKEY" email=="$ |
|
MCUMAIL" User-Agent:"$MCUAGENT" |
|
HTTP/1.1 200 OK |
|
Cache-Control: no-cache |
|
Connection: keep-alive |
|
Content-Length: 0 |
|
Date: Wed, 30 Sep 2020 19:38:23 GMT |
|
Expires: -1 |
|
Pragma: no-cache |
|
Server: Microsoft-IIS/8.5 |
|
Via: 1.1 482a78f386817c034ae15d18a92d3c98.cloudfront.net (CloudFront) |
|
X-Amz-Cf-Id: vT95S1LInskSGKpFrEwaEMW62P0rwI7jST2n-Y7ELYvscs5tQETCIw== |
|
X-Amz-Cf-Pop: ARN53 |
|
X-AspNet-Version: 4.0.30319 |
|
X-Cache: Miss from cloudfront |
|
X-Powered-By: ASP.NET |
|
|
|
|
|
|
|
mrg@TPXT:~/mc$ # list active Workouts (guidance type rules) |
|
mrg@TPXT:~/mc$ http get https://uiservices.movescount.com/userdevices/$AMBIT_SN/rules type==guidance appkey=="$APPKEY" userkey=="$USERKEY" email=="$MCUMAIL" User-Agent:"$MCUAGENT" | jq ".[] | del(.Binary, .Source)" |
|
{ |
|
"ActivityID": 1, |
|
"Category": "guidance", |
|
"Description": null, |
|
"IsPublic": false, |
|
"LastModifiedDate": "2020-09-30T19:15:56.4", |
|
"Name": "My Workout", |
|
"OutputFormat": "onedecimal", |
|
"Postfix": null, |
|
"Prefix": null, |
|
"RuleID": 13670761, |
|
"SelfURI": "rules/13670761", |
|
"TargetVirtualMachineVersion": "0.08, build 15.8.18.0", |
|
"Type": "guidance" |
|
} |
|
mrg@TPXT:~/mc$ |
Hey I just created few very simple scripts to upload and download workouts following your steps.
Check here: https://gist.github.com/dgvalde/4bb9a9dc2162c27440a978b217c01b7e
Many thanks!
P.D: I notice that you have a typo on the http calls. You have $MCUMAIL instead of $MCMAIL. Anyhow, it seems it still works without email.