Move lastfm constants to separate file (#92289)

This commit is contained in:
Joost Lekkerkerker 2023-04-30 18:09:02 +02:00 committed by GitHub
parent ed286fc223
commit cd52e05075
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 11 deletions

View File

@ -0,0 +1,15 @@
"""Constants for LastFM."""
import logging
from typing import Final
LOGGER = logging.getLogger(__package__)
DOMAIN: Final = "lastfm"
DEFAULT_NAME = "LastFM"
CONF_USERS = "users"
ATTR_LAST_PLAYED = "last_played"
ATTR_PLAY_COUNT = "play_count"
ATTR_TOP_PLAYED = "top_played"
STATE_NOT_SCROBBLING = "Not Scrobbling"

View File

@ -2,7 +2,6 @@
from __future__ import annotations from __future__ import annotations
import hashlib import hashlib
import logging
from pylast import LastFMNetwork, Track, User, WSError from pylast import LastFMNetwork, Track, User, WSError
import voluptuous as vol import voluptuous as vol
@ -14,15 +13,14 @@ import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
LOGGER = logging.getLogger(__name__) from .const import (
ATTR_LAST_PLAYED,
CONF_USERS = "users" ATTR_PLAY_COUNT,
ATTR_TOP_PLAYED,
ATTR_LAST_PLAYED = "last_played" CONF_USERS,
ATTR_PLAY_COUNT = "play_count" LOGGER,
ATTR_TOP_PLAYED = "top_played" STATE_NOT_SCROBBLING,
)
STATE_NOT_SCROBBLING = "Not Scrobbling"
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{ {

View File

@ -5,7 +5,7 @@ from pylast import Track
import pytest import pytest
from homeassistant.components import sensor from homeassistant.components import sensor
from homeassistant.components.lastfm.sensor import STATE_NOT_SCROBBLING from homeassistant.components.lastfm.const import STATE_NOT_SCROBBLING
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component