Open Kam5678 opened 11 months ago
I have the same issue. Almost all data comes from the Apple Watch. But sometimes - I can't see a pattern - there are totaled data from the iPhone that includes the data from the watch. This of course leads to incorrect results in the total.
For the following data, I call the following function:
And get the following data: (I excluded deviceID, sourceID)
To get an Idea of how the data looks on my phone:
On Dec 16 - 17: 00:52 -> 7:28 On Dec 17 -18 : 23:53 -> 6:00
THE PROBLEM:
So after doing some debugging, the problem is that there seem's to be two instances of Sleep_In_Bed data being saved in the list returned for SLEEP_IN_BED data. One comes from the Sleep schedule feature, where your iphone schedules your sleep time, and the other are entries from your apple watch. This causes there to be overlap of sleep data, and thus summing the list causes an inaccurate answer to be produced, that is way over the actual sleep in bed time spent.
The only difference that can be noticed is that the source name will diffrentiate between iphone and apple watch, so I thought I could use this to my advantage, BUT:
In case the user changes their name for their iphone or apple watch, to something that doesn't have these keywords, then there is no way of knowing which data for SLEEP_IN_BED is for which device.
I haven't included deviceID and sourceID in this example for privacy reasons, but from my data I have seen the deviceID is always the same but source id is different:
for iPhone: com.apple.health.739... for Apple watch: com.apple.health.FD5....
Is there some sort of convention for this? I don't think sourceID depends at all on the device model though, so I don't think it will work?
Or some better way to to diffrentiate between both types of data?
Model: IPHONE 15 PRO