I've MiTM'd the Zepp life so now have details of the requests used to capture some of the metrics that the app visualises.
The Stress event type gives a read out of stress level by time:
band_data_url=f"https://api-mifit-de2.zepp.com/users/{auth_info['token_info']['user_id']}/events"
headers={
'apptoken': auth_info['token_info']['app_token'],
}
get_data={
"limit" : 1000,
"from" : '0',
"to" : '1691103600000',
"eventType" : "all_day_stress"
}
The response looks like this
{
"items": [
{
"userId": "<redacted>",
"eventType": "all_day_stress",
"subType": "all_day_stress",
"timestamp": 1690844400001,
"deviceType": "0",
"minStress": "37",
"mediumProportion": "10",
"maxStress": "62",
"data": "[{\"time\":1690902960000,\"value\":59},{\"time\":1690903260000,\"value\":48},{\"time\":1690904460000,\"value\":62},{\"time\":1690906260000,\"value\":58},{\"time\":1690907160000,\"value\":53},{\"time\":1690907760000,\"value\":57},{\"time\":1690908060000,\"value\":49},{\"time\":1690908660000,\"value\":44},{\"time\":1690908960000,\"value\":37},{\"time\":1690909260000,\"value\":40}]",
"relaxProportion": "10",
"deviceId": "<redacted>",
"deviceSn": "<redacted>",
"avgStress": "50",
"highProportion": "0",
"deviceSource": "256",
"deviceMac": "<redacted>",
"normalProportion": "80"
}
]
}
There is also a single_stress
event type, but it doesn't return any values for my account.
Activity
03-Aug-23 14:30
assigned to @btasker
03-Aug-23 14:32
changed the description
03-Aug-23 15:57
One curious thing I've noticed: the API is only currently giving me results from the 1st of August. There's nothing for today or yesterday.
The
Zepp
app, however does show levels for those days.It might be that it only syncs the data periodically - the API does seem to be a little finickity about the timestamps used in
from
andto
. Unless a timestamp of midnight is used, results for the specified day won't be included at all.I'll have to check tomorrow whether yesterday's readings are suddenly available.
I don't get any change in result if I use a
from
value of 0 so... shrug03-Aug-23 15:58
I'm adding two types of series.
There's the daily cumulative tracker:
and there's another for the readings that are taken through the day
03-Aug-23 16:00
mentioned in commit e1fc36ac1f7790f9c61e6d2dc25ed9df65fb85c1
Message
Collect stress level information (utilities/zepp_to_influxdb#1)
This collects the stress readings submitted by the watch.
Values seem to lag behind by quite a bit though - the most recent value available to me at the moment is a couple of days behind.
03-Aug-23 16:06
Although this is implemented, I'm not going to close this until I've checked whether data is catching up (a couple of days lag isn't great, but it's still better than rolling something out that can't actually collect data).
03-Aug-23 16:18
Oh, actually, they've just shown up
I guess the app had issues syncing for some reason - I'd signed out and back in. It does seem like it expects you to open the app to trigger a sync once a day or so. Might have to see whether we can do anything about that.
03-Aug-23 16:18
As the data's shown up, I'm going to close this as done.