I am experimenting with a watch face that shows some historical HR metrics (times spent in specified user set ranges) for the present day. I have the face and settings sorted out and everything seems to work when using the watch face when going about day to day business.
This morning, I did a workout and logged it as an activity on the watch (i.e., I started a treadmill activity). After saving that and returning to my watch face, none of the HRs from that session were processed in the history of the watch face.
The face uses getHeartRateHistory to get a sample of HR's. The sample range either starts from midnight (if the face is just initialising) or starts from the time getHeartRateHistory was last called (Time.Moment stored as a var). This idea being it prevents the need to read and process the entire day's HRs every time the function is called.
Now, my issue could be
1 - The HR data from the stored treadmill activity is not 'kept' in the same place as getHeartRateHistory accesses which would explain why my workout HRs were not processed. - I think this would mean what I am trying to do is not feasible since to do it reliably would require a web API call which a watchface can't do.
2 - The watch face function calling getHeartRateHistory is still called despite the watchface no longer being in the foreground but fails to get the HRs (perhaps they are not available during Activities?). But the failed call still updates the var where it stores the time getHeartRateHistory was called. The upshot of this would be that when the watchface is back in the foreground it only calls for history since the last time stamp and so none of the activity HRs are processed.
3 - Some other coding error of mine
Because this relies on the interplay of different screens, I am working on a real device which, in turn, is fiendishly difficult to debug - so any suggestions welcome.
Also Is there a set of documents that explains the technical aspects of things like heart rate history and activities? I have read (somewhere on here I think) that getHeartRateHistory is essentially reset if the watch reboots but can find precious little other information. The API docs give its usage but not (for example) how long a data set it will store (does it reset to 0 items after a sync or does it always store the current day for example).
Any help/advice is greatly appreciated.