mirror of
https://github.com/home-assistant/core
synced 2024-07-21 14:24:50 +02:00
Add Steam game ID and screenshot paths as attributes (#32005)
* Update Steam intergration to list screenshot paths and Steam game ID * Steam entity_picture now changed to game art when in-game * Steam - changing API endpoints to constants * Steam - formatting code for lint * Update sensor.py *Removing entity_picture image switching based on current playing game * Steam - tidying up code * Update homeassistant/components/steam_online/sensor.py Co-Authored-By: springstan <46536646+springstan@users.noreply.github.com> Co-authored-by: springstan <46536646+springstan@users.noreply.github.com>
This commit is contained in:
parent
df86668dfc
commit
f7f6c47973
@ -28,6 +28,10 @@ STATE_SNOOZE = "snooze"
|
|||||||
STATE_LOOKING_TO_TRADE = "looking_to_trade"
|
STATE_LOOKING_TO_TRADE = "looking_to_trade"
|
||||||
STATE_LOOKING_TO_PLAY = "looking_to_play"
|
STATE_LOOKING_TO_PLAY = "looking_to_play"
|
||||||
|
|
||||||
|
STEAM_API_URL = "https://steamcdn-a.akamaihd.net/steam/apps/"
|
||||||
|
STEAM_HEADER_IMAGE_FILE = "header.jpg"
|
||||||
|
STEAM_MAIN_IMAGE_FILE = "capsule_616x353.jpg"
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
{
|
{
|
||||||
vol.Required(CONF_API_KEY): cv.string,
|
vol.Required(CONF_API_KEY): cv.string,
|
||||||
@ -73,6 +77,7 @@ class SteamSensor(Entity):
|
|||||||
self._account = account
|
self._account = account
|
||||||
self._profile = None
|
self._profile = None
|
||||||
self._game = None
|
self._game = None
|
||||||
|
self._game_id = None
|
||||||
self._state = None
|
self._state = None
|
||||||
self._name = None
|
self._name = None
|
||||||
self._avatar = None
|
self._avatar = None
|
||||||
@ -104,6 +109,7 @@ class SteamSensor(Entity):
|
|||||||
try:
|
try:
|
||||||
self._profile = self._steamod.user.profile(self._account)
|
self._profile = self._steamod.user.profile(self._account)
|
||||||
self._game = self._get_current_game()
|
self._game = self._get_current_game()
|
||||||
|
self._game_id = self._profile.current_game[0]
|
||||||
self._state = {
|
self._state = {
|
||||||
1: STATE_ONLINE,
|
1: STATE_ONLINE,
|
||||||
2: STATE_BUSY,
|
2: STATE_BUSY,
|
||||||
@ -119,6 +125,7 @@ class SteamSensor(Entity):
|
|||||||
except self._steamod.api.HTTPTimeoutError as error:
|
except self._steamod.api.HTTPTimeoutError as error:
|
||||||
_LOGGER.warning(error)
|
_LOGGER.warning(error)
|
||||||
self._game = None
|
self._game = None
|
||||||
|
self._game_id = None
|
||||||
self._state = None
|
self._state = None
|
||||||
self._name = None
|
self._name = None
|
||||||
self._avatar = None
|
self._avatar = None
|
||||||
@ -170,6 +177,11 @@ class SteamSensor(Entity):
|
|||||||
attr = {}
|
attr = {}
|
||||||
if self._game is not None:
|
if self._game is not None:
|
||||||
attr["game"] = self._game
|
attr["game"] = self._game
|
||||||
|
if self._game_id is not None:
|
||||||
|
attr["game_id"] = self._game_id
|
||||||
|
game_url = f"{STEAM_API_URL}{self._game_id}/"
|
||||||
|
attr["game_image_header"] = f"{game_url}{STEAM_HEADER_IMAGE_FILE}"
|
||||||
|
attr["game_image_main"] = f"{game_url}{STEAM_MAIN_IMAGE_FILE}"
|
||||||
if self._last_online is not None:
|
if self._last_online is not None:
|
||||||
attr["last_online"] = self._last_online
|
attr["last_online"] = self._last_online
|
||||||
if self._level is not None:
|
if self._level is not None:
|
||||||
|
Loading…
Reference in New Issue
Block a user