Skip to content

Smartglass provider

SmartGlass - Control Registered Devices

pythonxbox.api.provider.smartglass.SmartglassProvider(client)

Bases: BaseProvider

Initialize Baseclass, create smartglass session id

Args: Instance of XBL client

Source code in src/pythonxbox/api/provider/smartglass/__init__.py
def __init__(self, client: "XboxLiveClient") -> None:
    """
    Initialize Baseclass, create smartglass session id

    Args: Instance of XBL client
    """
    super().__init__(client)
    self._smartglass_session_id = str(uuid4())

SG_URL = 'https://xccs.xboxlive.com' class-attribute instance-attribute

HEADERS_SG = {'x-xbl-contract-version': '4', 'skillplatform': 'RemoteManagement'} class-attribute instance-attribute

get_console_list(include_storage_devices=True, **kwargs) async

Get Console list

Parameters:

Name Type Description Default
include_storage_devices bool

Include a list of storage devices in the response

True

Returns: Console List

Source code in src/pythonxbox/api/provider/smartglass/__init__.py
async def get_console_list(
    self, include_storage_devices: bool = True, **kwargs
) -> SmartglassConsoleList:
    """
    Get Console list

    Args:
        include_storage_devices: Include a list of storage devices in the response

    Returns: Console List
    """
    params = {
        "queryCurrentDevice": "false",
        "includeStorageDevices": str(include_storage_devices).lower(),
    }
    resp = await self._fetch_list("devices", params, **kwargs)
    return SmartglassConsoleList.model_validate_json(resp.text)

get_installed_apps(device_id=None, **kwargs) async

Get Installed Apps

Parameters:

Name Type Description Default
device_id str | None

ID of console (from console list)

None

Returns: Installed Apps

Source code in src/pythonxbox/api/provider/smartglass/__init__.py
async def get_installed_apps(
    self, device_id: str | None = None, **kwargs
) -> InstalledPackagesList:
    """
    Get Installed Apps

    Args:
        device_id: ID of console (from console list)

    Returns: Installed Apps
    """
    params = {}
    if device_id:
        params["deviceId"] = device_id
    resp = await self._fetch_list("installedApps", params, **kwargs)
    return InstalledPackagesList.model_validate_json(resp.text)

get_storage_devices(device_id, **kwargs) async

Get Installed Apps

Parameters:

Name Type Description Default
device_id str

ID of console (from console list)

required

Returns: Storage Devices list

Source code in src/pythonxbox/api/provider/smartglass/__init__.py
async def get_storage_devices(self, device_id: str, **kwargs) -> StorageDevicesList:
    """
    Get Installed Apps

    Args:
        device_id: ID of console (from console list)

    Returns: Storage Devices list
    """
    params = {"deviceId": device_id}
    resp = await self._fetch_list("storageDevices", params, **kwargs)
    return StorageDevicesList.model_validate_json(resp.text)

get_console_status(device_id, **kwargs) async

Get Console Status

Parameters:

Name Type Description Default
device_id str

ID of console (from console list)

required

Returns: Console Status

Source code in src/pythonxbox/api/provider/smartglass/__init__.py
async def get_console_status(
    self, device_id: str, **kwargs
) -> SmartglassConsoleStatus:
    """
    Get Console Status

    Args:
        device_id: ID of console (from console list)

    Returns: Console Status
    """
    url = f"{self.SG_URL}/consoles/{device_id}"
    resp = await self.client.session.get(url, headers=self.HEADERS_SG, **kwargs)
    resp.raise_for_status()
    return SmartglassConsoleStatus.model_validate_json(resp.text)

get_op_status(device_id, op_id, **kwargs) async

Get Operation Status

Parameters:

Name Type Description Default
device_id str

ID of console (from console list)

required
op_id str

Operation ID (from previous command)

required

Returns: Operation Status

Source code in src/pythonxbox/api/provider/smartglass/__init__.py
async def get_op_status(
    self, device_id: str, op_id: str, **kwargs
) -> OperationStatusResponse:
    """
    Get Operation Status

    Args:
        device_id: ID of console (from console list)
        op_id: Operation ID (from previous command)

    Returns: Operation Status
    """
    url = f"{self.SG_URL}/opStatus"
    headers = {
        "x-xbl-contract-version": "3",
        "x-xbl-opId": op_id,
        "x-xbl-deviceId": device_id,
    }
    resp = await self.client.session.get(url, headers=headers, **kwargs)
    resp.raise_for_status()
    return OperationStatusResponse.model_validate_json(resp.text)

wake_up(device_id, **kwargs) async

Wake Up Console

Parameters:

Name Type Description Default
device_id str

ID of console (from console list)

required

Returns: Command Response

