mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Migrate to voluptuous (#3173)
This commit is contained in:
parent
32e1e046ae
commit
70888532f8
@ -5,12 +5,25 @@ For more details about this platform, please refer to the documentation at
|
|||||||
https://home-assistant.io/components/sensor.lastfm/
|
https://home-assistant.io/components/sensor.lastfm/
|
||||||
"""
|
"""
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.const import CONF_API_KEY
|
from homeassistant.const import CONF_API_KEY
|
||||||
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
|
REQUIREMENTS = ['pylast==1.6.0']
|
||||||
|
|
||||||
|
CONF_USERS = 'users'
|
||||||
|
|
||||||
ICON = 'mdi:lastfm'
|
ICON = 'mdi:lastfm'
|
||||||
|
|
||||||
REQUIREMENTS = ['pylast==1.6.0']
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
|
vol.Required(CONF_API_KEY): cv.string,
|
||||||
|
vol.Required(CONF_USERS, default=[]):
|
||||||
|
vol.All(cv.ensure_list, [cv.string]),
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
@ -18,9 +31,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
"""Setup the Last.fm platform."""
|
"""Setup the Last.fm platform."""
|
||||||
import pylast as lastfm
|
import pylast as lastfm
|
||||||
network = lastfm.LastFMNetwork(api_key=config.get(CONF_API_KEY))
|
network = lastfm.LastFMNetwork(api_key=config.get(CONF_API_KEY))
|
||||||
|
|
||||||
add_devices(
|
add_devices(
|
||||||
[LastfmSensor(username,
|
[LastfmSensor(username,
|
||||||
network) for username in config.get("users", [])])
|
network) for username in config.get(CONF_USERS)])
|
||||||
|
|
||||||
|
|
||||||
class LastfmSensor(Entity):
|
class LastfmSensor(Entity):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user