Remove xbox_live integration (#90592)

This commit is contained in:
Martin Hjelmare 2023-03-31 20:30:04 +02:00 committed by GitHub
parent 611d4135fd
commit 8256d9b472
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 1 additions and 187 deletions

View File

@ -1438,7 +1438,6 @@ omit =
homeassistant/components/xbox/media_player.py
homeassistant/components/xbox/remote.py
homeassistant/components/xbox/sensor.py
homeassistant/components/xbox_live/sensor.py
homeassistant/components/xeoma/camera.py
homeassistant/components/xiaomi/camera.py
homeassistant/components/xiaomi_aqara/__init__.py

View File

@ -1367,7 +1367,6 @@ build.json @home-assistant/supervisor
/tests/components/ws66i/ @ssaenger
/homeassistant/components/xbox/ @hunterjm
/tests/components/xbox/ @hunterjm
/homeassistant/components/xbox_live/ @MartinHjelmare
/homeassistant/components/xiaomi_aqara/ @danielhiversen @syssi
/tests/components/xiaomi_aqara/ @danielhiversen @syssi
/homeassistant/components/xiaomi_ble/ @Jc2k @Ernst79

View File

@ -10,7 +10,6 @@
"microsoft_face",
"microsoft",
"msteams",
"xbox",
"xbox_live"
"xbox"
]
}

View File

@ -1 +0,0 @@
"""The xbox_live component."""

View File

@ -1,9 +0,0 @@
{
"domain": "xbox_live",
"name": "Xbox Live",
"codeowners": ["@MartinHjelmare"],
"documentation": "https://www.home-assistant.io/integrations/xbox_live",
"iot_class": "cloud_polling",
"loggers": ["xboxapi"],
"requirements": ["xboxapi==2.0.1"]
}

View File

@ -1,156 +0,0 @@
"""Sensor for Xbox Live account status."""
from __future__ import annotations
from datetime import timedelta
import logging
import voluptuous as vol
from xboxapi import Client
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import CONF_API_KEY, CONF_SCAN_INTERVAL
from homeassistant.core import HomeAssistant, callback
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.issue_registry import IssueSeverity, create_issue
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
_LOGGER = logging.getLogger(__name__)
CONF_XUID = "xuid"
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
vol.Required(CONF_API_KEY): cv.string,
vol.Required(CONF_XUID): vol.All(cv.ensure_list, [cv.string]),
}
)
def setup_platform(
hass: HomeAssistant,
config: ConfigType,
add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the Xbox platform."""
create_issue(
hass,
"xbox_live",
"pending_removal",
breaks_in_ha_version="2023.2.0",
is_fixable=False,
severity=IssueSeverity.WARNING,
translation_key="pending_removal",
)
_LOGGER.warning(
"The Xbox Live integration is deprecated "
"and will be removed in Home Assistant 2023.2"
)
api = Client(api_key=config[CONF_API_KEY])
entities = []
# request profile info to check api connection
response = api.api_get("profile")
if not response.ok:
_LOGGER.error(
(
"Can't setup X API connection. Check your account or "
"api key on xapi.us. Code: %s Description: %s "
),
response.status_code,
response.reason,
)
return
users = config[CONF_XUID]
interval = timedelta(minutes=1 * len(users))
interval = config.get(CONF_SCAN_INTERVAL, interval)
for xuid in users:
if (gamercard := get_user_gamercard(api, xuid)) is None:
continue
entities.append(XboxSensor(api, xuid, gamercard, interval))
add_entities(entities, True)
def get_user_gamercard(api, xuid):
"""Get profile info."""
gamercard = api.gamer(gamertag="", xuid=xuid).get("gamercard")
_LOGGER.debug("User gamercard: %s", gamercard)
if gamercard.get("success", True) and gamercard.get("code") is None:
return gamercard
_LOGGER.error(
"Can't get user profile %s. Error Code: %s Description: %s",
xuid,
gamercard.get("code", "unknown"),
gamercard.get("description", "unknown"),
)
return None
class XboxSensor(SensorEntity):
"""A class for the Xbox account."""
_attr_icon = "mdi:microsoft-xbox"
_attr_should_poll = False
def __init__(self, api, xuid, gamercard, interval):
"""Initialize the sensor."""
self._state = None
self._presence = []
self._xuid = xuid
self._api = api
self._gamertag = gamercard["gamertag"]
self._gamerscore = gamercard["gamerscore"]
self._interval = interval
self._picture = gamercard["gamerpicSmallSslImagePath"]
self._tier = gamercard["tier"]
@property
def name(self):
"""Return the name of the sensor."""
return self._gamertag
@property
def native_value(self):
"""Return the state of the sensor."""
return self._state
@property
def extra_state_attributes(self):
"""Return the state attributes."""
attributes = {"gamerscore": self._gamerscore, "tier": self._tier}
for device in self._presence:
for title in device["titles"]:
attributes[f'{device["type"]} {title["placement"]}'] = title["name"]
return attributes
@property
def entity_picture(self):
"""Avatar of the account."""
return self._picture
async def async_added_to_hass(self) -> None:
"""Start custom polling."""
@callback
def async_update(event_time=None):
"""Update the entity."""
self.async_schedule_update_ha_state(True)
async_track_time_interval(self.hass, async_update, self._interval)
def update(self) -> None:
"""Update state data from Xbox API."""
presence = self._api.gamer(gamertag="", xuid=self._xuid).get("presence")
_LOGGER.debug("User presence: %s", presence)
self._state = presence["state"]
self._presence = presence.get("devices", [])

View File

@ -1,8 +0,0 @@
{
"issues": {
"pending_removal": {
"title": "The Xbox Live integration is being removed",
"description": "The Xbox Live integration is pending removal from Home Assistant and will no longer be available as of Home Assistant 2023.2.\n\nThe integration is being removed, because it is only useful for the legacy device Xbox 360 and the upstream API now requires a paid subscription. Newer consoles are supported by the Xbox integration for free.\n\nRemove the Xbox Live YAML configuration from your configuration.yaml file and restart Home Assistant to fix this issue."
}
}
}

View File

@ -3293,12 +3293,6 @@
"config_flow": true,
"iot_class": "cloud_polling",
"name": "Xbox"
},
"xbox_live": {
"integration_type": "hub",
"config_flow": false,
"iot_class": "cloud_polling",
"name": "Xbox Live"
}
}
},

View File

@ -2643,9 +2643,6 @@ wolf_smartset==0.1.11
# homeassistant.components.xbox
xbox-webapi==2.0.11
# homeassistant.components.xbox_live
xboxapi==2.0.1
# homeassistant.components.xiaomi_ble
xiaomi-ble==0.16.4