Source code in src/pythonxbox/api/provider/smartglass/__init__.py
async def wake_up(self, device_id: str, **kwargs) -> CommandResponse:
    """
    Wake Up Console

    Args:
        device_id: ID of console (from console list)

    Returns: Command Response
    """
    return await self._send_one_shot_command(device_id, "Power", "WakeUp", **kwargs)

turn_off(device_id, **kwargs) async

Turn Off Console

Parameters:

Name Type Description Default
device_id str

ID of console (from console list)

required

Returns: Command Response

Source code in src/pythonxbox/api/provider/smartglass/__init__.py
async def turn_off(self, device_id: str, **kwargs) -> CommandResponse:
    """
    Turn Off Console

    Args:
        device_id: ID of console (from console list)

    Returns: Command Response
    """
    return await self._send_one_shot_command(
        device_id, "Power", "TurnOff", **kwargs
    )

reboot(device_id, **kwargs) async

Reboot Console

Parameters:

Name Type Description Default
device_id str

ID of console (from console list)

required

Returns: Command Response

Source code in src/pythonxbox/api/provider/smartglass/__init__.py
async def reboot(self, device_id: str, **kwargs) -> CommandResponse:
    """
    Reboot Console

    Args:
        device_id: ID of console (from console list)

    Returns: Command Response
    """
    return await self._send_one_shot_command(device_id, "Power", "Reboot", **kwargs)

mute(device_id, **kwargs) async

Mute

Parameters:

Name Type Description Default
device_id str

ID of console (from console list)

required

Returns: Command Response

Source code in src/pythonxbox/api/provider/smartglass/__init__.py
async def mute(self, device_id: str, **kwargs) -> CommandResponse:
    """
    Mute

    Args:
        device_id: ID of console (from console list)

    Returns: Command Response
    """
    return await self._send_one_shot_command(device_id, "Audio", "Mute", **kwargs)

unmute(device_id, **kwargs) async

Unmute

Parameters:

Name Type Description Default
device_id str

ID of console (from console list)

required

Returns: Command Response

Source code in src/pythonxbox/api/provider/smartglass/__init__.py
async def unmute(self, device_id: str, **kwargs) -> CommandResponse:
    """
    Unmute

    Args:
        device_id: ID of console (from console list)

    Returns: Command Response
    """
    return await self._send_one_shot_command(device_id, "Audio", "Unmute", **kwargs)

volume(device_id, direction, amount=1, **kwargs) async

Adjust Volume

Parameters:

Name Type Description Default
device_id str

ID of console (from console list)

required

Returns: Command Response

Source code in src/pythonxbox/api/provider/smartglass/__init__.py
async def volume(
    self, device_id: str, direction: VolumeDirection, amount: int = 1, **kwargs
) -> CommandResponse:
    """
    Adjust Volume

    Args:
        device_id: ID of console (from console list)

    Returns: Command Response
    """
    params = [{"direction": direction.value, "amount": str(amount)}]
    return await self._send_one_shot_command(
        device_id, "Audio", "Volume", params, **kwargs
    )

play(device_id, **kwargs) async

Play (media controls)

Parameters:

Name Type Description Default
device_id str

ID of console (from console list)

required

Returns: Command Response

Source code in src/pythonxbox/api/provider/smartglass/__init__.py
async def play(self, device_id: str, **kwargs) -> CommandResponse:
    """
    Play (media controls)

    Args:
        device_id: ID of console (from console list)

    Returns: Command Response
    """
    return await self._send_one_shot_command(device_id, "Media", "Play", **kwargs)

pause(device_id, **kwargs) async

Pause (media controls)

Parameters:

Name Type Description Default
device_id str

ID of console (from console list)

required

Returns: Command Response

Source code in src/pythonxbox/api/provider/smartglass/__init__.py
async def pause(self, device_id: str, **kwargs) -> CommandResponse:
    """
    Pause (media controls)

    Args:
        device_id: ID of console (from console list)

    Returns: Command Response
    """
    return await self._send_one_shot_command(device_id, "Media", "Pause", **kwargs)

previous(device_id, **kwargs) async

Previous (media controls)

Parameters:

Name Type Description Default
device_id str

ID of console (from console list)

required

Returns: Command Response

Source code in src/pythonxbox/api/provider/smartglass/__init__.py
async def previous(self, device_id: str, **kwargs) -> CommandResponse:
    """
    Previous (media controls)

    Args:
        device_id: ID of console (from console list)

    Returns: Command Response
    """
    return await self._send_one_shot_command(
        device_id, "Media", "Previous", **kwargs
    )

next(device_id, **kwargs) async

Next (media controls)

Parameters:

Name Type Description Default
device_id str

ID of console (from console list)

required

