mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
commit
8dc6443d14
@ -137,6 +137,7 @@ omit =
|
|||||||
homeassistant/components/sensor/openweathermap.py
|
homeassistant/components/sensor/openweathermap.py
|
||||||
homeassistant/components/sensor/rest.py
|
homeassistant/components/sensor/rest.py
|
||||||
homeassistant/components/sensor/sabnzbd.py
|
homeassistant/components/sensor/sabnzbd.py
|
||||||
|
homeassistant/components/sensor/steam_online.py
|
||||||
homeassistant/components/sensor/speedtest.py
|
homeassistant/components/sensor/speedtest.py
|
||||||
homeassistant/components/sensor/swiss_public_transport.py
|
homeassistant/components/sensor/swiss_public_transport.py
|
||||||
homeassistant/components/sensor/systemmonitor.py
|
homeassistant/components/sensor/systemmonitor.py
|
||||||
|
74
homeassistant/components/sensor/steam_online.py
Normal file
74
homeassistant/components/sensor/steam_online.py
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
"""
|
||||||
|
homeassistant.components.sensor.steam_online
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
Sensor for Steam account status.
|
||||||
|
|
||||||
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/sensor.steam_online/
|
||||||
|
"""
|
||||||
|
from homeassistant.helpers.entity import Entity
|
||||||
|
from homeassistant.const import (ATTR_ENTITY_PICTURE, CONF_API_KEY)
|
||||||
|
|
||||||
|
ICON = 'mdi:steam'
|
||||||
|
|
||||||
|
REQUIREMENTS = ['steamodd==4.21']
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
|
""" Sets up the Steam platform. """
|
||||||
|
import steam as steamod
|
||||||
|
steamod.api.key.set(config.get(CONF_API_KEY))
|
||||||
|
add_devices(
|
||||||
|
[SteamSensor(account,
|
||||||
|
steamod) for account in config.get('accounts', [])])
|
||||||
|
|
||||||
|
|
||||||
|
class SteamSensor(Entity):
|
||||||
|
""" Steam account. """
|
||||||
|
|
||||||
|
# pylint: disable=abstract-method
|
||||||
|
def __init__(self, account, steamod):
|
||||||
|
self._steamod = steamod
|
||||||
|
self._account = account
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
""" Returns the name of the sensor. """
|
||||||
|
return self._profile.persona
|
||||||
|
|
||||||
|
@property
|
||||||
|
def entity_id(self):
|
||||||
|
""" Entity ID. """
|
||||||
|
return 'sensor.steam_{}'.format(self._account)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def state(self):
|
||||||
|
""" State of the sensor. """
|
||||||
|
return self._state
|
||||||
|
|
||||||
|
# pylint: disable=no-member
|
||||||
|
def update(self):
|
||||||
|
""" Update device state. """
|
||||||
|
self._profile = self._steamod.user.profile(self._account)
|
||||||
|
self._state = {
|
||||||
|
1: 'Online',
|
||||||
|
2: 'Busy',
|
||||||
|
3: 'Away',
|
||||||
|
4: 'Snooze',
|
||||||
|
5: 'Trade',
|
||||||
|
6: 'Play',
|
||||||
|
}.get(self._profile.status, 'Offline')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_state_attributes(self):
|
||||||
|
""" Returns the state attributes. """
|
||||||
|
return {
|
||||||
|
ATTR_ENTITY_PICTURE: self._profile.avatar_medium
|
||||||
|
}
|
||||||
|
|
||||||
|
@property
|
||||||
|
def icon(self):
|
||||||
|
""" Icon to use in the frontend """
|
||||||
|
return ICON
|
@ -243,6 +243,9 @@ somecomfort==0.2.1
|
|||||||
# homeassistant.components.sensor.speedtest
|
# homeassistant.components.sensor.speedtest
|
||||||
speedtest-cli==0.3.4
|
speedtest-cli==0.3.4
|
||||||
|
|
||||||
|
# homeassistant.components.sensor.steam_online
|
||||||
|
steamodd==4.21
|
||||||
|
|
||||||
# homeassistant.components.light.tellstick
|
# homeassistant.components.light.tellstick
|
||||||
# homeassistant.components.sensor.tellstick
|
# homeassistant.components.sensor.tellstick
|
||||||
# homeassistant.components.switch.tellstick
|
# homeassistant.components.switch.tellstick
|
||||||
|
Loading…
x
Reference in New Issue
Block a user