Xbox One / Smartglass Integration

Fixed my typo on last comment. You can launch something on your xbox whit the oficial ios or android xbox smartglass apps?

Itā€™s been a while, but with the smartglass rest server running, you should be able to do:

rest_command:
  xboxone_input:
    url: "http://192.168.1.10:5557/device/<live_id>/{{ type }}/{{ command }}"

Where type can be media or input and you replace the <live_id> with whatever yours is. The commands can be anything listed under:

http://HASS_IP:5557/device/<live_id>/input

or

http://HASS_IP:5557/device/<live_id>/media

see the RESTful Command documentation, for more info.

The {{ }} stuff defines a template, so you can call rest_command.xboxone_input from a button on your dashboard as a service with:

data:
  type: input
  command: dpad_up 

See the example at the bottom of the Entity Button Card documentation and the Service Calls documentation for more info on how to implement this on your lovelace dashboard, or as part of an automation, etc.

Iā€™ve only just got back into this after a semester of uni, so havenā€™t had a chance to test all this, but considering it works via the browser, the homeassistant REST functionality should be adequate.

1 Like

I stand corrected! Lol

Hi

Iā€™m running HA in a docker not Hassio. Iā€™ve installed the component and smartglass via pip3:

pip3 install marshmallow
pip3 install xbox-smartglass-core

What do I do next please? Iā€™ve tried going to my-domain.com:5557 but nothing is loading.

Thanks in advance.

Execute the server first

Change parameters to your liking

$ xbox-rest-server -b 127.0.0.1 -p 5557
1 Like

Thanks. Iā€™ve now got the liveid but Iā€™m a bit confused by the authentication stage.

Iā€™m running HA in a docker, so I used a PC to get the liveid - if I authenticate via xbox-rest-server on the PC, does the logged in ā€˜sessionā€™ get transferred to the HA docker? Or, is this not possible?

Update:

I tried adding:

media_player:
  - platform: xboxone
    device: xxxxxxxxxxxxxxxxxxxx
    ip_address: 192.168.30.45
    name: Xbox
    authentication: false

But no info at all is coming through :frowning:

Bumping - any ideas what Iā€™m missing?

Iā€™m trying the same kind of setup and my xbox-rest-server is running on a laptop. Edit media_player.py and replace DEFAULT_HOST = ā€˜localhostā€™ by the IP of your server

EDIT: authenticate on your xbox-rest-server by typing xbox-authenticate, it looks like this fetches your Microsoft account refresh token (for me it stored it under /Users/xxx/Library/Application Support/xbox/, using a Mac)
EDIT2: hold on doing this, home-assistant doesnā€™t start anymoreā€¦ Iā€™m troubleshooting
EDIT3: ok you need to start your xbox-rest-server on your external machine IP, otherwise HA is not available to access it and does not even boot (at least it shows in the logs)

I have recently updated my docker image to the new github repo and added some extra config and personal security. Its a very simple dockerfile so its nothing amazing.

if you want to have your own local build you can set it up like below.

dockerfile

FROM python:3.7-alpine as base

ARG default_server=127.0.0.1
ARG default_port=5557

RUN addgroup -S app && adduser -S -g docker docker
WORKDIR /home/docker
RUN apk add --no-cache gcc musl-dev libffi-dev openssl-dev
COPY requirements.txt /requirements.txt
RUN pip3 install -r /requirements.txt

USER docker
ENV SERVER=$default_server
ENV PORT=$default_port
RUN echo $PATH

CMD [ "sh", "-c", "xbox-rest-server -b $SERVER -p $PORT"]

requirements.txt

marshmallow==3.5.1
xbox-smartglass-core==1.2.2

Build it as you would a normal docker file then run it with or without the SERVER and PORT environmental arguments.

Alternatively you can use my image from docker hub, this is a third party image so please consider building yourself as always for the best security!

version: '3.4'
services:
  xboxrestapi:
    container_name: xboxrestapi
    image: whatdaybob/xbox-smartglass-core
    environment: [
      "SERVER=0.0.0.0",
      "PORT=5557"
    ]
    volumes: [
      '/etc/localtime:/etc/localtime:ro'
    ]
    restart: always
    ports: ['5557:5557']

Hope this helps someone somewhere?

@whatdaybob using Dockerhub is a good idea you should get in touch with the owner of the GitHub repo to publish an ā€œofficialā€ image: https://github.com/OpenXbox/xbox-smartglass-core-python/issues/21

I have limited Docker knowledge but ended up running xbox-smartglass-core-python in a Docker container on the same server than my HA instance using the dockerfile provided in the repo and ā€œdocker build --tag xbox-smartglass-core-python:1.0ā€ then bind it locally so only HA can access it.

Itā€™s a bit risky to run this on a network as anyone can access the unauthenticated /auth API endpoint and get the Microsoft JWT refresh token

I believe @tuxuser already has this in the works as I see a lot of work going into it, the dockerfile in the repo is almost spot on and it seems there is a docker hub build by the official owner but its not publically available just now, mine is a stop gap in the simplest way possible with any ip and port the end user needs.

This is extremely outdated hence this version uses the official pypi rest server that was updated as recently as 10 days ago I believe?

Smart and is exactly how I am using it in my docker-compose using the networking capabilities.

Great point out to anyone unaware of this issue!

My only reason for building this myself was due to me not being able to use the refresh token via any personal build or external build using the old xbox-smartglass-core-python code, i just though if there is anyone else out there experiencing the same issue as me could see how to tackle the problem themselves.

1 Like

Hi, iā€™ve installed XboxOne hassio-addons and i correctly connected it to my XboxOne. I can turn Off it.
I donā€™t know why, but i canā€™t start app (Example Netflix). What i need to do?

Any luck on this front? Iā€™m having the same issue with the Xbox Smartglass Pythong program.

Iā€™m launching directly from URL and yet nothing happens on my Xbox.

I am assuming this wonā€™t work with XBox 360 ?

It looks like Xbox pulled some of the features from the API.

Iā€™m able to send power on/off comands, plus control button presses.

I havenā€™t tested the HA plugin, but Iā€™ve done this directly with HTTP commands.

I am actually unable to get this working as intended. I can get it working as it shouldā€¦ however it kills all automations ones I get the restful api add-on running time receive the data