Returns: Command Response

Source code in src/pythonxbox/api/provider/smartglass/__init__.py
async def next(self, device_id: str, **kwargs) -> CommandResponse:
    """
    Next (media controls)

    Args:
        device_id: ID of console (from console list)

    Returns: Command Response
    """
    return await self._send_one_shot_command(device_id, "Media", "Next", **kwargs)

go_home(device_id, **kwargs) async

Go Home

Parameters:

Name Type Description Default
device_id str

ID of console (from console list)

required

Returns: Command Response

Source code in src/pythonxbox/api/provider/smartglass/__init__.py
async def go_home(self, device_id: str, **kwargs) -> CommandResponse:
    """
    Go Home

    Args:
        device_id: ID of console (from console list)

    Returns: Command Response
    """
    return await self._send_one_shot_command(device_id, "Shell", "GoHome", **kwargs)

go_back(device_id, **kwargs) async

Go Back

Parameters:

Name Type Description Default
device_id str

ID of console (from console list)

required

Returns:

Type Description
CommandResponse

class:SmartglassConsoleStatus: Command Response

Source code in src/pythonxbox/api/provider/smartglass/__init__.py
async def go_back(self, device_id: str, **kwargs) -> CommandResponse:
    """
    Go Back

    Args:
        device_id: ID of console (from console list)

    Returns:
        :class:`SmartglassConsoleStatus`: Command Response
    """
    return await self._send_one_shot_command(device_id, "Shell", "GoBack", **kwargs)

show_guide_tab(device_id, tab=GuideTab.Guide, **kwargs) async

Show Guide Tab

Parameters:

Name Type Description Default
device_id str

ID of console (from console list)

required

Returns: Command Response

Source code in src/pythonxbox/api/provider/smartglass/__init__.py
async def show_guide_tab(
    self, device_id: str, tab: GuideTab = GuideTab.Guide, **kwargs
) -> CommandResponse:
    """
    Show Guide Tab

    Args:
        device_id: ID of console (from console list)

    Returns: Command Response
    """
    params = [{"tabName": tab.value}]
    return await self._send_one_shot_command(
        device_id, "Shell", "ShowGuideTab", params, **kwargs
    )

press_button(device_id, button, **kwargs) async

Press Button

Parameters:

Name Type Description Default
device_id str

ID of console (from console list)

required

Returns: Command Response

Source code in src/pythonxbox/api/provider/smartglass/__init__.py
async def press_button(
    self, device_id: str, button: InputKeyType, **kwargs
) -> CommandResponse:
    """
    Press Button

    Args:
        device_id: ID of console (from console list)

    Returns: Command Response
    """
    params = [{"keyType": button.value}]
    return await self._send_one_shot_command(
        device_id, "Shell", "InjectKey", params, **kwargs
    )

insert_text(device_id, text, **kwargs) async

Insert Text

Parameters:

Name Type Description Default
device_id str

ID of console (from console list)

required

Returns: Command Response

Source code in src/pythonxbox/api/provider/smartglass/__init__.py
async def insert_text(self, device_id: str, text: str, **kwargs) -> CommandResponse:
    """
    Insert Text

    Args:
        device_id: ID of console (from console list)

    Returns: Command Response
    """
    params = [{"replacementString": text}]
    return await self._send_one_shot_command(
        device_id, "Shell", "InjectString", params, **kwargs
    )

launch_app(device_id, one_store_product_id, **kwargs) async

Launch Application

Parameters:

Name Type Description Default
device_id str

ID of console (from console list)

required
one_store_product_id str

OneStoreProductID for the app to launch

required

Returns: Command Response

Source code in src/pythonxbox/api/provider/smartglass/__init__.py
async def launch_app(
    self, device_id: str, one_store_product_id: str, **kwargs
) -> CommandResponse:
    """
    Launch Application

    Args:
        device_id: ID of console (from console list)
        one_store_product_id: OneStoreProductID for the app to launch

    Returns: Command Response
    """
    params = [{"oneStoreProductId": one_store_product_id}]
    return await self._send_one_shot_command(
        device_id,
        "Shell",
        "ActivateApplicationWithOneStoreProductId",
        params,
        **kwargs,
    )

show_tv_guide(device_id, **kwargs) async

Show TV Guide

Parameters:

Name Type Description Default
device_id str

ID of console (from console list)

required

Returns: Command Response

Source code in src/pythonxbox/api/provider/smartglass/__init__.py
async def show_tv_guide(self, device_id: str, **kwargs) -> CommandResponse:
    """
    Show TV Guide

    Args:
        device_id: ID of console (from console list)

    Returns: Command Response
    """
    return await self._send_one_shot_command(device_id, "TV", "ShowGuide", **kwargs)