-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Screen time values incorrect - timezone issue #3
Comments
This is interesting, thanks for identifying that. I think it would be much more likely the API is using UTC and perhaps doesn't account for timezones. Although I don't think a timezone is ever sent from the mobile app so I'm curious as to how that is handling timezones (maybe converting UTC to local before sending the request?) I'm in the UK myself so its not something I can easily replicate / test with on my devices. 2nd issue should be easy to fix though I think. |
Actually 2nd issue is intended otherwise if you were to issue a query for previous days, it would overwrite the current screentime. |
Ok, I see the problem. The mobile app does in fact send the timezone in the requests (ISO8601 format), however customised slightly in that the API does not accept the separator in the timezone section (00:00 is not accepted, 0000 is however). |
These two issues are related. If you convert to UTC before sending the request, that means you are reliant on the time component of the date time. This is what I tried to do manually by sending a request with 5am as the start_time (which is backing out the 5 hours from midnight). However from all of my testing, the time is ignored. I am not sure if the time is improperly formatted? In any case, as noted, the time returned seems to always account from midnight. As is, it's not possible to account for timezones. |
fix Screen time values incorrect - timezone issue #3 update application client ID pantherale0/ha-familysafety#35
module version 0.3.0 should fix this (plus auth issue). We're always going to be reliant on the timezones for this. But its not like we are rewriting the time directly (eg 00:00 to 23:00 for UTC-1), instead it will append the timezone to the end. At least I'm hoping thats all the mobile app does. Will release a beta of the HA integration for testing. |
Could you try latest beta please and let us know how you get on? https://github.com/pantherale0/ha-familysafety/releases/tag/1.2.0 |
I just tested the module and it looks like it's now returning the correct screen time usage data! I also tested the auth URL, and everything seems to be working. Thanks @pantherale0. |
As described in the home assistant integration issue the screen time values are not returning expected results and matched by the Family Safety app and other independent sources.
I think I've identified two problems:
pyfamilysafety.api DEBUG: Request to https://mobileaggregator.family.microsoft.com/api/v4/activityReport/appUsage/<redacted>?beginTime=2024-02-24T05:00:00Z&endTime=2024-02-24T23:59:59Z status code 200
2024-02-24 16:48:18 pyfamilysafety.account DEBUG: extra logging {"dailyDeviceUsage": [{"timeUsed": 11520000, "date": "2024-02-24T00:00:00", "deviceScreenTimeUsages": [{"deviceId": "<redacted>", "deviceName": "<redacted>", "platform": "Windows", "timeUsed": 11520000}]}], "deviceUsageAggregates": {"dailyAverage": 11520000.0, "totalScreenTime": 11520000, "otherDevicesCount": 0, "deviceAggregates": [{"deviceId": "<redacted>", "deviceName": "<redacted>", "platform": "Windows", "timeUsed": 11520000}]}, "connectedDevices": {"totalConnectedDevicesCount": 2, "otherConnectedDevicesCount": 0, "connectedDeviceAggregate": [{"deviceId": "g:<redacted>", "deviceName": "<redacted>", "platform": "Windows"}, {"deviceId": "g:<redacted>", "deviceName": "<redacted>", "platform": "Windows"}]}}
The text was updated successfully, but these errors were encountered: