Hass.io Add-on: Xbox One

Hass.io Add-on: Xbox One

This add-on is a packaged version of the Xbox One SmartGlass RESTful server and a Home Assistant Xbox One custom component. It allows you to easily setup and configure controlling your Xbox from Home Assistant.

Installation

The installation of this add-on is pretty straightforward and not different in
comparison to installing any other Hass.io add-on.

  1. Add my Hass.io add-ons repository to your Hass.io instance.
  2. Install the “Xbox One” add-on.
  3. Put your Xbox Live account details into the email/password options.
  4. Click the Save button to store your credentials.
  5. Start the “Xbox One” add-on.
  6. Check the logs of the “Xbox One” add-on to see if everything went well.
  7. Surf to your Hass.io instance and use port 5557
    (e.g. http://hassio.local:5557).

Add-on Configuration

Note: Remember to restart the add-on when the configuration is changed.

Example add-on configuration:

{
  "email": "[email protected]",
  "password": "changeme"
}

Note: This is just an example, don’t copy and past it! Create your own!

Option: email

The email address you use to login to your Xbox Live account.

Option: password

The password you use to login to your Xbox Live account.

Home Assistant Configuration

This add-on creates a custom component in your hassio instance. This component needs to be configured in order to display your Xbox in Home Assistant. Follow the below steps to get started.

  1. Turn on all of the Xboxes you wish to be discovered.
  2. View the device list in this plugin: hassio.local:5557/devices
  3. Create the media_player configuration using the liveid as the value for device.
  4. Restart Home Assistant to pick up the config change.

Example configuration.yaml:

media_player:
  - platform: xboxone
    device: FD009374623167E
    name: Living Room Xbox One

Note: This is just an example, don’t copy and past it! Create your own!

Option: platform

Required: This must be set to xboxone

Option: device

The LiveID of your Xbox One. It can be found in /devices endpoint. Once this addon is up and running click here.

Option: name

The friendly name for this Xbox which will appear in Home Assistant.

Authors & Contributors

The original setup of this repository is by Jason Hunter.

Huge shoutout to Team OpenXbox for reverse engineering the SmartGlass protocol and providing the libraries and server used.

Special thanks to the contributions of tuxuser for answering late night questions and doing almost all of the heavy lifting on this.

10 Likes

Thank you very much for this addon.
It was very easy to setup.

Great idea to let the addon copy the custom_componeten directly into the config directory.

Although I recieved an error on http://hassio.local:5557/auth/oauth after pasting the url the device is paired successfully and working like a charm.

1 Like

Thought Id give this a quick try but found myself with the following in the log:

[2018-08-27 22:08:07,914] INFO in rest_server: Starting Xbox Smartglass REST server started on 0.0.0.0:5557
[2018-08-27 22:08:07,917] DEBUG in rest_server: Setting tokenfile path to /root/.local/share/xbox/tokens.json
[2018-08-27 22:08:07,919] INFO in rest_server: Trying to load & refresh tokens
[2018-08-27 22:08:07,922] WARNING in rest_server: Failed to authenticate with tokenfile from /root/.local/share/xbox/tokens.json, error: [Errno 2] No such file or directory: '/root/.local/share/xbox/tokens.json'

Config:
{
“email”: “[email protected]”,
“password”: “mypassword”
}

I notice this config resets when started with the error.

I tried manually creating the share/xbox folder as well.

Hass.io supervisor
Version 127

HassOS 1.9
Deployment production

System logs: https://pastebin.com/RK3M4K5r

Im a bit tired so may have missed something obvious…

New version does not require any config. The token file warning is normal. Follow directions in readme inside the addon directly. There is a new auth endpoint.

Hello @hunterjm,

Many thanks for the work.

For those of us that use Hassbian, how can we access your custom component, since one can install the openxbox python server using pip?

As it seems the component is generated by the addon.

Regards

Oh yes of course dumb me, should have figured that out.

Thanks @hunterjm :slight_smile:

Kind regards

Brill, missed the new instructions in the addon itself (doh)

Just got it auth’d and added to HA so will have to have a play later tonight!

Awesome work :slight_smile:

I just had to deactivate this addon. I’m getting a ton of errors.

Update for media_player.living_room_xbox_one fails
09:21 custom_components/media_player/xboxone.py (ERROR)
Unknown Error: Expecting value: line 1 column 1 (char 0)
09:21 custom_components/media_player/xboxone.py (ERROR)
Update for media_player.living_room_xbox_one fails
09:12 custom_components/media_player/xboxone.py (ERROR)
Unknown Error: Expecting value: line 1 column 1 (char 0)

home-assistant.log error:

[homeassistant.helpers.entity] Update for media_player.living_room_xbox_one fails
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py”, line 199, in async_update_ha_state
yield from self.async_device_update()
File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py”, line 322, in async_device_update
yield from self.hass.async_add_job(self.update)
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/media_player/xboxone.py”, line 521, in update
self._xboxone.refresh()
File “/config/custom_components/media_player/xboxone.py”, line 409, in refresh
self._volume_controls = self._get_volume_controls()
File “/config/custom_components/media_player/xboxone.py”, line 284, in _get_volume_controls
controls = response.get(‘avr’) or response.get(‘tv’)
UnboundLocalError: local variable ‘response’ referenced before assignment
2018-09-01 09:11:45 ERROR (SyncWorker_1) [custom_components.media_player.xboxone] Unknown Error: Expecting value: line 1 column 1 (char 0)
2018-09-01 09:11:45 ERROR (MainThread) [homeassistant.helpers.entity] Update for media_player.living_room_xbox_one fails
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py”, line 199, in async_update_ha_state
yield from self.async_device_update()
File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py”, line 322, in async_device_update
yield from self.hass.async_add_job(self.update)
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/media_player/xboxone.py”, line 521, in update
self._xboxone.refresh()
File “/config/custom_components/media_player/xboxone.py”, line 409, in refresh
self._volume_controls = self._get_volume_controls()
File “/config/custom_components/media_player/xboxone.py”, line 284, in _get_volume_controls
controls = response.get(‘avr’) or response.get(‘tv’)
UnboundLocalError: local variable ‘response’ referenced before assignment
2018-09-01 09:12:07 ERROR (SyncWorker_14) [custom_components.media_player.xboxone] Unknown Error: Expecting value: line 1 column 1 (char 0

Looks like your tokens expired. I have a fix for that I’m testing now, but re-starting the addon and authenticating at /auth/oauth should fix this.

1 Like

After restart:

[2018-09-01 17:49:47,496] INFO in rest_server: Starting Xbox Smartglass REST server started on 0.0.0.0:5557
[2018-09-01 17:49:47,498] DEBUG in rest_server: Setting tokenfile path to /root/.local/share/xbox/tokens.json
[2018-09-01 17:49:47,501] INFO in rest_server: Trying to load & refresh tokens
[2018-09-01 17:49:47,505] WARNING in rest_server: Failed to authenticate with tokenfile from /root/.local/share/xbox/tokens.json, error: [Errno 2] No such file or directory: ‘/root/.local/share/xbox/tokens.json’ 127.0.0.1 - -
[2018-09-01 17:49:56] “GET /device HTTP/1.1” 200 138 2.556043
[2018-09-01 17:49:56,764] ERROR in app: {‘success’: False, ‘message’: ‘Console info for FD0065DC5563D30C8 is not available’} 127.0.0.1 - -
[2018-09-01 17:49:56] “GET /device/FD0065DC5563D30C8 HTTP/1.1” 403 196 0.011796 127.0.0.1 - -
[2018-09-01 17:50:07] “GET /device HTTP/1.1” 200 138 2.559887
[2018-09-01 17:50:07,729] ERROR in app: {‘success’: False, ‘message’: ‘Console info for FD0065DC934D30C8 is not available’} 127.0.0.1 - -
[2018-09-01 17:50:07] “GET /device/FD0065DC921D30C8 HTTP/1.1” 403 196 0.009489 127.0.0.1 - -
[2018-09-01 17:50:18] “GET /device HTTP/1.1” 200 138 2.558754
[2018-09-01 17:50:18,736] ERROR in app: {‘success’: False, ‘message’: ‘Console info for FD0065DC934D30C8 is not available’} 127.0.0.1 - -
[2018-09-01 17:50:18] “GET /device/FD0065DC5563D30C8 HTTP/1.1” 403 196 0.009128 127.0.0.1 - -
[2018-09-01 17:50:29] “GET /device HTTP/1.1” 200 138 2.555490 [2018-09-01 17:50:29,716] ERROR in app: {‘success’: False, ‘message’: ‘Console info for FD0065DC5563D30C8 is not available’} 127.0.0.1 - -
[2018-09-01 17:50:29] “GET /device/FD0065DC5563D30C8 HTTP/1.1” 403 196 0.009724 127.0.0.1 - -
[2018-09-01 17:50:40] “GET /device HTTP/1.1” 200 138 2.559817
[2018-09-01 17:50:40,722] ERROR in app: {‘success’: False, ‘message’: ‘Console info for FD0065DC5563D30C8 is not available’}

This is normal. It’s looking for your console, but it’s probably turned off. Does everything still appear properly in Home Assistant?

It seems quite temperamental but at times i am able to tell it to open netflix etc. The card doesnt quite look normal is that correct?

Also, i am getting this error every 10 seconds - any idea?

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 199, in async_update_ha_state
    yield from self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 322, in async_device_update
    yield from self.hass.async_add_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/media_player/xboxone.py", line 521, in update
    self._xboxone.refresh()
  File "/config/custom_components/media_player/xboxone.py", line 409, in refresh
    self._volume_controls = self._get_volume_controls()
  File "/config/custom_components/media_player/xboxone.py", line 288, in _get_volume_controls
    'mute': controls['buttons']['btn.vol_mute']['url'],
KeyError: 'btn.vol_mute'```

I keep getting:
WARNING (MainThread) [homeassistant.components.media_player] Updating xboxone media_player took longer than the scheduled update interval 0:00:10

I’m also not able to switch the Xbox Off. Anyone having issues?

Thanks

Hi,
Thank you for the author of this addon.

I get the following errors in the logs. Any idea on how to solve that.

2018-09-23 17:38:58 ERROR (SyncWorker_0) [custom_components.media_player.xboxone] Console XXXXXXXXXXXXXXXX not available
2018-09-23 17:39:09 ERROR (SyncWorker_3) [custom_components.media_player.xboxone] Console XXXXXXXXXXXXXXXX not available
2018-09-23 17:39:20 ERROR (SyncWorker_14) [custom_components.media_player.xboxone] Console XXXXXXXXXXXXXXXX not available
2018-09-23 17:39:31 ERROR (SyncWorker_18) [custom_components.media_player.xboxone] Console XXXXXXXXXXXXXXXX not available
2018-09-23 17:39:41 ERROR (SyncWorker_9) [custom_components.media_player.xboxone] Console XXXXXXXXXXXXXXXX not available
2018-09-23 17:39:52 ERROR (SyncWorker_1) [custom_components.media_player.xboxone] Console XXXXXXXXXXXXXXXX not available

alos these erros mate

2018-09-29 09:05:43 ERROR (SyncWorker_6) [custom_components.media_player.xboxone] Refreshing authentication tokens failed!
2018-09-29 09:05:43 ERROR (SyncWorker_6) [custom_components.media_player.xboxone] Failed to connect to XXXXXXXXXXXXXX

I have to manually refresh my token every other day… is that normal?

Awesome, managed to get this working this morning!

Does anyone know how i can launch an app? Specifically looking to launch Plex.

I can see i should be using:

/device/liveid/launch/path:app_id

But i have no idea what to use for “path:app_id”
Launching plex manually and then checking /console_status shows that Plex title_id is 1826276761 but still not sure what to put for the path? I don’t see anything related to path under /console_status

My end goal is to have an an option for “Launch Plex” on my harmony remote which will turn on my tv & xbox and then using emulated_hue/homeassistant send a cmd to launch plex.

just installed the 1.1.0 update and now connected each time i load. looks to me like it is working now

Same here : everything is fine now. No more messages in the logs. Thank you for making this happen.

1 Like