Skip to content

Commit

Permalink
Merge pull request hunterjm#31 from hunterjm/develop
Browse files Browse the repository at this point in the history
2.0.0
  • Loading branch information
hunterjm authored Feb 22, 2019
2 parents a3d6fe0 + 2301d9e commit 3aab1ce
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion xboxone/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ RUN apk add --no-cache jq gcc musl-dev python3-dev libffi-dev openssl-dev python
if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi && \
rm -r /root/.cache

RUN pip3 install xbox-smartglass-rest==0.9.6
RUN pip3 install xbox-smartglass-rest==0.9.8

CMD [ "/run.sh" ]
2 changes: 1 addition & 1 deletion xboxone/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ media_player:
name: Living Room Xbox One
```

**Note**: _This is just an example, don't copy and past it! Create your own!_
**Note**: _This is just an example, don't copy and paste it! Create your own!_

### Option: `platform`

Expand Down
2 changes: 1 addition & 1 deletion xboxone/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Xbox One",
"version": "1.1.0",
"version": "2.0.0",
"slug": "xboxone",
"description": "Control your Xbox One from your Home Assistant device",
"url": "https://github.com/hunterjm/hassio-addons/tree/master/xboxone",
Expand Down
4 changes: 2 additions & 2 deletions xboxone/run.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

# Copy over the xbox component
mkdir -p /config/custom_components/media_player
cp -f xboxone.py /config/custom_components/media_player/xboxone.py
mkdir -p /config/custom_components/xboxone
cp -f xboxone.py /config/custom_components/xboxone/media_player.py

# Persistent tokens on reboot
touch /config/.xbox-token.json
Expand Down
19 changes: 13 additions & 6 deletions xboxone/xboxone.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
- Original code: https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/media_player/firetv.py
"""
import logging

import functools
import requests
import voluptuous as vol
from urllib.parse import urljoin

from homeassistant.components.media_player import (
SUPPORT_NEXT_TRACK, SUPPORT_PAUSE, SUPPORT_PREVIOUS_TRACK, PLATFORM_SCHEMA,
MediaPlayerDevice, PLATFORM_SCHEMA)

from homeassistant.components.media_player.const import (
SUPPORT_NEXT_TRACK, SUPPORT_PAUSE, SUPPORT_PREVIOUS_TRACK,
SUPPORT_SELECT_SOURCE, SUPPORT_TURN_OFF, SUPPORT_TURN_ON,
SUPPORT_VOLUME_STEP, SUPPORT_VOLUME_MUTE, SUPPORT_PLAY, MediaPlayerDevice,
SUPPORT_VOLUME_STEP, SUPPORT_VOLUME_MUTE, SUPPORT_PLAY,
MEDIA_TYPE_MUSIC, MEDIA_TYPE_VIDEO, MEDIA_TYPE_TVSHOW, MEDIA_TYPE_CHANNEL)
from homeassistant.const import (
STATE_IDLE, STATE_OFF, STATE_PAUSED, STATE_PLAYING, STATE_UNKNOWN, STATE_ON,
Expand All @@ -33,7 +36,7 @@
SUPPORT_NEXT_TRACK | SUPPORT_SELECT_SOURCE | SUPPORT_PLAY | \
SUPPORT_VOLUME_STEP | SUPPORT_VOLUME_MUTE

REQUIRED_SERVER_VERSION = '0.9.6'
REQUIRED_SERVER_VERSION = '0.9.8'

DEFAULT_SSL = False
DEFAULT_HOST = 'localhost'
Expand Down Expand Up @@ -312,7 +315,11 @@ def _update_volume_controls(self):

def poweron(self):
try:
response = self.get('/device/<liveid>/poweron').json()
url = '/device/<liveid>/poweron'
params = None
if self._ip:
params = { 'addr': self._ip }
response = self.get(url, params=params).json()
if not response.get('success'):
_LOGGER.error('Failed to poweron {0}'.format(self.liveid))
return None
Expand Down Expand Up @@ -542,7 +549,7 @@ def state(self):
if playback_state:
state = playback_state
elif self._xboxone.connected or self._xboxone.available:
if self._xboxone.active_app_type not in ['Application', 'App'] or self._xboxone.active_app == 'Home':
if self._xboxone.active_app_type in ['Application', 'App'] or self._xboxone.active_app == 'Home':
state = STATE_ON
else:
state = STATE_UNKNOWN
Expand Down

0 comments on commit 3aab1ce

Please sign in to comment.