From e94bebdf7b2b145de81b427f1f6c21485d2adbbe Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Tue, 12 Oct 2021 05:39:51 +0200 Subject: [PATCH] Migrate attribution attribute for Picnic (#57507) --- homeassistant/components/picnic/sensor.py | 3 +-- tests/components/picnic/test_sensor.py | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/picnic/sensor.py b/homeassistant/components/picnic/sensor.py index e0f0d943663b..7eafef17982a 100644 --- a/homeassistant/components/picnic/sensor.py +++ b/homeassistant/components/picnic/sensor.py @@ -5,7 +5,6 @@ from typing import Any 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.typing import StateType from homeassistant.helpers.update_coordinator import ( @@ -41,8 +40,8 @@ async def async_setup_entry( class PicnicSensor(SensorEntity, CoordinatorEntity): """The CoordinatorEntity subclass representing Picnic sensors.""" + _attr_attribution = ATTRIBUTION entity_description: PicnicSensorEntityDescription - _attr_extra_state_attributes = {ATTR_ATTRIBUTION: ATTRIBUTION} def __init__( self, diff --git a/tests/components/picnic/test_sensor.py b/tests/components/picnic/test_sensor.py index 36aa06443dfe..2f8fb4cec53f 100644 --- a/tests/components/picnic/test_sensor.py +++ b/tests/components/picnic/test_sensor.py @@ -138,6 +138,8 @@ class TestPicnicSensor(unittest.IsolatedAsyncioTestCase): if unit: assert sensor.attributes["unit_of_measurement"] == unit + assert sensor.attributes["attribution"] == "Data provided by Picnic" + async def _setup_platform( self, use_default_responses=False, enable_all_sensors=True ):