From 6ce3274f1594f873dffc90f395d2c3b9f5c7a363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Gajdu=C5=A1ek?= Date: Tue, 21 Nov 2023 22:35:18 +0100 Subject: [PATCH] Force update the entity --- custom_components/feedparser/sensor.py | 6 +++++- pyproject.toml | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/custom_components/feedparser/sensor.py b/custom_components/feedparser/sensor.py index b4259b2..9d20304 100644 --- a/custom_components/feedparser/sensor.py +++ b/custom_components/feedparser/sensor.py @@ -82,6 +82,10 @@ async def async_setup_platform( class FeedParserSensor(SensorEntity): """Representation of a Feedparser sensor.""" + # force update the entity since the number of feed entries does not necessarily + # change, but we still want to update the extra_state_attributes + _attr_force_update = True + def __init__( self: FeedParserSensor, feed: str, @@ -105,7 +109,7 @@ def __init__( self._local_time = local_time self._entries: list[dict[str, str]] = [] self._attr_extra_state_attributes = {"entries": self._entries} - _attr_attribution = "Data retrieved using RSS feedparser" + self._attr_attribution = "Data retrieved using RSS feedparser" _LOGGER.debug("Feed %s: FeedParserSensor initialized - %s", self.name, self) def __repr__(self: FeedParserSensor) -> str: diff --git a/pyproject.toml b/pyproject.toml index bac2809..23ada42 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ dependencies = ["python-dateutil", "feedparser==6.0.10", "homeassistant"] dev = [ "black", "homeassistant-stubs", - "pytest==7.4.0", + "pytest==7.4.3", "mypy", "ruff", "types-python-dateutil",