Xbox One / Smartglass Integration

It looks like there has been some further development by a team called OpenXbox for getting better access to Xbox One and also talking to it via Smartglass protocols.

It would be great to integrate this into HomeAssistant as it is talking directly to the console/Microsoft rather than using 3rd Party services.

New options that this might allow:

More info:
https://xbox-smartglass-core-python.readthedocs.io/en/latest/source/xbox.sg.console.html


http://openxbox.org/smartglass-documentation/

Can you help me make this work in Hass.io? Don’t actually know how to use python and if I am not mistaken (or maybe I just couldn’t make the sudo command work) Hass.io doesn’t allow me to use python as a command.

I am currently working on adding a webostv remote component but Xbox One S control is my next step in the project, so I’ll look into writing homeassistant components with ObenXbox afterwards. I’ve had a quick play with their example scripts and the functionality is pretty good.

There’s already someone working on making this possible, see https://github.com/OpenXbox/xbox-smartglass-core-python/issues/4

1 Like

Ooooh, very exciting!

It just got a bit easier:

To ease the interopability from Home Assistant (asyncio event loop) <—> Xbox SmartGlass library (gevent loop), I created a simple REST server.

Major credits to @hunterjm (idea for HA smartglass) and @UnknownSKL (https://github.com/unknownskl/xbox-smartglass-rpc/tree/release/0.2.0) and of course, the OpenXbox team (https://openxbox.org)

If you have questions about using the API or improvements in mind, feel free to send a PR or open an issue.

gz

2 Likes

Great stuff!!

Give it a try, if you like:

1 Like

Hey man, I’m having some trouble installing your REST server script on my Raspberry Pi3 running Raspbian Lite (not running Home Assistant). I’m not too familiar with UNIX commands but I’ve learned a lot over the past few months.

I run the command “sudo pip install xbox-smartglass-rest” and it installs a bunch of things, but seems to error out when it hits anything related to ‘cryptography’. It spits out the errors below:

Failed building wheel for cryptography
Failed building wheel for greenlet
Failed building wheel for gevent
Command “/usr/bin/python -u -c “import setuptools, tokenize;file=’/tmp/pip-install-FrwTLm/cryptography/setup.py’;f=getattr(tokenize, ‘open’, open)(file);code=f.read().replace(’\r\n’, ‘\n’);f.close();exec(compile(code, file, ‘exec’))” install --record /tmp/pip-record-rFhqSw/install-record.txt --single-version-externally-managed --compile” failed with error code 1 in /tmp/pip-install-FrwTLm/cryptography/

I tried checking if the cryptography module for Python is installed by running “sudo pip install cryptography” and looks like it is installed, with the message below:

"Requirement already satisfied: cryptography in /usr/lib/python2.7/dist-packages (1.7.1)

Any thoughts?

  1. Please use Python 3.5+
  2. Please install the package in its own virtual environment (venv or virtualenvwrapper or whatever you like)

Raspbian comes with Python 3.5.3, so I don’t think that’s the problem. I’ll look into using venv though. Thanks for the advice.

@dwinnn I am running this myself on my pi. Instead of running pip which in the case of a pi is python 2.7. Use pip3 for your command and it should run fine.

Thanks for the shoutout @tuxuser, but you did all the heavy lifting. For those of you on Hass.io, I just bundled this all up into a neat little add-on. The armhf architecture is still building as of this post. You can pull from my repository here:

1 Like

Thanks! I was close to remembering about pip3 but failed to Google search. But now I’ll just use hunterjm’s Hass.io addon.

Hey, Thanks for this addon. It would be awesome if the media player would show the main image of the game or even better for youtube videos, netflix series and so on.

xbox

This picture shows the current status.

edit: Why is the media player component showing the status idle?
something like on would make more sense
Greetings Gideon

App image and friendly name support will be coming in the next release.

Unfortunately, the Netflix & YouTube apps didn’t integrate with Xbox’s Smartglass service to provide info about the actual media that was playing. We are limited to showing only the same things that are visible inside the XBox app itself. If you are on Windows, you can use the app to connect to your console and see what we hope to eventually have this component support, or download the app on your smartphone.

2 Likes

Can I use this component in automations?

Like if the youtube video is paused turn light on and so on
Or can I only use the off and idle state ?

Is it possible to create custom lightning setups for different Apps and Games?

Playing a youtube video change the light to red
or playing Need For Speed turn the police light effect on.

Right now for YouTube, we only trigger the play_pause_toggle because YouTube doesn’t return a media state. You can create automations based on the media_title which will show you the name of the app. In the next version, that will be a more friendly name like “YouTube” instead of the title identifier that displays today “GoogleInc.YouTube_{hash}!App”. The only application that I know of that supports the full media player functionality with Smartglass is the BluRay player app, which also has a bug in this version that will be fixed in the next.

2 Likes

Nice job! Working fine with my Xbox and looking forward to more updates :grinning:

2 Likes

Awesome stuff!! Is this going to make it’s way into the standard Home Assistant build as a component or will it remain an add-on for Hass.IO?

Might have to migrate myself over to Hass.IO in order to get in on using this haha