mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Migrate attribution attribute for Picnic (#57507)
This commit is contained in:
parent
580b5fb812
commit
e94bebdf7b
@ -5,7 +5,6 @@ from typing import Any
|
|||||||
|
|
||||||
from homeassistant.components.sensor import SensorEntity
|
from homeassistant.components.sensor import SensorEntity
|
||||||
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.typing import StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
from homeassistant.helpers.update_coordinator import (
|
from homeassistant.helpers.update_coordinator import (
|
||||||
@ -41,8 +40,8 @@ async def async_setup_entry(
|
|||||||
class PicnicSensor(SensorEntity, CoordinatorEntity):
|
class PicnicSensor(SensorEntity, CoordinatorEntity):
|
||||||
"""The CoordinatorEntity subclass representing Picnic sensors."""
|
"""The CoordinatorEntity subclass representing Picnic sensors."""
|
||||||
|
|
||||||
|
_attr_attribution = ATTRIBUTION
|
||||||
entity_description: PicnicSensorEntityDescription
|
entity_description: PicnicSensorEntityDescription
|
||||||
_attr_extra_state_attributes = {ATTR_ATTRIBUTION: ATTRIBUTION}
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -138,6 +138,8 @@ class TestPicnicSensor(unittest.IsolatedAsyncioTestCase):
|
|||||||
if unit:
|
if unit:
|
||||||
assert sensor.attributes["unit_of_measurement"] == unit
|
assert sensor.attributes["unit_of_measurement"] == unit
|
||||||
|
|
||||||
|
assert sensor.attributes["attribution"] == "Data provided by Picnic"
|
||||||
|
|
||||||
async def _setup_platform(
|
async def _setup_platform(
|
||||||
self, use_default_responses=False, enable_all_sensors=True
|
self, use_default_responses=False, enable_all_sensors=True
|
||||||
):
|
):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user