Move attribution to standalone attribute [r-s] (#80520)

* Move attribution to standalone attribute [r-s]

* Fix test
This commit is contained in:
epenet 2022-10-18 13:33:20 +02:00 committed by GitHub
parent 6b56336e52
commit c37e4b870f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 28 additions and 52 deletions

View file

@ -11,7 +11,7 @@ from homeassistant.components.sensor import (
SensorStateClass,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_ATTRIBUTION, ENERGY_KILO_WATT_HOUR
from homeassistant.const import ENERGY_KILO_WATT_HOUR
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
@ -83,6 +83,7 @@ async def async_setup_entry(
class SrpEntity(SensorEntity):
"""Implementation of a Srp Energy Usage sensor."""
_attr_attribution = ATTRIBUTION
_attr_should_poll = False
def __init__(self, coordinator):
@ -127,17 +128,6 @@ class SrpEntity(SensorEntity):
return f"{self.coordinator.data:.2f}"
return None
@property
def extra_state_attributes(self):
"""Return the state attributes."""
if not self.coordinator.data:
return None
attributes = {
ATTR_ATTRIBUTION: ATTRIBUTION,
}
return attributes
@property
def available(self):
"""Return if entity is available."""