Account¶
pyfamilysafety.account.Account ¶
Account(api)
A family member with Digital Safety enabled.
Attributes:
| Name | Type | Description |
|---|---|---|
user_id |
Microsoft member identifier. |
|
role |
Family role from the roster API. |
|
first_name |
Member first name. |
|
surname |
Member last name. |
|
profile_picture |
Profile image URL. |
|
devices |
list[Device]
|
Registered devices, populated by :meth: |
applications |
list[Application]
|
Apps from the activity report, populated by :meth: |
schedule |
dict
|
The current screentime schedule for each device type. |
today_screentime_usage |
int
|
Total device screen time today in milliseconds. |
average_screentime_usage |
float
|
Daily average screen time from the API. |
screentime_usage |
dict
|
Raw device screen-time report JSON. |
application_usage |
dict
|
Raw app activity report JSON. |
blocked_platforms |
list[OverrideTarget]
|
Platforms with an active device override block. |
account_balance |
float
|
Microsoft Store allowance balance when available. |
account_currency |
str
|
Currency code for |
experimental |
bool
|
Mirrors the parent :class: |
Init an account.
Source code in pyfamilysafety/account.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
to_json ¶
to_json(indent=2)
Returns all public account fields as a pretty-printed JSON string.
Source code in pyfamilysafety/account.py
64 65 66 67 68 69 70 71 72 73 74 75 | |
add_account_callback ¶
add_account_callback(callback)
Add a callback to the account.
Source code in pyfamilysafety/account.py
77 78 79 80 81 82 | |
remove_account_callback ¶
remove_account_callback(callback)
Remove a given account callback.
Source code in pyfamilysafety/account.py
84 85 86 87 88 89 | |
update
async
¶
update()
Update all account details.
Source code in pyfamilysafety/account.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
get_screentime_usage
async
¶
get_screentime_usage(start_time=None, end_time=None, device_count=4, platform='ALL')
Return screen time usage for a time range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_time
|
datetime
|
Range start; defaults to start of today (local). |
None
|
end_time
|
datetime
|
Range end; defaults to end of today (local). |
None
|
device_count
|
int
|
Maximum devices in the device usage report. |
4
|
platform
|
str
|
Platform filter (e.g. |
'ALL'
|
Returns:
| Type | Description |
|---|---|
dict
|
When default times are used, returns cached |
dict
|
updating account fields. Otherwise a dict with |
dict
|
|
Source code in pyfamilysafety/account.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | |
get_device ¶
get_device(device_id)
Returns a single device.
Source code in pyfamilysafety/account.py
256 257 258 | |
get_application ¶
get_application(application_id)
Returns a single application.
Source code in pyfamilysafety/account.py
260 261 262 | |
get_schedule ¶
get_schedule()
Returns the current schedule.
Source code in pyfamilysafety/account.py
264 265 266 | |
set_device_limits
async
¶
set_device_limits(schedule)
Set screen time limits for a platform on the account.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schedule
|
DeviceLimitsSchedule
|
Platform-specific limits built from
:class: |
required |
Returns:
| Type | Description |
|---|---|
dict
|
The API response body, if present. |
Source code in pyfamilysafety/account.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | |
override_device
async
¶
override_device(target, override, valid_until=None, culture='en-GB')
Block or unblock a platform for this member.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
OverrideTarget
|
Platform to override (:class: |
required |
override
|
OverrideType
|
|
required |
valid_until
|
datetime
|
Required when |
None
|
culture
|
str
|
Locale string sent to the API (default |
'en-GB'
|
Returns:
| Type | Description |
|---|---|
bool
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in pyfamilysafety/account.py
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | |
get_web_restrictions
async
¶
get_web_restrictions()
Return current web filtering settings for this member.
Returns:
| Type | Description |
|---|---|
dict
|
Parsed JSON from the web restrictions API. |
Source code in pyfamilysafety/account.py
322 323 324 325 326 327 328 329 | |
update_web_restrictions
async
¶
update_web_restrictions(operations)
Apply web filtering changes using JSON Patch operations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operations
|
list[dict]
|
List of patch operation dicts ( |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Parsed JSON response from the API, if present. |
Source code in pyfamilysafety/account.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 | |
add_web_exception
async
¶
add_web_exception(website, allowed=False, source='')
Add a web filtering exception for a specific website.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
website
|
str
|
Domain or URL to except from the default filter. |
required |
allowed
|
bool
|
|
False
|
source
|
str
|
Optional source label sent to the API. |
''
|
Returns:
| Type | Description |
|---|---|
dict
|
Parsed JSON response from the API, if present. |
Source code in pyfamilysafety/account.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | |
from_dict
async
classmethod
¶
from_dict(api, raw_response, experimental)
Converts a roster request response to an array.
Source code in pyfamilysafety/account.py
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | |