Remove attribution from extra state attributes (#76580)

pull/76595/head
Franck Nijhof 2022-08-11 03:24:12 +02:00 committed by GitHub
parent 8ecbb85852
commit dbfba3a951
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 26 deletions

View File

@ -10,12 +10,7 @@ import brottsplatskartan
import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import (
ATTR_ATTRIBUTION,
CONF_LATITUDE,
CONF_LONGITUDE,
CONF_NAME,
)
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -90,6 +85,8 @@ def setup_platform(
class BrottsplatskartanSensor(SensorEntity):
"""Representation of a Brottsplatskartan Sensor."""
_attr_attribution = brottsplatskartan.ATTRIBUTION
def __init__(self, bpk, name):
"""Initialize the Brottsplatskartan sensor."""
self._brottsplatskartan = bpk
@ -109,8 +106,5 @@ class BrottsplatskartanSensor(SensorEntity):
incident_type = incident.get("title_type")
incident_counts[incident_type] += 1
self._attr_extra_state_attributes = {
ATTR_ATTRIBUTION: brottsplatskartan.ATTRIBUTION
}
self._attr_extra_state_attributes.update(incident_counts)
self._attr_extra_state_attributes = incident_counts
self._attr_native_value = len(incidents)

View File

@ -9,7 +9,7 @@ from fixerio.exceptions import FixerioException
import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ATTR_ATTRIBUTION, CONF_API_KEY, CONF_NAME, CONF_TARGET
from homeassistant.const import CONF_API_KEY, CONF_NAME, CONF_TARGET
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -61,6 +61,8 @@ def setup_platform(
class ExchangeRateSensor(SensorEntity):
"""Representation of a Exchange sensor."""
_attr_attribution = ATTRIBUTION
def __init__(self, data, name, target):
"""Initialize the sensor."""
self.data = data
@ -88,7 +90,6 @@ class ExchangeRateSensor(SensorEntity):
"""Return the state attributes."""
if self.data.rate is not None:
return {
ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_EXCHANGE_RATE: self.data.rate["rates"][self._target],
ATTR_TARGET: self._target,
}

View File

@ -8,13 +8,7 @@ from gitlab import Gitlab, GitlabAuthenticationError, GitlabGetError
import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import (
ATTR_ATTRIBUTION,
CONF_NAME,
CONF_SCAN_INTERVAL,
CONF_TOKEN,
CONF_URL,
)
from homeassistant.const import CONF_NAME, CONF_SCAN_INTERVAL, CONF_TOKEN, CONF_URL
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -78,6 +72,8 @@ def setup_platform(
class GitLabSensor(SensorEntity):
"""Representation of a GitLab sensor."""
_attr_attribution = ATTRIBUTION
def __init__(self, gitlab_data, name):
"""Initialize the GitLab sensor."""
self._available = False
@ -111,7 +107,6 @@ class GitLabSensor(SensorEntity):
def extra_state_attributes(self):
"""Return the state attributes."""
return {
ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_BUILD_STATUS: self._state,
ATTR_BUILD_STARTED: self._started_at,
ATTR_BUILD_FINISHED: self._finished_at,

View File

@ -11,7 +11,6 @@ import requests
from homeassistant.components import ffmpeg
from homeassistant.components.camera import Camera
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_ATTRIBUTION
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.aiohttp_client import async_aiohttp_proxy_stream
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -49,6 +48,8 @@ async def async_setup_entry(
class RingCam(RingEntityMixin, Camera):
"""An implementation of a Ring Door Bell camera."""
_attr_attribution = ATTRIBUTION
def __init__(self, config_entry_id, ffmpeg_manager, device):
"""Initialize a Ring Door Bell camera."""
super().__init__(config_entry_id, device)
@ -105,7 +106,6 @@ class RingCam(RingEntityMixin, Camera):
def extra_state_attributes(self):
"""Return the state attributes."""
return {
ATTR_ATTRIBUTION: ATTRIBUTION,
"video_url": self._video_url,
"last_video_id": self._last_video_id,
}

View File

@ -13,7 +13,7 @@ from RMVtransport.rmvtransport import (
import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ATTR_ATTRIBUTION, CONF_NAME, CONF_TIMEOUT, TIME_MINUTES
from homeassistant.const import CONF_NAME, CONF_TIMEOUT, TIME_MINUTES
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import PlatformNotReady
import homeassistant.helpers.config_validation as cv
@ -116,6 +116,8 @@ async def async_setup_platform(
class RMVDepartureSensor(SensorEntity):
"""Implementation of an RMV departure sensor."""
_attr_attribution = ATTRIBUTION
def __init__(
self,
station,
@ -170,7 +172,6 @@ class RMVDepartureSensor(SensorEntity):
"minutes": self.data.departures[0].get("minutes"),
"departure_time": self.data.departures[0].get("departure_time"),
"product": self.data.departures[0].get("product"),
ATTR_ATTRIBUTION: ATTRIBUTION,
}
except IndexError:
return {}

View File

@ -5,7 +5,6 @@ from typing import Any, cast
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.device_registry import DeviceEntryType
from homeassistant.helpers.entity import DeviceInfo
@ -49,6 +48,7 @@ class SpeedtestSensor(
"""Implementation of a speedtest.net sensor."""
entity_description: SpeedtestSensorEntityDescription
_attr_attribution = ATTRIBUTION
_attr_has_entity_name = True
_attr_icon = ICON
@ -62,7 +62,7 @@ class SpeedtestSensor(
self.entity_description = description
self._attr_unique_id = description.key
self._state: StateType = None
self._attrs = {ATTR_ATTRIBUTION: ATTRIBUTION}
self._attrs: dict[str, Any] = {}
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, self.coordinator.config_entry.entry_id)},
name=DEFAULT_NAME,