project Utilities / zepp_to_influxdb avatar

utilities/zepp_to_influxdb#7: Capture PAI Scores



Issue Information

Issue Type: issue
Status: closed
Reported By: btasker
Assigned To: btasker

Milestone: v0.4
Created: 08-Aug-23 16:45



Description

Zepp captures and tracks a Personal Activity Intelligence (PAI) score - it's essentially a normalised indicator of the impact that your activities are having on your body.

It's scored across a rolling 7 days and it's recommended you try and keep the score above 100.

The scores can be retrieved with

  • Domain: api-mifit.zepp.com
  • Path: /users/{user id}/events

Query String:

  • limit (set to 1000)
  • from (epoch ms timestamp)
  • to (epoch ms timestamp)
  • eventType (PaiHealthInfo)

The resulting JSON response looks like this

{
  "items": [
    {
      "userId": "<redacted>",
      "eventType": "PaiHealthInfo",
      "subType": "PaiHealthInfo",
      "timestamp": 1690844400000,
      "date": "2023-08-01",
      "activityScores": "[0.0010464523220434785,0.018166501075029373,0,0,0,0,0]",
      "mediumZoneLowerLimit": "113",
      "mediumZonePai": "5.233584",
      "gender": "0",
      "deviceId": "<redacted>",
      "lowZoneLowerLimit": "102",
      "sn": "<redacted>",
      "mediumZoneMinutes": "61",
      "totalPai": "6.1129966",
      "maxHr": "188",
      "uploadTimestamp": "1690973126763",
      "highZonePai": "0.0",
      "timeZone": "4",
      "index": "1",
      "version": "5",
      "lowZonePai": "0.54343665",
     "restHr": "65",
      "nextActivityScores": "[6.112996578216553,6.112996578216553,6.112996578216553,6.112996578216553,6.112996578216553,6.112996578216553,5.783071041107178]",
      "dailyPai": "5.7770205",
      "highZoneLowerLimit": "150",
      "deviceSource": "256",
      "time": "1690930790000",
      "lowZoneMinutes": "46",
      "highZoneMinutes": "0",
      "age": "38"
    }
  ]
}

With one entry in items per day



Toggle State Changes

Activity


assigned to @btasker

It probably doesn't make sense to capture each activity score in activityScores, so instead we'll capture a count of the number of scoreable activities ```python "scorable_activities" : len(item['activityScores']), ````

This is actually going to add quite a few fields, before the next release, it might be worth revisiting #5

Heart rate measurements

Broken up into several series:

Field:

  • heart_rate (integer)

Tags:

  • PAI_measure : daily
  • hr_measure : PAI
  • hr_state (one of max, resting)

PAI scores, durations and bounds

split across series

Fields

  • activity_duration_m (integer)
  • pai_score_bound (integer)
  • pai_score (float)

Tags:

  • PAI_measure : daily
  • PAI_bound : (one of low, medium, high)

Daily PAI stats

Fields:

  • scorable_activities (integer)
  • pai_score (float)
  • total_pai (float)

Tags:

  • PAI_measure : daily
  • PAI_bound : daily

I do worry a little that the hr_state tag is going to be confusing when looking at non PAI heart-rate data.

verified

mentioned in commit 133e3be6ac1668eef71621fdb6cc9121a8734e3a

Commit: 133e3be6ac1668eef71621fdb6cc9121a8734e3a 
Author: B Tasker                            
                            
Date: 2023-08-08T17:55:03.000+01:00 

Message

Collect PAI data (utilities/zepp_to_influxdb#7)

First implementation of PAI data collection. See code or Gitlab issue for resulting data schema

+135 -0 (135 lines changed)