mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Move attribution to standalone attribute [h-l] (#80516)
This commit is contained in:
parent
9ff077e225
commit
5d207f77ae
@ -10,7 +10,7 @@ import requests
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
from homeassistant.const import ATTR_ATTRIBUTION, CONF_API_KEY, CONF_EMAIL
|
from homeassistant.const import CONF_API_KEY, CONF_EMAIL
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
@ -21,8 +21,6 @@ import homeassistant.util.dt as dt_util
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
ATTRIBUTION = "Data provided by Have I Been Pwned (HIBP)"
|
|
||||||
|
|
||||||
DATE_STR_FORMAT = "%Y-%m-%d %H:%M:%S"
|
DATE_STR_FORMAT = "%Y-%m-%d %H:%M:%S"
|
||||||
|
|
||||||
HA_USER_AGENT = "Home Assistant HaveIBeenPwned Sensor Component"
|
HA_USER_AGENT = "Home Assistant HaveIBeenPwned Sensor Component"
|
||||||
@ -61,6 +59,8 @@ def setup_platform(
|
|||||||
class HaveIBeenPwnedSensor(SensorEntity):
|
class HaveIBeenPwnedSensor(SensorEntity):
|
||||||
"""Implementation of a HaveIBeenPwned sensor."""
|
"""Implementation of a HaveIBeenPwned sensor."""
|
||||||
|
|
||||||
|
_attr_attribution = "Data provided by Have I Been Pwned (HIBP)"
|
||||||
|
|
||||||
def __init__(self, data, email):
|
def __init__(self, data, email):
|
||||||
"""Initialize the HaveIBeenPwned sensor."""
|
"""Initialize the HaveIBeenPwned sensor."""
|
||||||
self._state = None
|
self._state = None
|
||||||
@ -86,7 +86,7 @@ class HaveIBeenPwnedSensor(SensorEntity):
|
|||||||
@property
|
@property
|
||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self):
|
||||||
"""Return the attributes of the sensor."""
|
"""Return the attributes of the sensor."""
|
||||||
val = {ATTR_ATTRIBUTION: ATTRIBUTION}
|
val = {}
|
||||||
if self._email not in self._data.data:
|
if self._email not in self._data.data:
|
||||||
return val
|
return val
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ from homeassistant.components.binary_sensor import (
|
|||||||
BinarySensorEntity,
|
BinarySensorEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import ATTR_ATTRIBUTION
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import DeviceInfo
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
@ -78,7 +77,6 @@ async def async_setup_entry(
|
|||||||
"button_type": elevator.get("buttonType"),
|
"button_type": elevator.get("buttonType"),
|
||||||
"cause": elevator.get("cause"),
|
"cause": elevator.get("cause"),
|
||||||
"lines": lines,
|
"lines": lines,
|
||||||
ATTR_ATTRIBUTION: ATTRIBUTION,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return elevators
|
return elevators
|
||||||
@ -126,6 +124,8 @@ async def async_setup_entry(
|
|||||||
class HvvDepartureBinarySensor(CoordinatorEntity, BinarySensorEntity):
|
class HvvDepartureBinarySensor(CoordinatorEntity, BinarySensorEntity):
|
||||||
"""HVVDepartureBinarySensor class."""
|
"""HVVDepartureBinarySensor class."""
|
||||||
|
|
||||||
|
_attr_attribution = ATTRIBUTION
|
||||||
|
|
||||||
def __init__(self, coordinator, idx, config_entry):
|
def __init__(self, coordinator, idx, config_entry):
|
||||||
"""Initialize."""
|
"""Initialize."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
|
@ -7,7 +7,7 @@ from requests.exceptions import ConnectTimeout, HTTPError
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import persistent_notification
|
from homeassistant.components import persistent_notification
|
||||||
from homeassistant.const import ATTR_ATTRIBUTION, CONF_ACCESS_TOKEN, CONF_SCAN_INTERVAL
|
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_SCAN_INTERVAL
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect, dispatcher_send
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect, dispatcher_send
|
||||||
@ -19,8 +19,6 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
ALLOWED_WATERING_TIME = [5, 10, 15, 30, 45, 60]
|
ALLOWED_WATERING_TIME = [5, 10, 15, 30, 45, 60]
|
||||||
|
|
||||||
ATTRIBUTION = "Data provided by hydrawise.com"
|
|
||||||
|
|
||||||
CONF_WATERING_TIME = "watering_minutes"
|
CONF_WATERING_TIME = "watering_minutes"
|
||||||
|
|
||||||
NOTIFICATION_ID = "hydrawise_notification"
|
NOTIFICATION_ID = "hydrawise_notification"
|
||||||
@ -89,6 +87,8 @@ class HydrawiseHub:
|
|||||||
class HydrawiseEntity(Entity):
|
class HydrawiseEntity(Entity):
|
||||||
"""Entity class for Hydrawise devices."""
|
"""Entity class for Hydrawise devices."""
|
||||||
|
|
||||||
|
_attr_attribution = "Data provided by hydrawise.com"
|
||||||
|
|
||||||
def __init__(self, data, description: EntityDescription):
|
def __init__(self, data, description: EntityDescription):
|
||||||
"""Initialize the Hydrawise entity."""
|
"""Initialize the Hydrawise entity."""
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
@ -111,4 +111,4 @@ class HydrawiseEntity(Entity):
|
|||||||
@property
|
@property
|
||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
return {ATTR_ATTRIBUTION: ATTRIBUTION, "identifier": self.data.get("relay")}
|
return {"identifier": self.data.get("relay")}
|
||||||
|
@ -16,7 +16,7 @@ from pyicloud.services.findmyiphone import AppleDevice
|
|||||||
|
|
||||||
from homeassistant.components.zone import async_active_zone
|
from homeassistant.components.zone import async_active_zone
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import ATTR_ATTRIBUTION, CONF_USERNAME
|
from homeassistant.const import CONF_USERNAME
|
||||||
from homeassistant.core import CALLBACK_TYPE, HomeAssistant
|
from homeassistant.core import CALLBACK_TYPE, HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
from homeassistant.helpers.dispatcher import dispatcher_send
|
from homeassistant.helpers.dispatcher import dispatcher_send
|
||||||
@ -48,8 +48,6 @@ from .const import (
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
)
|
)
|
||||||
|
|
||||||
ATTRIBUTION = "Data provided by Apple iCloud"
|
|
||||||
|
|
||||||
# entity attributes
|
# entity attributes
|
||||||
ATTR_ACCOUNT_FETCH_INTERVAL = "account_fetch_interval"
|
ATTR_ACCOUNT_FETCH_INTERVAL = "account_fetch_interval"
|
||||||
ATTR_BATTERY = "battery"
|
ATTR_BATTERY = "battery"
|
||||||
@ -368,6 +366,8 @@ class IcloudAccount:
|
|||||||
class IcloudDevice:
|
class IcloudDevice:
|
||||||
"""Representation of a iCloud device."""
|
"""Representation of a iCloud device."""
|
||||||
|
|
||||||
|
_attr_attribution = "Data provided by Apple iCloud"
|
||||||
|
|
||||||
def __init__(self, account: IcloudAccount, device: AppleDevice, status) -> None:
|
def __init__(self, account: IcloudAccount, device: AppleDevice, status) -> None:
|
||||||
"""Initialize the iCloud device."""
|
"""Initialize the iCloud device."""
|
||||||
self._account = account
|
self._account = account
|
||||||
@ -385,7 +385,6 @@ class IcloudDevice:
|
|||||||
self._location = None
|
self._location = None
|
||||||
|
|
||||||
self._attrs = {
|
self._attrs = {
|
||||||
ATTR_ATTRIBUTION: ATTRIBUTION,
|
|
||||||
ATTR_ACCOUNT_FETCH_INTERVAL: self._account.fetch_interval,
|
ATTR_ACCOUNT_FETCH_INTERVAL: self._account.fetch_interval,
|
||||||
ATTR_DEVICE_NAME: self._device_model,
|
ATTR_DEVICE_NAME: self._device_model,
|
||||||
ATTR_DEVICE_STATUS: None,
|
ATTR_DEVICE_STATUS: None,
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.components.sensor import SensorEntity, SensorEntityDescription
|
from homeassistant.components.sensor import SensorEntity, SensorEntityDescription
|
||||||
from homeassistant.const import ATTR_ATTRIBUTION, CONF_MONITORED_CONDITIONS
|
from homeassistant.const import CONF_MONITORED_CONDITIONS
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
@ -11,8 +11,6 @@ from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
|||||||
|
|
||||||
from . import ATTR_VERSION, DATA_UPDATED, DOMAIN as IPERF3_DOMAIN, SENSOR_TYPES
|
from . import ATTR_VERSION, DATA_UPDATED, DOMAIN as IPERF3_DOMAIN, SENSOR_TYPES
|
||||||
|
|
||||||
ATTRIBUTION = "Data retrieved using Iperf3"
|
|
||||||
|
|
||||||
ICON = "mdi:speedometer"
|
ICON = "mdi:speedometer"
|
||||||
|
|
||||||
ATTR_PROTOCOL = "Protocol"
|
ATTR_PROTOCOL = "Protocol"
|
||||||
@ -42,6 +40,7 @@ async def async_setup_platform(
|
|||||||
class Iperf3Sensor(RestoreEntity, SensorEntity):
|
class Iperf3Sensor(RestoreEntity, SensorEntity):
|
||||||
"""A Iperf3 sensor implementation."""
|
"""A Iperf3 sensor implementation."""
|
||||||
|
|
||||||
|
_attr_attribution = "Data retrieved using Iperf3"
|
||||||
_attr_icon = ICON
|
_attr_icon = ICON
|
||||||
_attr_should_poll = False
|
_attr_should_poll = False
|
||||||
|
|
||||||
@ -55,7 +54,6 @@ class Iperf3Sensor(RestoreEntity, SensorEntity):
|
|||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
return {
|
return {
|
||||||
ATTR_ATTRIBUTION: ATTRIBUTION,
|
|
||||||
ATTR_PROTOCOL: self._iperf3_data.protocol,
|
ATTR_PROTOCOL: self._iperf3_data.protocol,
|
||||||
ATTR_REMOTE_HOST: self._iperf3_data.host,
|
ATTR_REMOTE_HOST: self._iperf3_data.host,
|
||||||
ATTR_REMOTE_PORT: self._iperf3_data.port,
|
ATTR_REMOTE_PORT: self._iperf3_data.port,
|
||||||
|
@ -7,7 +7,7 @@ from pyirishrail.pyirishrail import IrishRailRTPI
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
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
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
@ -23,7 +23,6 @@ ATTR_DUE_AT = "Due at"
|
|||||||
ATTR_EXPECT_AT = "Expected at"
|
ATTR_EXPECT_AT = "Expected at"
|
||||||
ATTR_NEXT_UP = "Later Train"
|
ATTR_NEXT_UP = "Later Train"
|
||||||
ATTR_TRAIN_TYPE = "Train type"
|
ATTR_TRAIN_TYPE = "Train type"
|
||||||
ATTRIBUTION = "Data provided by Irish Rail"
|
|
||||||
|
|
||||||
CONF_STATION = "station"
|
CONF_STATION = "station"
|
||||||
CONF_DESTINATION = "destination"
|
CONF_DESTINATION = "destination"
|
||||||
@ -76,6 +75,8 @@ def setup_platform(
|
|||||||
class IrishRailTransportSensor(SensorEntity):
|
class IrishRailTransportSensor(SensorEntity):
|
||||||
"""Implementation of an irish rail public transport sensor."""
|
"""Implementation of an irish rail public transport sensor."""
|
||||||
|
|
||||||
|
_attr_attribution = "Data provided by Irish Rail"
|
||||||
|
|
||||||
def __init__(self, data, station, direction, destination, stops_at, name):
|
def __init__(self, data, station, direction, destination, stops_at, name):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
self.data = data
|
self.data = data
|
||||||
@ -110,7 +111,6 @@ class IrishRailTransportSensor(SensorEntity):
|
|||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ATTR_ATTRIBUTION: ATTRIBUTION,
|
|
||||||
ATTR_STATION: self._station,
|
ATTR_STATION: self._station,
|
||||||
ATTR_ORIGIN: self._times[0][ATTR_ORIGIN],
|
ATTR_ORIGIN: self._times[0][ATTR_ORIGIN],
|
||||||
ATTR_DESTINATION: self._times[0][ATTR_DESTINATION],
|
ATTR_DESTINATION: self._times[0][ATTR_DESTINATION],
|
||||||
|
@ -10,7 +10,7 @@ from pylast import WSError
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
from homeassistant.const import ATTR_ATTRIBUTION, CONF_API_KEY
|
from homeassistant.const import CONF_API_KEY
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
@ -21,7 +21,6 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
ATTR_LAST_PLAYED = "last_played"
|
ATTR_LAST_PLAYED = "last_played"
|
||||||
ATTR_PLAY_COUNT = "play_count"
|
ATTR_PLAY_COUNT = "play_count"
|
||||||
ATTR_TOP_PLAYED = "top_played"
|
ATTR_TOP_PLAYED = "top_played"
|
||||||
ATTRIBUTION = "Data provided by Last.fm"
|
|
||||||
|
|
||||||
STATE_NOT_SCROBBLING = "Not Scrobbling"
|
STATE_NOT_SCROBBLING = "Not Scrobbling"
|
||||||
|
|
||||||
@ -64,6 +63,8 @@ def setup_platform(
|
|||||||
class LastfmSensor(SensorEntity):
|
class LastfmSensor(SensorEntity):
|
||||||
"""A class for the Last.fm account."""
|
"""A class for the Last.fm account."""
|
||||||
|
|
||||||
|
_attr_attribution = "Data provided by Last.fm"
|
||||||
|
|
||||||
def __init__(self, user, lastfm_api):
|
def __init__(self, user, lastfm_api):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
self._unique_id = hashlib.sha256(user.encode("utf-8")).hexdigest()
|
self._unique_id = hashlib.sha256(user.encode("utf-8")).hexdigest()
|
||||||
@ -117,7 +118,6 @@ class LastfmSensor(SensorEntity):
|
|||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
return {
|
return {
|
||||||
ATTR_ATTRIBUTION: ATTRIBUTION,
|
|
||||||
ATTR_LAST_PLAYED: self._lastplayed,
|
ATTR_LAST_PLAYED: self._lastplayed,
|
||||||
ATTR_PLAY_COUNT: self._playcount,
|
ATTR_PLAY_COUNT: self._playcount,
|
||||||
ATTR_TOP_PLAYED: self._topplayed,
|
ATTR_TOP_PLAYED: self._topplayed,
|
||||||
|
@ -8,7 +8,6 @@ from homeassistant.components.camera import Camera, CameraEntityFeature
|
|||||||
from homeassistant.components.ffmpeg import get_ffmpeg_manager
|
from homeassistant.components.ffmpeg import get_ffmpeg_manager
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ATTRIBUTION,
|
|
||||||
ATTR_BATTERY_CHARGING,
|
ATTR_BATTERY_CHARGING,
|
||||||
ATTR_BATTERY_LEVEL,
|
ATTR_BATTERY_LEVEL,
|
||||||
ATTR_ENTITY_ID,
|
ATTR_ENTITY_ID,
|
||||||
@ -62,6 +61,7 @@ async def async_setup_entry(
|
|||||||
class LogiCam(Camera):
|
class LogiCam(Camera):
|
||||||
"""An implementation of a Logi Circle camera."""
|
"""An implementation of a Logi Circle camera."""
|
||||||
|
|
||||||
|
_attr_attribution = ATTRIBUTION
|
||||||
_attr_should_poll = True # Cameras default to False
|
_attr_should_poll = True # Cameras default to False
|
||||||
_attr_supported_features = CameraEntityFeature.ON_OFF
|
_attr_supported_features = CameraEntityFeature.ON_OFF
|
||||||
|
|
||||||
@ -141,7 +141,6 @@ class LogiCam(Camera):
|
|||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
state = {
|
state = {
|
||||||
ATTR_ATTRIBUTION: ATTRIBUTION,
|
|
||||||
"battery_saving_mode": (
|
"battery_saving_mode": (
|
||||||
STATE_ON if self._camera.battery_saving else STATE_OFF
|
STATE_ON if self._camera.battery_saving else STATE_OFF
|
||||||
),
|
),
|
||||||
|
@ -7,7 +7,6 @@ from typing import Any
|
|||||||
from homeassistant.components.sensor import SensorEntity, SensorEntityDescription
|
from homeassistant.components.sensor import SensorEntity, SensorEntityDescription
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ATTRIBUTION,
|
|
||||||
ATTR_BATTERY_CHARGING,
|
ATTR_BATTERY_CHARGING,
|
||||||
CONF_MONITORED_CONDITIONS,
|
CONF_MONITORED_CONDITIONS,
|
||||||
CONF_SENSORS,
|
CONF_SENSORS,
|
||||||
@ -58,6 +57,8 @@ async def async_setup_entry(
|
|||||||
class LogiSensor(SensorEntity):
|
class LogiSensor(SensorEntity):
|
||||||
"""A sensor implementation for a Logi Circle camera."""
|
"""A sensor implementation for a Logi Circle camera."""
|
||||||
|
|
||||||
|
_attr_attribution = ATTRIBUTION
|
||||||
|
|
||||||
def __init__(self, camera, time_zone, description: SensorEntityDescription):
|
def __init__(self, camera, time_zone, description: SensorEntityDescription):
|
||||||
"""Initialize a sensor for Logi Circle camera."""
|
"""Initialize a sensor for Logi Circle camera."""
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
@ -82,7 +83,6 @@ class LogiSensor(SensorEntity):
|
|||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
state = {
|
state = {
|
||||||
ATTR_ATTRIBUTION: ATTRIBUTION,
|
|
||||||
"battery_saving_mode": (
|
"battery_saving_mode": (
|
||||||
STATE_ON if self._camera.battery_saving else STATE_OFF
|
STATE_ON if self._camera.battery_saving else STATE_OFF
|
||||||
),
|
),
|
||||||
|
@ -9,7 +9,6 @@ from london_tube_status import TubeData
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
from homeassistant.const import ATTR_ATTRIBUTION
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import PlatformNotReady
|
from homeassistant.exceptions import PlatformNotReady
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
@ -25,8 +24,6 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
DOMAIN = "london_underground"
|
DOMAIN = "london_underground"
|
||||||
|
|
||||||
ATTRIBUTION = "Powered by TfL Open Data"
|
|
||||||
|
|
||||||
CONF_LINE = "line"
|
CONF_LINE = "line"
|
||||||
|
|
||||||
ICON = "mdi:subway"
|
ICON = "mdi:subway"
|
||||||
@ -102,11 +99,12 @@ class LondonTubeCoordinator(DataUpdateCoordinator):
|
|||||||
class LondonTubeSensor(CoordinatorEntity[LondonTubeCoordinator], SensorEntity):
|
class LondonTubeSensor(CoordinatorEntity[LondonTubeCoordinator], SensorEntity):
|
||||||
"""Sensor that reads the status of a line from Tube Data."""
|
"""Sensor that reads the status of a line from Tube Data."""
|
||||||
|
|
||||||
|
_attr_attribution = "Powered by TfL Open Data"
|
||||||
|
|
||||||
def __init__(self, coordinator, name):
|
def __init__(self, coordinator, name):
|
||||||
"""Initialize the London Underground sensor."""
|
"""Initialize the London Underground sensor."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
self._name = name
|
self._name = name
|
||||||
self.attrs = {ATTR_ATTRIBUTION: ATTRIBUTION}
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@ -126,5 +124,4 @@ class LondonTubeSensor(CoordinatorEntity[LondonTubeCoordinator], SensorEntity):
|
|||||||
@property
|
@property
|
||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self):
|
||||||
"""Return other details about the sensor state."""
|
"""Return other details about the sensor state."""
|
||||||
self.attrs["Description"] = self.coordinator.data[self.name]["Description"]
|
return {"Description": self.coordinator.data[self.name]["Description"]}
|
||||||
return self.attrs
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user