1
mirror of https://github.com/home-assistant/core synced 2024-09-15 17:29:45 +02:00

Move imports in lastfm component (#28010)

* Move imports in lastfm component

* Fix pylint
This commit is contained in:
Diefferson Koderer Môro 2019-10-22 05:38:01 +00:00 committed by Paulus Schoutsen
parent 5d317dc096
commit 6c18bbcf04

View File

@ -2,10 +2,12 @@
import logging
import re
import pylast as lastfm
from pylast import WSError
import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import CONF_API_KEY, ATTR_ATTRIBUTION
from homeassistant.const import ATTR_ATTRIBUTION, CONF_API_KEY
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
@ -30,9 +32,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Last.fm sensor platform."""
import pylast as lastfm
from pylast import WSError
api_key = config[CONF_API_KEY]
users = config.get(CONF_USERS)
@ -53,11 +52,11 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
class LastfmSensor(Entity):
"""A class for the Last.fm account."""
def __init__(self, user, lastfm):
def __init__(self, user, lastfm_api):
"""Initialize the sensor."""
self._user = lastfm.get_user(user)
self._user = lastfm_api.get_user(user)
self._name = user
self._lastfm = lastfm
self._lastfm = lastfm_api
self._state = "Not Scrobbling"
self._playcount = None
self._lastplayed = None