home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.43k stars 30.67k forks source link

HA no longer is able to control local Xbox #75311

Closed flyize closed 1 year ago

flyize commented 2 years ago

The problem

In the last week or two, HA stopped being able to control my Xbox. I've removed and readded the integration several times. It's able to detect the online users as sensors, but does not add my Xbox.

What version of Home Assistant Core has the issue?

2022.7.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

No response

Link to integration documentation on our website

https://www.home-assistant.io/integrations/xbox/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

probot-home-assistant[bot] commented 2 years ago

Hey there @hunterjm, mind taking a look at this issue as it has been labeled with an integration (xbox) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)


xbox documentation xbox source (message by IssueLinks)

flyize commented 2 years ago

Oh I forgot. Before I removed and readded the integration, this was the error I was seeing in my logs:

Logger: homeassistant.config_entries
Source: components/cloud/account_link.py:116
First occurred: July 11, 2022 at 10:51:43 AM (1 occurrences)
Last logged: July 11, 2022 at 10:51:43 AM

Error setting up entry Home Assistant Cloud for xbox
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 353, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/xbox/__init__.py", line 101, in async_setup_entry
    consoles: SmartglassConsoleList = await client.smartglass.get_console_list()
  File "/usr/local/lib/python3.10/site-packages/xbox/webapi/api/provider/smartglass/__init__.py", line 54, in get_console_list
    resp = await self._fetch_list("devices", params, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/xbox/webapi/api/provider/smartglass/__init__.py", line 359, in _fetch_list
    resp = await self.client.session.get(
  File "/usr/local/lib/python3.10/site-packages/xbox/webapi/api/client.py", line 86, in get
    return await self.request(hdrs.METH_GET, url, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/xbox/webapi/api/client.py", line 60, in request
    await self._auth_mgr.refresh_tokens()
  File "/usr/src/homeassistant/homeassistant/components/xbox/api.py", line 27, in refresh_tokens
    await self._oauth_session.async_ensure_token_valid()
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 475, in async_ensure_token_valid
    new_token = await self.implementation.async_refresh_token(self.token)
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 89, in async_refresh_token
    new_token = await self._async_refresh_token(token)
  File "/usr/src/homeassistant/homeassistant/components/cloud/account_link.py", line 116, in _async_refresh_token
    new_token = await account_link.async_fetch_access_token(
  File "/usr/local/lib/python3.10/site-packages/hass_nabucasa/account_link.py", line 112, in async_fetch_access_token
    resp.raise_for_status()
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 1004, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 500, message='Internal Server Error', url=URL('https://account-link.nabucasa.com/refresh_token/xbox')
mdb17 commented 2 years ago

same for me

flyize commented 2 years ago

@hunterjm Could this have something to do with the python switch?

Newlance commented 2 years ago

Same problem here

odu14ick commented 2 years ago

same here, but I have 503

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 353, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/xbox/__init__.py", line 101, in async_setup_entry
    consoles: SmartglassConsoleList = await client.smartglass.get_console_list()
  File "/usr/local/lib/python3.10/site-packages/xbox/webapi/api/provider/smartglass/__init__.py", line 54, in get_console_list
    resp = await self._fetch_list("devices", params, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/xbox/webapi/api/provider/smartglass/__init__.py", line 362, in _fetch_list
    resp.raise_for_status()
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 1004, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 503, message='Service Unavailable', url=URL('https://xccs.xboxlive.com/lists/devices?queryCurrentDevice=false&includeStorageDevices=true')
flyize commented 2 years ago

Through no change on my part, this seems to have resolved itself.

voltagex commented 2 years ago

404 here

aiohttp.client_exceptions.ClientResponseError: 404, message='Not Found', url=URL('https://xccs.xboxlive.com/commands')
2022-08-07 21:53:32 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139815059381968] 404, message='Not Found', url=URL('https://xccs.xboxlive.com/commands')
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/components/websocket_api/commands.py", line 193, in handle_call_service
    await hass.services.async_call(
  File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/core.py", line 1713, in async_call
    task.result()
  File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/core.py", line 1750, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/entity_component.py", line 204, in handle_service
    await service.entity_service_call(
  File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/service.py", line 680, in entity_service_call
    future.result()  # pop exception if have
  File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/entity.py", line 930, in async_request_call
    await coro
  File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/service.py", line 717, in _handle_entity_call
    await result
  File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/components/xbox/media_player.py", line 159, in async_turn_on
    await self.client.smartglass.wake_up(self._console.id)
  File "/srv/homeassistant/lib/python3.10/site-packages/xbox/webapi/api/provider/smartglass/__init__.py", line 134, in wake_up
    return await self._send_one_shot_command(device_id, "Power", "WakeUp", **kwargs)
  File "/srv/homeassistant/lib/python3.10/site-packages/xbox/webapi/api/provider/smartglass/__init__.py", line 397, in _send_one_shot_command
    resp.raise_for_status()
  File "/srv/homeassistant/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 1004, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 404, message='Not Found', url=URL('https://xccs.xboxlive.com/commands')
voltagex commented 2 years ago

https://github.com/home-assistant/core/issues/42588

flyize commented 2 years ago

...and now my Xbox is unavailable. Again, with no change on my part. Could this be an issue on the MS side of things?

flyize commented 2 years ago

@hunterjm Is there anything else missing from my report? Apologies if there is. Please let me know and I will instantly add it.

I just looked and also see this error in my logs:

Logger: homeassistant.helpers.service
Source: helpers/service.py:635
First occurred: 11:22:27 AM (3 occurrences)
Last logged: 1:51:31 PM

Unable to find referenced entities media_player.living_room_xbox or it is/they are currently not available
cdnninja commented 2 years ago

I am having media player issues as well. One note for everyone the remote control setting on the xbox itself seems to disable itself if you don't use the xbox for a bit. Re-enabling fixes some items but not the media_player.

DJ-CrossFade commented 2 years ago

The problem

In the last week or two, HA stopped being able to control my Xbox. I've removed and readded the integration several times. It's able to detect the online users as sensors, but does not add my Xbox.

What version of Home Assistant Core has the issue?

2022.7.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

No response

Link to integration documentation on our website

https://www.home-assistant.io/integrations/xbox/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

When this same thing just recently happened to me I found out that my case actually had nothing to do with Home Assistant. In my case it turned out that my Xbox no longer had "enabled remote features" checked in Settings, Devices & connections, Remote features. I recommend anyone with this issue check this setting on your Xbox before any other troubleshooting.

flyize commented 2 years ago

I don't think I had that on before, as that is for remote play. However, I tried to turn it on and my issue remains.

mdb17 commented 2 years ago

I have also found that the Xbox app no longer recognizes my console. Though I have yet to find a way add it back.

Pasha1402 commented 2 years ago

Same here. Removed xbox integration, the re-added it back: as result xbox media player and xbox remote entities no longer present, only xbox user profile stats.

markgentry1 commented 2 years ago

Was having the same issue, no media player entities or remote entities. Was able to resolve it by setting up the Xbox in my mobile app again and re-enabling remote play. Reloaded the integration and the media player entity and remote entities showed up as they used to.

Pasha1402 commented 2 years ago

Yes, I confirm fix by Markgentry1. It seems recent update on XBox disabled Remote features. Re-enabling them in phone app fixes everything for HA. The only step needed is to Reload integration.

Thanks @markgentry1!

bigwoof commented 2 years ago

thanks @markgentry1 that solved it for me too it looks like it is a problem on the box side and not the HA side - perhaps the integration can notify us that the remote features need to be re-enabled Having said that we can probably write an automation to test the integration, however I am not sure what trigger we can use for the automation.

flyize commented 2 years ago

Can you guys explain specifically what you did? I must be doing something wrong.

bigwoof commented 2 years ago

It seems that it didn't stick - it worked once and stopped again this morning - it also seems that I can't content to remote play via the xbox app. I will have to try on the box side and then can have another crack at the HA side.

Pasha1402 commented 2 years ago

@bigwoof, this is exactly the problem I was facing and cause of HA issue. I had to play around with XBox and phone switching remote on/off until I got remote play properly working on phone. Then HA was no brainer. Consider it as strict rule: Remote Play on phone fully working = HA working.

Good luck!

silver0007 commented 2 years ago

There's no need to do it via app. You can enable remote features also directly in xbox config menu. Changed yesterday, restarted HA and so far so good.

flyize commented 2 years ago

@silver0007 Unless maybe something changed with the November release, I'm guessing it will stop working for you again. Please report back!

bigwoof commented 2 years ago

Hi Just reporting my findings - it seems that Xbox sometimes breaks the connection - to fix it i disabled and enabled remote play on the console and then started a remote play session on my windows PC - I didn't have luck for some reason via my phone via the Xbox app.

once the remote play was up and running on the PC I reloded the integration and all was good again - now I can shut down the xbox at dinner time to get the kids to the dining room #Evil_Dad

rsnodgrass commented 1 year ago

Same issue. Would love to have a local XBOX control integration. We have 4 different XBOX consoles, some on different accounts, that we'd like to be able to control via a local HA instance. Not having a local XBOX controller AND NabuCasa Cloud only linking to a single Microsoft account makes this impossible today :(

ciedema commented 1 year ago

Turning Remote Access corrected this issue for me.

DJ-CrossFade commented 1 year ago

Same issue. Would love to have a local XBOX control integration. We have 4 different XBOX consoles, some on different accounts, that we'd like to be able to control via a local HA instance. Not having a local XBOX controller AND NabuCasa Cloud only linking to a single Microsoft account makes this impossible today :(

I have 2 consoles and I thought I fixed the issue by adding the 2nd console to my Microsoft account. I now have control of the 2nd console in HA but if I use HA to turn it on and/or pull a game up, it automatically logs my Xbox user in instead of logging it in to my son's. So I agree with what's - [ ] been said in this thread that it would be great to be able to use multiple gamertags. But at least with the configuration I have now I can turn the 2nd console off when my son forgets to.

rsnodgrass commented 1 year ago

@DJ-CrossFade while I can't control more than one console through HA, at least I monitor the state of each XBOX using the ping sensor (and a static DHCP IP for each). This might be useful to others.

binary_sensor:
  - platform: ping
    host: 192.168.1.75
    name: "XBOX 1 Power Ping"
    count: 3
    scan_interval: 1
Pasha1402 commented 1 year ago

@rsnodgrass, XBOX (at least latest gen) never suspends network during sleep. ping only makes sense if you switch it off completely, which is not very convenient. e.g. offline installs, quick wake, etc.

You'd better use "UPnP Availability" integration for the same purpose https://github.com/rytilahti/homeassistant-upnp-availability/. It is way faster and doesn't require "pinging"

rsnodgrass commented 1 year ago

@Pasha1402 thanks for tip on UPnP! I'll look into that.

FYI, the ping method for detecting power state of my Xbox Series works (when off it no longer responds to pings). However, you are probably right if the Xbox wakes up to do some background update, it might cause problems for my automations.

ghost commented 1 year ago

The same problem. I also noticed that an error 500 comes when requesting installed applications:

2023-01-21 17:23:23,924.924 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [1522676593904] Error handling message: Unknown error (unknown_error) from 127.0.0.1 (Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 YaBrowser/22.11.5.709 Yowser/2.5 Safari/537.36) Traceback (most recent call last): File "C:\Users\slava\HAOS\python-3.9.10.amd64\lib\site-packages\homeassistant\components\websocket_api\decorators.py", line 27, in _handle_async_response await func(hass, connection, msg) File "C:\Users\slava\HAOS\python-3.9.10.amd64\lib\site-packages\homeassistant\components\media_source__init__.py", line 170, in websocket_browse_media media = await async_browse_media(hass, msg.get("media_content_id", "")) File "C:\Users\slava\HAOS\python-3.9.10.amd64\lib\site-packages\homeassistant\components\media_source__init.py", line 121, in async_browse_media item = await _get_media_item(hass, media_content_id, None).async_browse() File "C:\Users\slava\HAOS\python-3.9.10.amd64\lib\site-packages\homeassistant\components\media_source\models.py", line 79, in async_browse return await self.async_media_source().async_browse_media(self) File "C:\Users\slava\HAOS\python-3.9.10.amd64\lib\site-packages\homeassistant\components\xbox\media_source.py", line 89, in async_browse_media return await self._build_game_library() File "C:\Users\slava\HAOS\python-3.9.10.amd64\lib\site-packages\homeassistant\components\xbox\media_source.py", line 98, in _build_game_library apps = await self.client.smartglass.get_installed_apps() File "C:\Users\slava\HAOS\python-3.9.10.amd64\lib\site-packages\xbox\webapi\api\provider\smartglass\init.py", line 71, in get_installed_apps resp = await self._fetch_list("installedApps", params, **kwargs) File "C:\Users\slava\HAOS\python-3.9.10.amd64\lib\site-packages\xbox\webapi\api\provider\smartglass\init__.py", line 362, in _fetch_list resp.raise_for_status() File "C:\Users\slava\HAOS\python-3.9.10.amd64\lib\site-packages\aiohttp\client_reqrep.py", line 1004, in raise_for_status raise ClientResponseError( aiohttp.client_exceptions.ClientResponseError: 500, message='Internal Server Error', url=URL('https://xccs.xboxlive.com/lists/installedApps')

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

flyize commented 1 year ago

@hunterjm Any ideas?

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.