[RELEASE] Xbox One Smartglass Driver

Description: Xbox One Smartglass Intergration. The driver interfaces with the Xbox Smartglass Project giving local control of your Xbox One.

Features: Powering On, Powering Off, Polling for state changes, sending controller button presses

Download Links

Driver: https://github.com/dmike3/Hubitat/blob/master/Drivers/Xbox-Smartglass/Xbox-One-Smartglass-Driver.groovy

Xbox One Smartglass Project: https://pypi.org/project/xbox-smartglass-core/

README: https://github.com/dmike3/Hubitat/blob/master/Drivers/Xbox-Smartglass/README.TXT

NOTES: If you have problems, please let me know. This is my first crack at doing a driver.

7 Likes

Great job!

2 Likes

I've put in a pull request to have this added to Hubitat Package Manager.

2 Likes

I was looking for a way to automate my lights based on my xbox media playback status and found this driver. Looks great but I've run in some issues setting this up. I've set up the REST server and everything looks good but I can't seem to get a connection to my Xbox. I've tried all the different device commands such as refresh and nexus and I'm getting these error messages:

java.lang.NullPointerException: Cannot invoke method getValue() on null object on line 126 (refresh)
groovyx.net.http.HttpResponseException: INTERNAL SERVER ERROR on line 313 (nexus)

I'm able to get a response using HTTP Get directly on my browser. Any ideas? Thanks!

Unfortunately, I have no way to test anymore.

Make sure your Xbox is setup to not do a full shutdown.

Also, make sure you can access it using standard URL’s.

Lastly, make sure all parameter are filled.

If you want, post some screen shots of the driver so I can jog my memory.

If it helps anyone, I've taken the Docker container from the XBox Open project and created one that exposes the appropriate ports.

This means that on my network I can just run the docker command and the openxbox-rest-server is listening on the appropriate port.

Docker Hub has the details.

Are you using the hubitat driver still?

Yes, it's just configured to point to a Docker image rather than the xbox API REST server running on a Raspberry Pi or similar.

I installed the Xbox app and drivers in Hubitat no problem. I wanted to move my Alexa xbox control commands into Hubitat routines so I can make them dashboard buttons.

Can anyone point me at how to go about setting up an Xbox REST server on Windows 10? I've been going over all the xbox rest api links and references to python installs, etc. and I'm not finding anything that says really how to set that up on a Windows PC. I see Linux examples and screenshots of Mac interfaces is all.

did you have any luck here? I am just starting out on this quest. ive never played with REST before so this will be an experience for me. I am also wondering i just buying a broadlink rm pro will do enough of what i need? good luck out there, will let you know if i see anything

I only got as far as installing the Xbox device driver and parent/child app code into Hubitat. That's my last device I have left to get integrated now into Hubitat. I'm going to try installing Python on Windows and then just see if that Xbox Rest stuff installs and I can find a place to get an IP address from it that the Xbox device driver needs in Hubitat. I'm not finding any straight forward instructions anywhere online.

Follow the install guide for the rest setup using the link in the description.

As for the IP, you need to grab that from your console. Probably good to setup a static IP or a DHCP reservation.

Thanks, I'll get to it soon. I noticed in the Hubitat Xbox app it asks for the IP of the Xbox console and IP address of the Rest server as well as a few other things (port, live id, etc).

I'm going to just have to manually update the IP when it changes. I have Netgear Nighthawk gaming router, but it was so flaky with being unable to maintain visibility across multiple PC's I have in my home office I wound up installing a 3rd party firmware (Voxel) and that turned out to have removed the options from the netgear router login for making IP's static. So I may have to figure that out. Or just remember to update the console IP when it changes. Its always something.

Its not working that easily unfortunately. I've installed Python 3.9.3 which is current. I went through all the setup steps on the "Installing packages" tutorial.

python --version
python -m pip --version
python -m pip install --upgrade pip setuptools wheel

All run from an Admin command line in Windows 10. And I'm not doing any of the virtual machine options since I am only going to use it for this one thing.

