mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Migrate attribution attribute for AmberElectric (#57505)
This commit is contained in:
parent
e94bebdf7b
commit
813e27a46a
@ -10,7 +10,6 @@ from homeassistant.components.binary_sensor import (
|
||||
BinarySensorEntityDescription,
|
||||
)
|
||||
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
|
||||
@ -28,6 +27,8 @@ PRICE_SPIKE_ICONS = {
|
||||
class AmberPriceGridSensor(CoordinatorEntity, BinarySensorEntity):
|
||||
"""Sensor to show single grid binary values."""
|
||||
|
||||
_attr_attribution = ATTRIBUTION
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: AmberUpdateCoordinator,
|
||||
@ -38,7 +39,6 @@ class AmberPriceGridSensor(CoordinatorEntity, BinarySensorEntity):
|
||||
self.site_id = coordinator.site_id
|
||||
self.entity_description = description
|
||||
self._attr_unique_id = f"{coordinator.site_id}-{description.key}"
|
||||
self._attr_device_state_attributes = {ATTR_ATTRIBUTION: ATTRIBUTION}
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool | None:
|
||||
@ -67,7 +67,6 @@ class AmberPriceSpikeBinarySensor(AmberPriceGridSensor):
|
||||
spike_status = self.coordinator.data["grid"]["price_spike"]
|
||||
return {
|
||||
"spike_status": spike_status,
|
||||
ATTR_ATTRIBUTION: ATTRIBUTION,
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,7 +20,7 @@ from homeassistant.components.sensor import (
|
||||
SensorEntityDescription,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_ATTRIBUTION, CURRENCY_DOLLAR, ENERGY_KILO_WATT_HOUR
|
||||
from homeassistant.const import CURRENCY_DOLLAR, ENERGY_KILO_WATT_HOUR
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
@ -54,6 +54,8 @@ def friendly_channel_type(channel_type: str) -> str:
|
||||
class AmberSensor(CoordinatorEntity, SensorEntity):
|
||||
"""Amber Base Sensor."""
|
||||
|
||||
_attr_attribution = ATTRIBUTION
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: AmberUpdateCoordinator,
|
||||
@ -88,7 +90,7 @@ class AmberPriceSensor(AmberSensor):
|
||||
"""Return additional pieces of information about the price."""
|
||||
interval = self.coordinator.data[self.entity_description.key][self.channel_type]
|
||||
|
||||
data: dict[str, Any] = {ATTR_ATTRIBUTION: ATTRIBUTION}
|
||||
data: dict[str, Any] = {}
|
||||
if interval is None:
|
||||
return data
|
||||
|
||||
@ -143,7 +145,6 @@ class AmberForecastSensor(AmberSensor):
|
||||
data = {
|
||||
"forecasts": [],
|
||||
"channel_type": intervals[0].channel_type.value,
|
||||
ATTR_ATTRIBUTION: ATTRIBUTION,
|
||||
}
|
||||
|
||||
for interval in intervals:
|
||||
@ -172,6 +173,8 @@ class AmberForecastSensor(AmberSensor):
|
||||
class AmberGridSensor(CoordinatorEntity, SensorEntity):
|
||||
"""Sensor to show single grid specific values."""
|
||||
|
||||
_attr_attribution = ATTRIBUTION
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: AmberUpdateCoordinator,
|
||||
@ -181,7 +184,6 @@ class AmberGridSensor(CoordinatorEntity, SensorEntity):
|
||||
super().__init__(coordinator)
|
||||
self.site_id = coordinator.site_id
|
||||
self.entity_description = description
|
||||
self._attr_device_state_attributes = {ATTR_ATTRIBUTION: ATTRIBUTION}
|
||||
self._attr_unique_id = f"{coordinator.site_id}-{description.key}"
|
||||
|
||||
@property
|
||||
|
Loading…
x
Reference in New Issue
Block a user