Computed activity fields

I want to capture the first value from multi-value field available in device_info.

lets say my test fit file column have multi value like these:

70
69

either using device_info.field or device_info.field[0], always gives me 69, I need to pull 70, any ideas?

thanks

You need to tick the “Processed fit file messages” box and use a script:

{
  let level
  for (let di of icu.fit.device_info) {
    if (di.manufacturer?.value !== 23 /* Suunto*/) continue
    console.log("di " + di)
    let v = di.battery_level?.value
    if (typeof v === 'number' && (!level || v < level)) level = v
  }
  level
}

In this case I have chosen the lowest value. The console log looks like this:

di timestamp(s)=1075909291,battery_voltage(V)=4.05078125,battery_level(%)=70,manufacturer=23,product=59,product_name=Suunto Vertical
di timestamp(s)=1075909479,battery_voltage(V)=4.05078125,battery_level(%)=69,manufacturer=23,product=59,product_name=Suunto Vertical
di timestamp(s)=1075912229,battery_voltage(V)=4.03125,battery_level(%)=68,manufacturer=23,product=59,product_name=Suunto Vertical
1 Like

Yay… Wrote my 1st Java Script :stuck_out_tongue:

Screenshot 2024-02-28 at 10.05.26 AM

3 Likes