* Use constant for offline state
* Use constant for no game name
* Rename trade and play constant their proper names
Trade and Play are not the correct names for the states. For instance
Play might be seens as the user is actually is playing, which is not
correct as there is no such state is returned from the Steam API.
Just having "trade" does not say much about what is happening and
might be misintepreted that the user is currently trading, which is not
correct either.
We instead use the names from the underlying library for naming the
states [1]
[1] 2e518ad84f/steam/user.py (L109)
* Get the proper game name if no extra info is given from the api
The third `current_game` parameter that was used before hold
extra information about the game that is being played. This might
contain the game name, it might also be empty. The correct way to
get the game name is to fetch it from the API depending on the
game id that might be returned in the `current_game` attribute if
the user is playing a game.
To not break existing implementations we keep the functionality
to first go with the extra information and only then fetch the proper
game name.
* Refactor getting game name to its own function
This cleans up the code and removed "ugly" else statements
from the sensor and makes the game fetching easier to read.
* Let state constant values be lower snake case
* Return None instead of 'None' when no current game exists
* Initialize steam app list only once to benefit form caching
* Return None as state attributes if no current game is present
I noticed the steam component "game" attribute is capitalized. This should be lowercase if I'm not mistaken.
From:
return {'Game': self._game}
To:
return {'game': self._game}
Not sure if i'm doing this correctly... apologizes if I'm not!