diff --git a/homeassistant/components/amberelectric/binary_sensor.py b/homeassistant/components/amberelectric/binary_sensor.py index fe6edea18f8..422ff66db59 100644 --- a/homeassistant/components/amberelectric/binary_sensor.py +++ b/homeassistant/components/amberelectric/binary_sensor.py @@ -61,7 +61,7 @@ class AmberPriceSpikeBinarySensor(AmberPriceGridSensor): return self.coordinator.data["grid"]["price_spike"] == "spike" @property - def device_state_attributes(self) -> Mapping[str, Any] | None: + def extra_state_attributes(self) -> Mapping[str, Any] | None: """Return additional pieces of information about the price spike.""" spike_status = self.coordinator.data["grid"]["price_spike"] diff --git a/homeassistant/components/amberelectric/sensor.py b/homeassistant/components/amberelectric/sensor.py index a1644fb7924..7cee95dcfcf 100644 --- a/homeassistant/components/amberelectric/sensor.py +++ b/homeassistant/components/amberelectric/sensor.py @@ -86,7 +86,7 @@ class AmberPriceSensor(AmberSensor): return format_cents_to_dollars(interval.per_kwh) @property - def device_state_attributes(self) -> Mapping[str, Any] | None: + def extra_state_attributes(self) -> Mapping[str, Any] | None: """Return additional pieces of information about the price.""" interval = self.coordinator.data[self.entity_description.key][self.channel_type] @@ -133,7 +133,7 @@ class AmberForecastSensor(AmberSensor): return format_cents_to_dollars(interval.per_kwh) @property - def device_state_attributes(self) -> Mapping[str, Any] | None: + def extra_state_attributes(self) -> Mapping[str, Any] | None: """Return additional pieces of information about the price.""" intervals = self.coordinator.data[self.entity_description.key].get( self.channel_type diff --git a/homeassistant/helpers/entity.py b/homeassistant/helpers/entity.py index 9ee7221ffa6..650ce0701a6 100644 --- a/homeassistant/helpers/entity.py +++ b/homeassistant/helpers/entity.py @@ -515,7 +515,15 @@ class Entity(ABC): attr.update(self.state_attributes or {}) extra_state_attributes = self.extra_state_attributes # Backwards compatibility for "device_state_attributes" deprecated in 2021.4 - # Add warning in 2021.6, remove in 2021.10 + # Warning added in 2021.12, will be removed in 2022.4 + if self.device_state_attributes is not None: + report_issue = self._suggest_report_issue() + _LOGGER.warning( + "Entity %s (%s) implements device_state_attributes. Please %s", + self.entity_id, + type(self), + report_issue, + ) if extra_state_attributes is None: extra_state_attributes = self.device_state_attributes attr.update(extra_state_attributes or {}) diff --git a/tests/components/amberelectric/test_sensor.py b/tests/components/amberelectric/test_sensor.py index ccfcd82b3bd..deafcb70fb7 100644 --- a/tests/components/amberelectric/test_sensor.py +++ b/tests/components/amberelectric/test_sensor.py @@ -164,7 +164,6 @@ async def test_general_and_feed_in_price_sensor( ) -> None: """Test the Feed In sensor.""" assert len(hass.states.async_all()) == 6 - print(hass.states) price = hass.states.get("sensor.mock_title_feed_in_price") assert price assert price.state == "-0.08"