pantherale0 / ha-familysafety

Microsoft Family Safety Home Assistant integration
MIT License
14 stars 2 forks source link

Manage screen time requests #33

Open manonstreet opened 9 months ago

manonstreet commented 9 months ago

Checklist

Is your feature request related to a problem? Please describe.

No

Describe the solution you'd like

Provide a means to grant additional screen time for an account. Surface new screen time requests on a per account basis.

Describe alternatives you've considered

N/A

Additional context

I use Microsoft's Family Safety to manage my kids screen time. Although they are on a established schedule, there are many times when additional time is needed. This process involves requesting time on their computers when it runs out, opening the Family Safety iOS app, opening the notification, and selecting how much additional time to grant.

Ideally, the need for the Family Safety iOS app could be eliminated through use of this integration. Signaling a screen time request (event, boolean change, etc.) would allow for creating an actionable notification to grant additional screen time with one click.

manonstreet commented 9 months ago

I was poking at the base python module code and see it already has the ability to get pending requests, and to approve pending requests (with a variable number of seconds).

Can this integration be extended to:

  1. Check for pending requests in the update interval loop (looks like every minute). As noted this can be exposed via a sensor (such as pending request boolean).
  2. Provide a way to manually trigger an update. This can be helpful when the kiddos run out of time at some critical moment in the game (I need to save! I am a about die!). They will request, and urgently ask for more time. I'd like a way to not have to wait for up to 1 minute before I can process the request.
  3. Provide a way to approve/deny the request. This is probably best done with a service.

Thanks!

pantherale0 commented 9 months ago

Yes, the code is there. Will enable it as an experimental feature as it's not fully tested yet (especially with new version of family safety).

manonstreet commented 7 months ago

Hi @pantherale0, curious when you might able able to implement this?

Thanks for your work on this integration, I use it daily!

pantherale0 commented 2 weeks ago

This is now available as a preview feature in 2024.12.0b0.

pantherale0 commented 2 weeks ago

Hmmm, need to figure this out further, after some testing, the ID of the request changes every time you send a new http request to the endpoint to get the pending requests

lordduckstein commented 2 weeks ago

Hello pantherale0, thank you for your service.

I hope you find out that the "screen time request" works fine. That is an option that i often use...

Thank You Lordi

pantherale0 commented 2 weeks ago

Hi @lordduckstein

If timed right, the feature does work, but as it's not something I use often it's difficult for me to test. Even screen time management in general is something that I don't really use much anymore.

I will continue to test though, and figure out better ways to manage them.

and7ey commented 2 weeks ago

@pantherale0 many thanks for your work!

Hopefully the functionality you are working on currently will work with the 2nd scenario @manonstreet suggested ("Provide a way to manually trigger an update").

pantherale0 commented 2 weeks ago

Currently the 2nd scenario hasn't been included, but I wonder if that could already be done by using the homeassistant.update_entity service?

and7ey commented 4 days ago

@pantherale0 could you please clarify how to use it? I have time restriction from 7 am to 11 pm each day (and there is no limitation on the number of hours). sensor.user_available_balance shows 0. Let's say I want to give an additional 30 minutes after 11pm. What should I do?

pantherale0 commented 3 days ago

@and7ey when the time has expired, a prompt appears on the device to "Ask a parent" for more time via a message (I can't remember the exact wording). This should than appear in Home Assistant as an extended attribute under sensor.user_pending_requests. You need to use the ID from that against the approve_request service call.

and7ey commented 1 day ago

a prompt appears on the device to "Ask a parent"

aah, I thought we are talking about scenario to give more time without user request, but re-read what manonstreet meant and understood that his idea is a different.

pantherale0 commented 1 day ago

aah, I thought we are talking about scenario to give more time without user request, but re-read what manonstreet meant and understood that his idea is a different.

I could potentially expose some service calls for you to do this? In the past though I've allowed 24/7 screen time in the app, but then used a schedule with an automation to toggle the switches to block platforms from within Home Assistant.

Currently I don't actually really use any of this at all.

and7ey commented 1 day ago

I could potentially expose some service calls for you to do this

Yes, please. Thanks in advance.