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: |
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
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
add_account_callback ¶
add_account_callback(callback)
Add a callback to the account.
Source code in pyfamilysafety/account.py
60 61 62 63 64 65 | |
remove_account_callback ¶
remove_account_callback(callback)
Remove a given account callback.
Source code in pyfamilysafety/account.py
67 68 69 70 71 72 | |
update
async
¶
update()
Update all account details.
Source code in pyfamilysafety/account.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
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
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
get_device ¶
get_device(device_id)
Returns a single device.
Source code in pyfamilysafety/account.py
222 223 224 | |
get_application ¶
get_application(application_id)
Returns a single application.
Source code in pyfamilysafety/account.py
226 227 228 | |
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
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
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
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | |
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
284 285 286 287 288 289 290 291 | |
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
293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |
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
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | |
from_dict
async
classmethod
¶
from_dict(api, raw_response, experimental)
Converts a roster request response to an array.
Source code in pyfamilysafety/account.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | |