iOS Widgets with Scriptable

After creating a script for updating wellness data with the Scriptable App (Update Wellness Data with Scriptable iOS Widgets), I created a set of widgets that provide a quick summary of my recent activity, eliminating the need to open a separate app for a brief overview.

You see all metrics of the last ride:

Widgets with Time in Zone for Power and HR
image

Another widget with Power and HR Histogram (all of course of the latest activity):
image

A power duration curve for the last ride and the last 42 days in comparison.
image

A widget for the weekly distribution of distance, load, time or work.
image

Made another widget, with Totals (and Max) of distance, climbing, training time of the last year:
image

Finally of course a fitness chart.
image

The templates are on GitHub.

I will probably do one or two more. But didn’t get the time until now :smiley:

This is for iOS and iPadOS, as Scriptable is iOS only (as far as I know).

2 Likes

Hi, I got your other script to work (to update wellness data). I like the idea of using scriptable for this type of widgets, great idea! I can’t get it to work though, I tried “Fitness Chart.js” but it won’t load. I editted the athleteID and API_key variables. Pressing the script to run results in a interacting button, but no result (no errors either).

Could you add a

console.log(res)

In the getData() function:

Press play and check the (1) if there is an access denied error or if you got fitness data

I must’ve made a mistake earlier. Adding the log worked, it now shows me the graph perfectly. If I then remove the logging line, it still works. My bad. To make use of all the graphs you’ve created, I must update the API_KEY and userID in all files?

1 Like

Great that it works now. :slight_smile:

Yes exactly!

Additionally the TiZ and the histogram widgets has the option for parameters. Add 1 for power and 2 for heartrate

Note: I’m not a professional programmer. Would it be possible to create a shared config.js file that contains the API_KEY and userID, and then refer to config.js from the other files?

const { API_KEY, userID } = require('./config');
Maybe something like this?

Yeah. Thought of that too, as you asked. Will probably add that. Then it’s even easier to share those scripts (without accidentally publishing the credentials)

1 Like

This is done now. I’ve updated the scripts and added a description for all widgets.

I’ve updated the overview of the last activity. Couldn’t remember what icon is what, so added a description of the fields. :smiley:
Additionaly if you did the route during the last year more than once, it will check your position on this route. It will show a medal, if you are 1., 2. or 3. place on this route.
image

Finally added a script with weekly distribution of e.g. distance. (see first post for more).

1 Like

I have synced your git and updated the config file. That seems to work now, but not for all scripts.

  • Power curve; it “runs” but doesn’t return a result (I just see the button “activate”, but nothing else)
  • Activity Fields; exception occurred. Error on line 47:92: TypeError: null is not an object (evaluating ‘activity.icu_efficiency_factor.toFixed’)
  • Totals year; shows me “Total 2024”, all values are 0 though
  • Intervals; it “runs” but doesn’t return a result (I just see the button “activate”, but nothing else)
  • Activity Fields Big; Error on line 49:382: TypeError: null is not an object (evaluating ‘(activity.icu_power_hr_z2).toFixed’)
  • Fitness chart; works as expected, shows Fitness, Fatigue and Form and corresponding graph
  • Activity Histogram; Error on line 76:39 TypeError: null is not an object (evaluating ‘activity.icu_power_zones.map’)
  • Totals to date; runs, but shows “No activity found.”
  • Totals weekly; works as expected, shows bar chart of this weeks distance per day
  • Activity TiZ; Error on line 54:43 TypeError: null is not an object (evaluating ‘activity.icu_zone_times.map’)

Is this enough information to debug?

Edit: looking back at post #1, it might have something to do with the fact that I don’t have any cycling activities (I don’t have a watch that logs power for running, skiing, weightlifting/workouts, hiit).

This won’t show anything, if you have no power data.

Should be fixed now.

There was a filter active for only cycling activities. I have disabled this.

It won’t do anything. It is the script with the credentials to share these with the other scripts :slight_smile:

Should be fixed now.

Should be fixed now.

Again I disabled the filter by default.

Should be fixed too.

Don’t know if it is working well for your activities. I do just running and cycling with power and hr. :slight_smile:

1 Like