I also added the path it suggested adding to my system variables on the Python install. So that is correct. When I run these command more than once it just gives me a bunch of "Requirement already satisfied" messages.

Those commands all ran fine. Then I go back to the instructions on the pypi.org/project/xbox-smartglass-core page and do the following:

pip install xbox-smartglass-core

So now I should be able to run the commands but they don't all work.

  1. When I run xbox-cli I just get a bunch of traceback messages ending with ModuleNotFoundError: No module named 'requests'

  2. When I ran xbox-authenticate that one seemed to work as it popped up my 2-factor authentication on my phone and then I got an email message from Microsoft that OpenXbox WebAPI was linked to my account.

  3. When I run xbox-rest-server --host 10.1.10.45 -p 1234 I get a bunch of traceback messages starting with:

File "c:\program files..... (where I installed python)...\lib\runpy", line 197, in _run_module_as main
and ending in
ModuleNotFoundError: No module named 'requests'

So I'm kind of stumped at the moment getting the rest server running.

Okay, I got a little further. I found out how to get the requests error to go away. By running

pip install requests

Now I'm able to get the Rest server running. One step closer to getting it plugged into Hubitat.

Once I got the rest server running I updated the values in the Xbox smartglass app (IP of the PC running the rest server, IP of the xbox console, the XBox Live Device ID from the console setting screen and the port # from when I ran the rest server.

I'm able to control all the operations on the Xbox and see them sent to the rest server and they control the Xbox console with one exception. I can click the buttons on the Hubitat device screen for the buttons, dpad, and it does control the console.

BUT - the Off operation does not turn off the console. I see it show up in the rest server as I click the Off button in Hubitat but it wont' turn off. If I have the console turned off and I click the On button in the Hubitat console it does turn the box on.

I have all of the TV Device Control settings checked (HDMI-CEC, Console turns on other devices, Console turns off other devices, Other devices can turn console off, console sends volume commands).

Any ideas as to why it won't turn off?

I've got a little more debugging info. I still can't turn the device off and it seems like its stuck on what state it thinks the Xbox is in.

While I can turn it on from the Hubitat device. It still won't turn off.

While I have the console powered on and controlling it with the buttons on the Xbox Hubitat device it is saying the Current state is "off". Regardless if I had manually turned on the console or if I had turned it on from the Hubitat device. Turning it on from the Hubitat device it showed for a moment the Current state was on, then it changes back to off. If I click the On button on the Hubitat device with the Xbox already on, it changes the Current State to On for a moment, but it will show off and give the skipping message in the logs if I then click the device off button.

So, when I click the Off button or call a custom action to turn off the device, in the debugging logs it saying "skipping" because it thinks the Xbox is off.

dev:3542021-02-23 12:30:05.401 pm debugSetting 10.1.10.50 to off

dev:2882021-02-23 12:30:05.339 pm debugSkipping. Xbox 10.1.10.50 is already off

dev:3542021-02-23 12:30:02.804 pm debugPolling Xbox Devices

It pulls the state of the console from the rest server.

http://ip:port/device?addr=XboxIP

Post what it reports back.

Screenshot is of the rest server (the temporary redirect commands at the bottom are what it does when the Off button is clicked in the Hubitat device screen. To the right is the output of the http://ip:port/device?addr=xxx command. And the rest of the controls are working at the time such as dpad, nexus button, etc. This is one of the new Xbox Series X as well if that makes a difference.

Do this from a web browser and post your results.

Do the following while the Xbox is on and post pictures with each result.

Maybe send these in a private IM.

http://restIp:port/device

http://restIp:port/device?addr=xboxIP

http://restIp:port/device/liveID/connect?anonymous=true

Last command will shut it off

http://restIp:port/device/liveID/poweroff?addr=xboxIP

That was from a web browser. The json output that shows the liveid, connection_status, etc. is the browser window output after putting in that url using my rest server and console's ips.
There are 3 windows up in that screenshot (console running the rest server, web brower with the hubitat interface and a web browser for the http://ip... command.