pantherale0 / ha-familysafety

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

Toggle to block all devices discontinued by Microsoft #37

Closed Snackington closed 6 days ago

Snackington commented 8 months ago

Notice

Microsoft appear to have disabled this functionality entirely, in fact, at least in the version of the app me (@pantherale0) is using the toggles to even set any overrides are gone entirely and instead only an option exists to enable / disable a schedule.

System Health details

System Information

version core-2024.3.1
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.2
os_name Linux
os_version 6.1.73-haos-raspi
arch aarch64
timezone America/Chicago
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 4928 Installed Version | 1.34.0 Stage | running Available Repositories | 1400 Downloaded Repositories | 12
Home Assistant Cloud logged_in | true -- | -- subscription_expiration | February 27, 2025 at 6:00 PM relayer_connected | true relayer_region | us-east-1 remote_enabled | true remote_connected | true alexa_enabled | true google_enabled | true remote_server | us-east-1-10.ui.nabu.casa certificate_status | ready instance_id | ddff79cdc8e647afa7f6ae72c8f35b73 can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 12.1 -- | -- update_channel | stable supervisor_version | supervisor-2024.03.0 agent_version | 1.6.0 docker_version | 24.0.7 disk_total | 27.7 GB disk_used | 6.1 GB healthy | true supported | true board | rpi4-64 supervisor_api | ok version_api | ok installed_addons | Terminal & SSH (9.10.0), Home Assistant Google Drive Backup (0.112.1), Mosquitto broker (6.4.0), Z-Wave JS UI (3.4.1), Studio Code Server (5.15.0)
Dashboards dashboards | 1 -- | -- resources | 6 views | 6 mode | storage
Recorder oldest_recorder_run | March 7, 2024 at 4:01 AM -- | -- current_recorder_run | March 15, 2024 at 9:00 PM estimated_db_size | 73.62 MiB database_engine | sqlite database_version | 3.44.2

Checklist

Describe the issue

Installation of the integration and connection went fine, I can see the screentime hours and the status of the "block all devices" toggle, but attempting to switch it on or off results in 500 internal server error. Tried restarting HA/Re-configuring integration.

Reproduction steps

N/A

Debug logs

2024-03-15 21:38:02.834 WARNING (MainThread) [pyfamilysafety.account] Unknown account spending response, please report to developer. {'askAParentEnabled': True, 'balances': []}
2024-03-15 21:38:05.317 WARNING (MainThread) [pyfamilysafety.account] Unknown account spending response, please report to developer. {'askAParentEnabled': True, 'balances': []}
2024-03-15 21:38:09.061 WARNING (MainThread) [pyfamilysafety.account] Unknown account spending response, please report to developer. {'askAParentEnabled': True, 'balances': []}
2024-03-15 21:38:11.915 WARNING (MainThread) [pyfamilysafety.account] Unknown account spending response, please report to developer. {'askAParentEnabled': True, 'balances': []}
2024-03-15 21:38:14.271 WARNING (MainThread) [pyfamilysafety.account] Unknown account spending response, please report to developer. {'askAParentEnabled': True, 'balances': []}
2024-03-15 21:38:16.623 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [548011862208] ('HTTP Error', 500, '"Internal Server Error"')
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 239, in handle_call_service
response = await hass.services.async_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2319, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2356, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 905, in entity_service_call
single_response = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 975, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/config/custom_components/family_safety/switch.py", line 117, in async_turn_off
return await self._disable_override()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/family_safety/entity_base.py", line 115, in _disable_override
await self._account.override_device(self._platform, OverrideType.CANCEL)
File "/usr/local/lib/python3.12/site-packages/pyfamilysafety/account.py", line 153, in override_device
response = await self._api.send_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyfamilysafety/api.py", line 103, in send_request
raise HttpException("HTTP Error", response.status, await response.text())
pyfamilysafety.exceptions.HttpException: ('HTTP Error', 500, '"Internal Server Error"')

Diagnostics dump

No response

andyearnshaw commented 8 months ago

I have the same issue, HTTP 500 error. Blocking individual systems works, Block Windows/Mobile/Xbox. It's just all devices that doesn't work correctly.

pantherale0 commented 7 months ago

Will take a look at this asap, currently in the middle of moving so haven't got access to any of my dev environments.

devdems commented 6 months ago

@pantherale0 any luck with getting this error resolved?

gormac77 commented 5 months ago

