diff --git a/homeassistant/components/comed_hourly_pricing/sensor.py b/homeassistant/components/comed_hourly_pricing/sensor.py index 38421813439..0e26b3406b8 100644 --- a/homeassistant/components/comed_hourly_pricing/sensor.py +++ b/homeassistant/components/comed_hourly_pricing/sensor.py @@ -15,7 +15,7 @@ from homeassistant.components.sensor import ( SensorEntity, SensorEntityDescription, ) -from homeassistant.const import ATTR_ATTRIBUTION, CONF_NAME, CONF_OFFSET +from homeassistant.const import CONF_NAME, CONF_OFFSET from homeassistant.core import HomeAssistant from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv @@ -27,8 +27,6 @@ _RESOURCE = "https://hourlypricing.comed.com/api" SCAN_INTERVAL = timedelta(minutes=5) -ATTRIBUTION = "Data provided by ComEd Hourly Pricing service" - CONF_CURRENT_HOUR_AVERAGE = "current_hour_average" CONF_FIVE_MINUTE = "five_minute" CONF_MONITORED_FEEDS = "monitored_feeds" @@ -91,7 +89,7 @@ async def async_setup_platform( class ComedHourlyPricingSensor(SensorEntity): """Implementation of a ComEd Hourly Pricing sensor.""" - _attr_extra_state_attributes = {ATTR_ATTRIBUTION: ATTRIBUTION} + _attr_attribution = "Data provided by ComEd Hourly Pricing service" def __init__(self, websession, offset, name, description: SensorEntityDescription): """Initialize the sensor.""" diff --git a/homeassistant/components/coronavirus/sensor.py b/homeassistant/components/coronavirus/sensor.py index 1a4f5b72fcd..7fa7c5aed08 100644 --- a/homeassistant/components/coronavirus/sensor.py +++ b/homeassistant/components/coronavirus/sensor.py @@ -1,7 +1,6 @@ """Sensor platform for the Corona virus.""" from homeassistant.components.sensor import SensorEntity from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ATTR_ATTRIBUTION from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.update_coordinator import CoordinatorEntity @@ -34,12 +33,12 @@ async def async_setup_entry( class CoronavirusSensor(CoordinatorEntity, SensorEntity): """Sensor representing corona virus data.""" + _attr_attribution = ATTRIBUTION _attr_native_unit_of_measurement = "people" def __init__(self, coordinator, country, info_type): """Initialize coronavirus sensor.""" super().__init__(coordinator) - self._attr_extra_state_attributes = {ATTR_ATTRIBUTION: ATTRIBUTION} self._attr_icon = SENSORS[info_type] self._attr_unique_id = f"{country}-{info_type}" if country == OPTION_WORLDWIDE: diff --git a/homeassistant/components/currencylayer/sensor.py b/homeassistant/components/currencylayer/sensor.py index 85f8b876765..9905228c26a 100644 --- a/homeassistant/components/currencylayer/sensor.py +++ b/homeassistant/components/currencylayer/sensor.py @@ -8,13 +8,7 @@ import requests import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity -from homeassistant.const import ( - ATTR_ATTRIBUTION, - CONF_API_KEY, - CONF_BASE, - CONF_NAME, - CONF_QUOTE, -) +from homeassistant.const import CONF_API_KEY, CONF_BASE, CONF_NAME, CONF_QUOTE from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -23,8 +17,6 @@ from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType _LOGGER = logging.getLogger(__name__) _RESOURCE = "http://apilayer.net/api/live" -ATTRIBUTION = "Data provided by currencylayer.com" - DEFAULT_BASE = "USD" DEFAULT_NAME = "CurrencyLayer Sensor" @@ -67,6 +59,8 @@ def setup_platform( class CurrencylayerSensor(SensorEntity): """Implementing the Currencylayer sensor.""" + _attr_attribution = "Data provided by currencylayer.com" + def __init__(self, rest, base, quote): """Initialize the sensor.""" self.rest = rest @@ -94,11 +88,6 @@ class CurrencylayerSensor(SensorEntity): """Return the state of the sensor.""" return self._state - @property - def extra_state_attributes(self): - """Return the state attributes of the sensor.""" - return {ATTR_ATTRIBUTION: ATTRIBUTION} - def update(self) -> None: """Update current date.""" self.rest.update() diff --git a/homeassistant/components/darksky/sensor.py b/homeassistant/components/darksky/sensor.py index db79b82de53..ccd4516e39c 100644 --- a/homeassistant/components/darksky/sensor.py +++ b/homeassistant/components/darksky/sensor.py @@ -18,7 +18,6 @@ from homeassistant.components.sensor import ( SensorStateClass, ) from homeassistant.const import ( - ATTR_ATTRIBUTION, CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, @@ -49,8 +48,6 @@ from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) -ATTRIBUTION = "Powered by Dark Sky" - CONF_FORECAST = "forecast" CONF_HOURLY_FORECAST = "hourly_forecast" CONF_LANGUAGE = "language" @@ -647,8 +644,8 @@ def setup_platform( class DarkSkySensor(SensorEntity): """Implementation of a Dark Sky sensor.""" + _attr_attribution = "Powered by Dark Sky" entity_description: DarkskySensorEntityDescription - _attr_extra_state_attributes = {ATTR_ATTRIBUTION: ATTRIBUTION} def __init__( self, diff --git a/homeassistant/components/digital_ocean/binary_sensor.py b/homeassistant/components/digital_ocean/binary_sensor.py index 9728da99a6f..59c6f7961c2 100644 --- a/homeassistant/components/digital_ocean/binary_sensor.py +++ b/homeassistant/components/digital_ocean/binary_sensor.py @@ -10,7 +10,6 @@ from homeassistant.components.binary_sensor import ( BinarySensorDeviceClass, BinarySensorEntity, ) -from homeassistant.const import ATTR_ATTRIBUTION from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -64,6 +63,8 @@ def setup_platform( class DigitalOceanBinarySensor(BinarySensorEntity): """Representation of a Digital Ocean droplet sensor.""" + _attr_attribution = ATTRIBUTION + def __init__(self, do, droplet_id): # pylint: disable=invalid-name """Initialize a new Digital Ocean sensor.""" self._digital_ocean = do @@ -90,7 +91,6 @@ class DigitalOceanBinarySensor(BinarySensorEntity): def extra_state_attributes(self): """Return the state attributes of the Digital Ocean droplet.""" return { - ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_CREATED_AT: self.data.created_at, ATTR_DROPLET_ID: self.data.id, ATTR_DROPLET_NAME: self.data.name, diff --git a/homeassistant/components/digital_ocean/switch.py b/homeassistant/components/digital_ocean/switch.py index da955e221a3..2791d83d6bc 100644 --- a/homeassistant/components/digital_ocean/switch.py +++ b/homeassistant/components/digital_ocean/switch.py @@ -7,7 +7,6 @@ from typing import Any import voluptuous as vol from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity -from homeassistant.const import ATTR_ATTRIBUTION from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -62,6 +61,8 @@ def setup_platform( class DigitalOceanSwitch(SwitchEntity): """Representation of a Digital Ocean droplet switch.""" + _attr_attribution = ATTRIBUTION + def __init__(self, do, droplet_id): # pylint: disable=invalid-name """Initialize a new Digital Ocean sensor.""" self._digital_ocean = do @@ -83,7 +84,6 @@ class DigitalOceanSwitch(SwitchEntity): def extra_state_attributes(self): """Return the state attributes of the Digital Ocean droplet.""" return { - ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_CREATED_AT: self.data.created_at, ATTR_DROPLET_ID: self.data.id, ATTR_DROPLET_NAME: self.data.name, diff --git a/homeassistant/components/discogs/sensor.py b/homeassistant/components/discogs/sensor.py index e207755ec24..51c69449d22 100644 --- a/homeassistant/components/discogs/sensor.py +++ b/homeassistant/components/discogs/sensor.py @@ -13,12 +13,7 @@ from homeassistant.components.sensor import ( SensorEntity, SensorEntityDescription, ) -from homeassistant.const import ( - ATTR_ATTRIBUTION, - CONF_MONITORED_CONDITIONS, - CONF_NAME, - CONF_TOKEN, -) +from homeassistant.const import CONF_MONITORED_CONDITIONS, CONF_NAME, CONF_TOKEN from homeassistant.core import HomeAssistant from homeassistant.helpers.aiohttp_client import SERVER_SOFTWARE import homeassistant.helpers.config_validation as cv @@ -29,8 +24,6 @@ _LOGGER = logging.getLogger(__name__) ATTR_IDENTITY = "identity" -ATTRIBUTION = "Data provided by Discogs" - DEFAULT_NAME = "Discogs" ICON_RECORD = "mdi:album" @@ -111,6 +104,8 @@ def setup_platform( class DiscogsSensor(SensorEntity): """Create a new Discogs sensor for a specific type.""" + _attr_attribution = "Data provided by Discogs" + def __init__(self, discogs_data, name, description: SensorEntityDescription): """Initialize the Discogs sensor.""" self.entity_description = description @@ -135,12 +130,10 @@ class DiscogsSensor(SensorEntity): "format": f"{self._attrs['formats'][0]['name']} ({self._attrs['formats'][0]['descriptions'][0]})", "label": self._attrs["labels"][0]["name"], "released": self._attrs["year"], - ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_IDENTITY: self._discogs_data["user"], } return { - ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_IDENTITY: self._discogs_data["user"], } diff --git a/homeassistant/components/dublin_bus_transport/sensor.py b/homeassistant/components/dublin_bus_transport/sensor.py index cf65c18e91c..6b9d47aecb3 100644 --- a/homeassistant/components/dublin_bus_transport/sensor.py +++ b/homeassistant/components/dublin_bus_transport/sensor.py @@ -14,7 +14,7 @@ import requests import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity -from homeassistant.const import ATTR_ATTRIBUTION, CONF_NAME, TIME_MINUTES +from homeassistant.const import CONF_NAME, TIME_MINUTES from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -29,8 +29,6 @@ ATTR_DUE_IN = "Due in" ATTR_DUE_AT = "Due at" ATTR_NEXT_UP = "Later Bus" -ATTRIBUTION = "Data provided by data.dublinked.ie" - CONF_STOP_ID = "stopid" CONF_ROUTE = "route" @@ -79,6 +77,8 @@ def setup_platform( class DublinPublicTransportSensor(SensorEntity): """Implementation of an Dublin public transport sensor.""" + _attr_attribution = "Data provided by data.dublinked.ie" + def __init__(self, data, stop, route, name): """Initialize the sensor.""" self.data = data @@ -111,7 +111,6 @@ class DublinPublicTransportSensor(SensorEntity): ATTR_DUE_AT: self._times[0][ATTR_DUE_AT], ATTR_STOP_ID: self._stop, ATTR_ROUTE: self._times[0][ATTR_ROUTE], - ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_NEXT_UP: next_up, } diff --git a/homeassistant/components/dwd_weather_warnings/sensor.py b/homeassistant/components/dwd_weather_warnings/sensor.py index 1436b416031..d6b3f6c2a0d 100644 --- a/homeassistant/components/dwd_weather_warnings/sensor.py +++ b/homeassistant/components/dwd_weather_warnings/sensor.py @@ -22,7 +22,7 @@ from homeassistant.components.sensor import ( SensorEntity, SensorEntityDescription, ) -from homeassistant.const import ATTR_ATTRIBUTION, CONF_MONITORED_CONDITIONS, CONF_NAME +from homeassistant.const import CONF_MONITORED_CONDITIONS, CONF_NAME from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -31,7 +31,6 @@ from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) -ATTRIBUTION = "Data provided by DWD" ATTR_REGION_NAME = "region_name" ATTR_REGION_ID = "region_id" ATTR_LAST_UPDATE = "last_update" @@ -108,6 +107,8 @@ def setup_platform( class DwdWeatherWarningsSensor(SensorEntity): """Representation of a DWD-Weather-Warnings sensor.""" + _attr_attribution = "Data provided by DWD" + def __init__( self, api, @@ -130,7 +131,6 @@ class DwdWeatherWarningsSensor(SensorEntity): def extra_state_attributes(self): """Return the state attributes of the DWD-Weather-Warnings.""" data = { - ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_REGION_NAME: self._api.api.warncell_name, ATTR_REGION_ID: self._api.api.warncell_id, ATTR_LAST_UPDATE: self._api.api.last_update,