Move attribution to standalone attribute [e-g] (#80513)

This commit is contained in:
epenet
2022-10-18 10:04:54 +02:00
committed by GitHub
parent cb530e398c
commit c717fd19de
9 changed files with 25 additions and 47 deletions

View File

@@ -7,14 +7,12 @@ from pyetherscan import get_balance
import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ATTR_ATTRIBUTION, CONF_ADDRESS, CONF_NAME, CONF_TOKEN
from homeassistant.const import CONF_ADDRESS, CONF_NAME, CONF_TOKEN
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
ATTRIBUTION = "Data provided by etherscan.io"
CONF_TOKEN_ADDRESS = "token_address"
SCAN_INTERVAL = timedelta(minutes=5)
@@ -54,6 +52,8 @@ def setup_platform(
class EtherscanSensor(SensorEntity):
"""Representation of an Etherscan.io sensor."""
_attr_attribution = "Data provided by etherscan.io"
def __init__(self, name, address, token, token_address):
"""Initialize the sensor."""
self._name = name
@@ -78,11 +78,6 @@ class EtherscanSensor(SensorEntity):
"""Return the unit of measurement this sensor expresses itself in."""
return self._unit_of_measurement
@property
def extra_state_attributes(self):
"""Return the state attributes of the sensor."""
return {ATTR_ATTRIBUTION: ATTRIBUTION}
def update(self) -> None:
"""Get the latest state of the sensor."""