Hi, I seem to have the same 500 error issue. I am able to block Windows as a whole but not individual apps. I have selected the apps from the UI, e.g. Roblox, so I do not think it is simply a matter of me spelling things incorrectly. Any ideas?

idorose commented 5 months ago

Hi, I seem to have the same 500 error issue. I am able to block Windows as a whole but not individual apps. I have selected the apps from the UI, e.g. Roblox, so I do not think it is simply a matter of me spelling things incorrectly. Any ideas?

same here, I also created switches for specific apps and it gives me the 500 error. Block mobile also doesn't seem to do anything (does it suppose to switch on and off the app time limit toggle in the health app?)

pantherale0 commented 5 months ago

Haven't got my other mobile with me at present, but debugging it looks like Microsoft's API has changed. At the moment all I literally have from Microsoft is "Internal Server Error" in the response body so it doesn't actually tell us whats wrong.

I've not used the app for a while, could someone confirm if these features are still available?

@idorose The Block Mobile switch is supposed to block mobile devices (Android), but I've never been able to get this to work. Just something that is exposed in the API.

gormac77 commented 5 months ago

@pantherale0 I can confirm the features are still avalable in the mobile app. I can go in and manage mobile, xbox and Windows for each of the users down to the application level. The interface has changed recently so possibly the API as well.

pantherale0 commented 5 months ago

Thanks @gormac77 if the UI has changed. The API has probably changed too in that case. I'll investigate asap but don't have the right hardware to hand at present.

rhyssman commented 1 month ago

Hi @pantherale0 any update on this this issue. Am also unable to switch blocking of applications similar to the above issue.

pantherale0 commented 1 month ago

Hi @rhyssman I haven't been able to use the integration lately as blocked by #40 which is a shame.

I still need to rework the library to use the "new" app however haven't had the time or chance to yet. Work on this is next in my queue once I've released 2024.10.0 for my Fuel Prices integration.

rhyssman commented 1 month ago

Hi @rhyssman I haven't been able to use the integration lately as blocked by #40 which is a shame.

I still need to rework the library to use the "new" app however haven't had the time or chance to yet. Work on this is next in my queue once I've released 2024.10.0 for my Fuel Prices integration.

Noted. Will keep tabs on this integration. Fuel prices integration looks good!

pantherale0 commented 1 month ago

Ok, looking at the API. This entire feature is no longer available. Seems Microsoft have really changed how this all works :disappointed:

devdems commented 1 month ago

I still see the usage of the devices in HA. I can not block them, though.

pantherale0 commented 1 month ago

@devdems usage is provided under a seperate endpoint that hasn't changed. So usage and overrides (blocking of devices) are completely seperate and probably completely different backends (assuming microservices architecture).

pantherale0 commented 1 week ago

I've managed to get round to this finally.

2024.12.0b0 "fixes" this - although by fix, the option to block all devices has been removed entirely as the API itself does not appear to support it anymore. You'll need to toggle each platform individually instead. A few performance improvements have been made to this area so it shouldn't take as long to toggle now.

Also the application switches have been disabled for now as the API has changed and these currently aren't working.

idorose commented 6 days ago

hey, just upgraded to the Beta, when I try to run the service to block an app I get an error, I tried both an app on mobile (Brawl Stars) and an app on PC (steam client webhelper).

Block Mobile doesn't seem to do anything as well.

lock windows works fine just like before.

pantherale0 commented 6 days ago

@idorose refer to my previous comment regarding blocking applications.

I think Block Mobile is supposed to work for android devices, but I don't actually know as I haven't got anything to test with. Just exposed what is available in the API. Might work to make this more dynamic to only load platforms that you have setup rather than all of them.

idorose commented 6 days ago

well I tried on my son's android, it doesn't seem to do anything. by the way, from Family Safety app there is no option to lock mobile as there is with windows devices, only block apps on mobile, there is an option to set up time limit for mobile (which blocks all apps with time limit)

pantherale0 commented 6 days ago

Ok, new update has just been released which fixes blocking and unblocking applications. A number of API changes though so please try with Android and Windows applications if you can (I'm most certain Android won't work).

@idorose thanks for testing the mobile block, I will remove that platform switch for the next version.

idorose commented 6 days ago

still not working for me, the log file shows error 400

pantherale0 commented 6 days ago

Ok, sounds like its probably due to the platform, I need to add the diagnostic data so that you can get the app ID, then we'll be able to see whats wrong

pantherale0 commented 6 days ago

The above app blocking issue has been converted to a separate issue as does not relate to this. Closing this issue now as this is resolved in the latest beta.