Move icon constants to entity attributes (#90518)

* Move icon constants to attribute

* Adjust test
This commit is contained in:
epenet 2023-03-31 09:34:17 +02:00 committed by GitHub
parent 2e0ecf9bd9
commit d0c38c1e12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 46 additions and 177 deletions

View File

@ -20,7 +20,6 @@ _RESOURCE = "http://apilayer.net/api/live"
DEFAULT_BASE = "USD"
DEFAULT_NAME = "CurrencyLayer Sensor"
ICON = "mdi:currency"
SCAN_INTERVAL = timedelta(hours=4)
@ -60,6 +59,7 @@ class CurrencylayerSensor(SensorEntity):
"""Implementing the Currencylayer sensor."""
_attr_attribution = "Data provided by currencylayer.com"
_attr_icon = "mdi:currency"
def __init__(self, rest, base, quote):
"""Initialize the sensor."""
@ -78,11 +78,6 @@ class CurrencylayerSensor(SensorEntity):
"""Return the name of the sensor."""
return self._base
@property
def icon(self):
"""Return the icon to use in the frontend, if any."""
return ICON
@property
def native_value(self):
"""Return the state of the sensor."""

View File

@ -32,7 +32,7 @@ CONF_STOP_ID = "stopid"
CONF_ROUTE = "route"
DEFAULT_NAME = "Next Bus"
ICON = "mdi:bus"
SCAN_INTERVAL = timedelta(minutes=1)
TIME_STR_FORMAT = "%H:%M"
@ -77,6 +77,7 @@ class DublinPublicTransportSensor(SensorEntity):
"""Implementation of an Dublin public transport sensor."""
_attr_attribution = "Data provided by data.dublinked.ie"
_attr_icon = "mdi:bus"
def __init__(self, data, stop, route, name):
"""Initialize the sensor."""
@ -118,11 +119,6 @@ class DublinPublicTransportSensor(SensorEntity):
"""Return the unit this state is expressed in."""
return UnitOfTime.MINUTES
@property
def icon(self):
"""Icon to use in the frontend, if any."""
return ICON
def update(self) -> None:
"""Get the latest data from opendata.ch and update the states."""
self.data.update()

View File

@ -19,12 +19,10 @@ _LOGGER = logging.getLogger(__name__)
ATTR_EXCHANGE_RATE = "Exchange rate"
ATTR_TARGET = "Target currency"
ATTRIBUTION = "Data provided by the European Central Bank (ECB)"
DEFAULT_BASE = "USD"
DEFAULT_NAME = "Exchange rate"
ICON = "mdi:currency-usd"
SCAN_INTERVAL = timedelta(days=1)
@ -61,7 +59,8 @@ def setup_platform(
class ExchangeRateSensor(SensorEntity):
"""Representation of a Exchange sensor."""
_attr_attribution = ATTRIBUTION
_attr_attribution = "Data provided by the European Central Bank (ECB)"
_attr_icon = "mdi:currency-usd"
def __init__(self, data, name, target):
"""Initialize the sensor."""
@ -94,11 +93,6 @@ class ExchangeRateSensor(SensorEntity):
ATTR_TARGET: self._target,
}
@property
def icon(self):
"""Return the icon to use in the frontend, if any."""
return ICON
def update(self) -> None:
"""Get the latest data and updates the states."""
self.data.update()

View File

@ -23,7 +23,6 @@ ATTR_USERNAME = "username"
DEFAULT_NAME = "Gitter messages"
DEFAULT_ROOM = "home-assistant/home-assistant"
ICON = "mdi:message-cog"
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
@ -59,6 +58,8 @@ def setup_platform(
class GitterSensor(SensorEntity):
"""Representation of a Gitter sensor."""
_attr_icon = "mdi:message-cog"
def __init__(self, data, room, name, username):
"""Initialize the sensor."""
self._name = name
@ -93,11 +94,6 @@ class GitterSensor(SensorEntity):
ATTR_MENTION: self._mention,
}
@property
def icon(self):
"""Return the icon to use in the frontend, if any."""
return ICON
def update(self) -> None:
"""Get the latest data and updates the state."""

View File

@ -27,8 +27,6 @@ from . import KNOWN_DEVICES
from .connection import HKDevice
from .entity import HomeKitEntity
ICON = "mdi:security"
CURRENT_STATE_MAP = {
0: STATE_ALARM_ARMED_HOME,
1: STATE_ALARM_ARMED_AWAY,
@ -72,6 +70,7 @@ async def async_setup_entry(
class HomeKitAlarmControlPanelEntity(HomeKitEntity, AlarmControlPanelEntity):
"""Representation of a Homekit Alarm Control Panel."""
_attr_icon = "mdi:security"
_attr_supported_features = (
AlarmControlPanelEntityFeature.ARM_HOME
| AlarmControlPanelEntityFeature.ARM_AWAY
@ -86,11 +85,6 @@ class HomeKitAlarmControlPanelEntity(HomeKitEntity, AlarmControlPanelEntity):
CharacteristicsTypes.BATTERY_LEVEL,
]
@property
def icon(self) -> str:
"""Return icon."""
return ICON
@property
def state(self) -> str:
"""Return the state of the device."""

View File

@ -30,7 +30,7 @@ CONF_DIRECTION = "direction"
CONF_STOPS_AT = "stops_at"
DEFAULT_NAME = "Next Train"
ICON = "mdi:train"
SCAN_INTERVAL = timedelta(minutes=2)
TIME_STR_FORMAT = "%H:%M"
@ -76,6 +76,7 @@ class IrishRailTransportSensor(SensorEntity):
"""Implementation of an irish rail public transport sensor."""
_attr_attribution = "Data provided by Irish Rail"
_attr_icon = "mdi:train"
def __init__(self, data, station, direction, destination, stops_at, name):
"""Initialize the sensor."""
@ -128,11 +129,6 @@ class IrishRailTransportSensor(SensorEntity):
"""Return the unit this state is expressed in."""
return UnitOfTime.MINUTES
@property
def icon(self):
"""Icon to use in the frontend, if any."""
return ICON
def update(self) -> None:
"""Get the latest data and update the states."""
self.data.update()

View File

@ -26,7 +26,6 @@ STATE_NOT_SCROBBLING = "Not Scrobbling"
CONF_USERS = "users"
ICON = "mdi:radio-fm"
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
@ -64,6 +63,7 @@ class LastfmSensor(SensorEntity):
"""A class for the Last.fm account."""
_attr_attribution = "Data provided by Last.fm"
_attr_icon = "mdi:radio-fm"
def __init__(self, user, lastfm_api):
"""Initialize the sensor."""
@ -127,8 +127,3 @@ class LastfmSensor(SensorEntity):
def entity_picture(self):
"""Avatar of the user."""
return self._cover
@property
def icon(self):
"""Return the icon to use in the frontend."""
return ICON

View File

@ -26,7 +26,6 @@ DOMAIN = "london_underground"
CONF_LINE = "line"
ICON = "mdi:subway"
SCAN_INTERVAL = timedelta(seconds=30)
@ -100,6 +99,7 @@ class LondonTubeSensor(CoordinatorEntity[LondonTubeCoordinator], SensorEntity):
"""Sensor that reads the status of a line from Tube Data."""
_attr_attribution = "Powered by TfL Open Data"
_attr_icon = "mdi:subway"
def __init__(self, coordinator, name):
"""Initialize the London Underground sensor."""
@ -116,11 +116,6 @@ class LondonTubeSensor(CoordinatorEntity[LondonTubeCoordinator], SensorEntity):
"""Return the state of the sensor."""
return self.coordinator.data[self.name]["State"]
@property
def icon(self):
"""Icon to use in the frontend, if any."""
return ICON
@property
def extra_state_attributes(self):
"""Return other details about the sensor state."""

View File

@ -26,7 +26,6 @@ CONF_TO = "to"
CONF_VIA = "via"
CONF_TIME = "time"
ICON = "mdi:train"
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=120)
@ -104,6 +103,7 @@ class NSDepartureSensor(SensorEntity):
"""Implementation of a NS Departure Sensor."""
_attr_attribution = "Data provided by NS"
_attr_icon = "mdi:train"
def __init__(self, nsapi, name, departure, heading, via, time):
"""Initialize the sensor."""
@ -121,11 +121,6 @@ class NSDepartureSensor(SensorEntity):
"""Return the name of the sensor."""
return self._name
@property
def icon(self):
"""Return the icon for the frontend."""
return ICON
@property
def native_value(self):
"""Return the next departure time."""

View File

@ -33,7 +33,6 @@ DAILY_NAME = "Daily Energy Usage"
ACTIVE_TYPE = "active"
DAILY_TYPE = "daily"
ICON = "mdi:flash"
MIN_TIME_BETWEEN_DAILY_UPDATES = timedelta(seconds=150)
MIN_TIME_BETWEEN_ACTIVE_UPDATES = timedelta(seconds=10)
@ -140,6 +139,8 @@ class NeurioData:
class NeurioEnergy(SensorEntity):
"""Implementation of a Neurio energy sensor."""
_attr_icon = "mdi:flash"
def __init__(self, data, name, sensor_type, update_call):
"""Initialize the sensor."""
self._name = name
@ -172,11 +173,6 @@ class NeurioEnergy(SensorEntity):
"""Return the unit of measurement of this entity, if any."""
return self._unit_of_measurement
@property
def icon(self):
"""Icon to use in the frontend, if any."""
return ICON
def update(self) -> None:
"""Get the latest data, update state."""
self.update_sensor()

View File

@ -23,8 +23,6 @@ from . import (
_LOGGER = logging.getLogger(__name__)
ICON = "mdi:gauge"
def setup_platform(
hass: HomeAssistant,
@ -71,6 +69,8 @@ def setup_platform(
class NumatoGpioAdc(SensorEntity):
"""Represents an ADC port of a Numato USB GPIO expander."""
_attr_icon = "mdi:gauge"
def __init__(self, name, device_id, port, src_range, dst_range, dst_unit, api):
"""Initialize the sensor."""
self._name = name
@ -97,11 +97,6 @@ class NumatoGpioAdc(SensorEntity):
"""Return the unit the value is expressed in."""
return self._unit_of_measurement
@property
def icon(self):
"""Return the icon to use in the frontend, if any."""
return ICON
def update(self) -> None:
"""Get the latest data and updates the state."""
try:

View File

@ -34,7 +34,7 @@ CONF_STOP_ID = "stop_id"
CONF_ROUTE_ID = "route_id"
DEFAULT_NAME = "OASA Telematics"
ICON = "mdi:bus"
SCAN_INTERVAL = timedelta(seconds=60)
@ -67,6 +67,7 @@ class OASATelematicsSensor(SensorEntity):
"""Implementation of the OASA Telematics sensor."""
_attr_attribution = "Data retrieved from telematics.oasa.gr"
_attr_icon = "mdi:bus"
def __init__(self, data, stop_id, route_id, name):
"""Initialize the sensor."""
@ -121,11 +122,6 @@ class OASATelematicsSensor(SensorEntity):
)
return {k: v for k, v in params.items() if v}
@property
def icon(self):
"""Icon to use in the frontend, if any."""
return ICON
def update(self) -> None:
"""Get the latest data from OASA API and update the states."""
self.data.update()

View File

@ -17,7 +17,6 @@ DEFAULT_NAME = "OTP Sensor"
TIME_STEP = 30 # Default time step assumed by Google Authenticator
ICON = "mdi:update"
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
@ -44,6 +43,7 @@ async def async_setup_platform(
class TOTPSensor(SensorEntity):
"""Representation of a TOTP sensor."""
_attr_icon = "mdi:update"
_attr_should_poll = False
def __init__(self, name, token):
@ -76,8 +76,3 @@ class TOTPSensor(SensorEntity):
def native_value(self):
"""Return the state of the sensor."""
return self._state
@property
def icon(self):
"""Return the icon to use in the frontend."""
return ICON

View File

@ -16,7 +16,6 @@ from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
_LOGGER = logging.getLogger(__name__)
ICON = "mdi:rss"
SENSOR_NAME = "Pocketcasts unlistened episodes"
@ -48,6 +47,8 @@ def setup_platform(
class PocketCastsSensor(SensorEntity):
"""Representation of a pocket casts sensor."""
_attr_icon = "mdi:rss"
def __init__(self, api):
"""Initialize the sensor."""
self._api = api
@ -63,11 +64,6 @@ class PocketCastsSensor(SensorEntity):
"""Return the sensor state."""
return self._state
@property
def icon(self):
"""Return the icon for the sensor."""
return ICON
def update(self) -> None:
"""Update sensor values."""
try:

View File

@ -24,7 +24,6 @@ DEFAULT_NAME = "Random Sensor"
DEFAULT_MIN = 0
DEFAULT_MAX = 20
ICON = "mdi:hanger"
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
@ -54,6 +53,8 @@ async def async_setup_platform(
class RandomSensor(SensorEntity):
"""Representation of a Random number sensor."""
_attr_icon = "mdi:hanger"
def __init__(self, name, minimum, maximum, unit_of_measurement):
"""Initialize the Random sensor."""
self._name = name
@ -72,11 +73,6 @@ class RandomSensor(SensorEntity):
"""Return the state of the device."""
return self._state
@property
def icon(self):
"""Return the icon to use in the frontend, if any."""
return ICON
@property
def native_unit_of_measurement(self):
"""Return the unit this state is expressed in."""

View File

@ -42,7 +42,7 @@ CONF_DIRECTION = "direction"
CONF_DEPARTURE_TYPE = "departure_type"
DEFAULT_NAME = "Next departure"
ICON = "mdi:bus"
SCAN_INTERVAL = timedelta(minutes=1)
@ -98,6 +98,7 @@ class RejseplanenTransportSensor(SensorEntity):
"""Implementation of Rejseplanen transport sensor."""
_attr_attribution = "Data provided by rejseplanen.dk"
_attr_icon = "mdi:bus"
def __init__(self, data, stop_id, route, direction, name):
"""Initialize the sensor."""
@ -143,11 +144,6 @@ class RejseplanenTransportSensor(SensorEntity):
"""Return the unit this state is expressed in."""
return UnitOfTime.MINUTES
@property
def icon(self):
"""Icon to use in the frontend, if any."""
return ICON
def update(self) -> None:
"""Get the latest data from rejseplanen.dk and update the states."""
self.data.update()

View File

@ -34,8 +34,6 @@ DEFAULT_SEED = 999
DEFAULT_UNIT = "value"
DEFAULT_RELATIVE_TO_EPOCH = True
ICON = "mdi:chart-line"
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
vol.Optional(CONF_AMP, default=DEFAULT_AMP): vol.Coerce(float),
@ -79,6 +77,8 @@ def setup_platform(
class SimulatedSensor(SensorEntity):
"""Class for simulated sensor."""
_attr_icon = "mdi:chart-line"
def __init__(
self, name, unit, amp, mean, period, phase, fwhm, seed, relative_to_epoch
):
@ -135,11 +135,6 @@ class SimulatedSensor(SensorEntity):
"""Return the state of the sensor."""
return self._state
@property
def icon(self):
"""Icon to use in the frontend, if any."""
return ICON
@property
def native_unit_of_measurement(self):
"""Return the unit this state is expressed in."""

View File

@ -10,7 +10,6 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DOMAIN
SWITCH_PREFIX = "Switch"
ICON = "mdi:toggle-switch"
async def async_setup_entry(
@ -55,6 +54,8 @@ async def async_setup_entry(
class SmappeeActuator(SwitchEntity):
"""Representation of a Smappee Comport Plug."""
_attr_icon = "mdi:toggle-switch"
def __init__(
self,
smappee_base,
@ -105,11 +106,6 @@ class SmappeeActuator(SwitchEntity):
# Switch or comfort plug
return self._state == "ON_ON"
@property
def icon(self):
"""Icon to use in the frontend."""
return ICON
def turn_on(self, **kwargs: Any) -> None:
"""Turn on Comport Plug."""
if self._actuator_type in ("SWITCH", "COMFORT_PLUG"):

View File

@ -6,10 +6,8 @@ DEFAULT_NAME = "SRP Energy"
CONF_IS_TOU = "is_tou"
ATTRIBUTION = "Powered by SRP Energy"
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=1440)
SENSOR_NAME = "Usage"
SENSOR_TYPE = "usage"
ICON = "mdi:flash"

View File

@ -17,9 +17,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from .const import (
ATTRIBUTION,
DEFAULT_NAME,
ICON,
MIN_TIME_BETWEEN_UPDATES,
SENSOR_NAME,
SENSOR_TYPE,
@ -83,7 +81,8 @@ async def async_setup_entry(
class SrpEntity(SensorEntity):
"""Implementation of a Srp Energy Usage sensor."""
_attr_attribution = ATTRIBUTION
_attr_attribution = "Powered by SRP Energy"
_attr_icon = "mdi:flash"
_attr_should_poll = False
def __init__(self, coordinator):
@ -116,11 +115,6 @@ class SrpEntity(SensorEntity):
"""Return the unit of measurement of this entity, if any."""
return self._unit_of_measurement
@property
def icon(self):
"""Return icon."""
return ICON
@property
def usage(self):
"""Return entity state."""

View File

@ -26,7 +26,7 @@ CONF_SANDBOX = "sandbox"
DEFAULT_SANDBOX = False
DEFAULT_ACCOUNT_NAME = "Starling"
ICON = "mdi:currency-gbp"
SCAN_INTERVAL = timedelta(seconds=180)
ACCOUNT_SCHEMA = vol.Schema(
@ -76,6 +76,8 @@ def setup_platform(
class StarlingBalanceSensor(SensorEntity):
"""Representation of a Starling balance sensor."""
_attr_icon = "mdi:currency-gbp"
def __init__(self, starling_account, account_name, balance_data_type):
"""Initialize the sensor."""
self._starling_account = starling_account
@ -100,11 +102,6 @@ class StarlingBalanceSensor(SensorEntity):
"""Return the unit of measurement."""
return self._starling_account.currency
@property
def icon(self):
"""Return the entity icon."""
return ICON
def update(self) -> None:
"""Fetch new state data for the sensor."""
self._starling_account.update_balance_data()

View File

@ -35,7 +35,6 @@ CONF_START = "from"
DEFAULT_NAME = "Next Departure"
ICON = "mdi:bus"
SCAN_INTERVAL = timedelta(seconds=90)
@ -79,6 +78,7 @@ class SwissPublicTransportSensor(SensorEntity):
"""Implementation of an Swiss public transport sensor."""
_attr_attribution = "Data provided by transport.opendata.ch"
_attr_icon = "mdi:bus"
def __init__(self, opendata, start, destination, name):
"""Initialize the sensor."""
@ -125,11 +125,6 @@ class SwissPublicTransportSensor(SensorEntity):
ATTR_DELAY: self._opendata.connections[0]["delay"],
}
@property
def icon(self):
"""Icon to use in the frontend, if any."""
return ICON
async def async_update(self) -> None:
"""Get the latest data from opendata.ch and update the states."""

View File

@ -18,8 +18,6 @@ from homeassistant.util import Throttle
_LOGGER = logging.getLogger(__name__)
ICON = "mdi:bus-clock"
CONF_APP_ID = "app_id"
CONF_APP_KEY = "app_key"
CONF_LINE = "line"
@ -74,6 +72,7 @@ class TMBSensor(SensorEntity):
"""Implementation of a TMB line/stop Sensor."""
_attr_attribution = "Data provided by Transport Metropolitans de Barcelona"
_attr_icon = "mdi:bus-clock"
def __init__(self, ibus_client, stop, line, name):
"""Initialize the sensor."""
@ -89,11 +88,6 @@ class TMBSensor(SensorEntity):
"""Return the name of the sensor."""
return self._name
@property
def icon(self):
"""Return the icon for the frontend."""
return ICON
@property
def native_unit_of_measurement(self):
"""Return the unit of measurement."""

View File

@ -94,7 +94,6 @@ DEVICE_CLASS_MAP = {
UnitOfEnergy.KILO_WATT_HOUR: SensorDeviceClass.ENERGY,
}
ICON = "mdi:counter"
PRECISION = 3
PAUSED = "paused"
@ -323,6 +322,7 @@ class UtilitySensorExtraStoredData(SensorExtraStoredData):
class UtilityMeterSensor(RestoreSensor):
"""Representation of an utility meter sensor."""
_attr_icon = "mdi:counter"
_attr_should_poll = False
def __init__(
@ -659,11 +659,6 @@ class UtilityMeterSensor(RestoreSensor):
return state_attr
@property
def icon(self):
"""Return the icon to use in the frontend, if any."""
return ICON
@property
def extra_restore_state_data(self) -> UtilitySensorExtraStoredData:
"""Return sensor specific state data to be restored."""

View File

@ -32,7 +32,6 @@ CONF_SECRET = "secret"
DEFAULT_DELAY = 0
ICON = "mdi:train"
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=120)
@ -83,6 +82,7 @@ class VasttrafikDepartureSensor(SensorEntity):
"""Implementation of a Vasttrafik Departure Sensor."""
_attr_attribution = "Data provided by Västtrafik"
_attr_icon = "mdi:train"
def __init__(self, planner, name, departure, heading, lines, delay):
"""Initialize the sensor."""
@ -110,11 +110,6 @@ class VasttrafikDepartureSensor(SensorEntity):
"""Return the name of the sensor."""
return self._name
@property
def icon(self):
"""Return the icon for the frontend."""
return ICON
@property
def extra_state_attributes(self):
"""Return the state attributes."""

View File

@ -20,7 +20,6 @@ _LOGGER = logging.getLogger(__name__)
CONF_XUID = "xuid"
ICON = "mdi:microsoft-xbox"
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
@ -98,6 +97,7 @@ def get_user_gamercard(api, xuid):
class XboxSensor(SensorEntity):
"""A class for the Xbox account."""
_attr_icon = "mdi:microsoft-xbox"
_attr_should_poll = False
def __init__(self, api, xuid, gamercard, interval):
@ -138,11 +138,6 @@ class XboxSensor(SensorEntity):
"""Avatar of the account."""
return self._picture
@property
def icon(self):
"""Return the icon to use in the frontend."""
return ICON
async def async_added_to_hass(self) -> None:
"""Start custom polling."""

View File

@ -29,7 +29,7 @@ CONF_STOP_ID = "stop_id"
CONF_ROUTE = "routes"
DEFAULT_NAME = "Yandex Transport"
ICON = "mdi:bus"
SCAN_INTERVAL = timedelta(minutes=1)
@ -70,6 +70,7 @@ class DiscoverYandexTransport(SensorEntity):
"""Implementation of yandex_transport sensor."""
_attr_attribution = "Data provided by maps.yandex.ru"
_attr_icon = "mdi:bus"
def __init__(self, requester: YandexMapsRequester, stop_id, routes, name) -> None:
"""Initialize sensor."""
@ -168,8 +169,3 @@ class DiscoverYandexTransport(SensorEntity):
def extra_state_attributes(self):
"""Return the state attributes."""
return self._attrs
@property
def icon(self):
"""Icon to use in the frontend, if any."""
return ICON

View File

@ -24,7 +24,6 @@ DEFAULT_NAME = "Zestimate"
NAME = "zestimate"
ZESTIMATE = f"{DEFAULT_NAME}:{NAME}"
ICON = "mdi:home-variant"
ATTR_AMOUNT = "amount"
ATTR_CHANGE = "amount_change_30_days"
@ -67,6 +66,7 @@ class ZestimateDataSensor(SensorEntity):
"""Implementation of a Zestimate sensor."""
_attr_attribution = "Data provided by Zillow.com"
_attr_icon = "mdi:home-variant"
def __init__(self, name, params):
"""Initialize the sensor."""
@ -103,11 +103,6 @@ class ZestimateDataSensor(SensorEntity):
attributes["address"] = self.address
return attributes
@property
def icon(self):
"""Icon to use in the frontend, if any."""
return ICON
def update(self):
"""Get the latest data and update the states."""

View File

@ -3,9 +3,7 @@ from unittest.mock import MagicMock
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
from homeassistant.components.srp_energy.const import (
ATTRIBUTION,
DEFAULT_NAME,
ICON,
SENSOR_NAME,
SENSOR_TYPE,
SRP_ENERGY_DOMAIN,
@ -91,10 +89,10 @@ async def test_srp_entity(hass: HomeAssistant) -> None:
assert srp_entity.unique_id == SENSOR_TYPE
assert srp_entity.state is None
assert srp_entity.unit_of_measurement == UnitOfEnergy.KILO_WATT_HOUR
assert srp_entity.icon == ICON
assert srp_entity.icon == "mdi:flash"
assert srp_entity.usage == "2.00"
assert srp_entity.should_poll is False
assert srp_entity.attribution == ATTRIBUTION
assert srp_entity.attribution == "Powered by SRP Energy"
assert srp_entity.available is not None
assert srp_entity.device_class is SensorDeviceClass.ENERGY
assert srp_entity.state_class is SensorStateClass.TOTAL_INCREASING