mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Add RSS description to Feedreader event (#126681)
This commit is contained in:
parent
2d16732972
commit
b3b5d9602a
@ -19,6 +19,7 @@ from .coordinator import FeedReaderCoordinator
|
|||||||
LOGGER = logging.getLogger(__name__)
|
LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
ATTR_CONTENT = "content"
|
ATTR_CONTENT = "content"
|
||||||
|
ATTR_DESCRIPTION = "description"
|
||||||
ATTR_LINK = "link"
|
ATTR_LINK = "link"
|
||||||
ATTR_TITLE = "title"
|
ATTR_TITLE = "title"
|
||||||
|
|
||||||
@ -40,7 +41,9 @@ class FeedReaderEvent(CoordinatorEntity[FeedReaderCoordinator], EventEntity):
|
|||||||
_attr_event_types = [EVENT_FEEDREADER]
|
_attr_event_types = [EVENT_FEEDREADER]
|
||||||
_attr_name = None
|
_attr_name = None
|
||||||
_attr_has_entity_name = True
|
_attr_has_entity_name = True
|
||||||
_unrecorded_attributes = frozenset({ATTR_CONTENT, ATTR_TITLE, ATTR_LINK})
|
_unrecorded_attributes = frozenset(
|
||||||
|
{ATTR_CONTENT, ATTR_DESCRIPTION, ATTR_TITLE, ATTR_LINK}
|
||||||
|
)
|
||||||
coordinator: FeedReaderCoordinator
|
coordinator: FeedReaderCoordinator
|
||||||
|
|
||||||
def __init__(self, coordinator: FeedReaderCoordinator) -> None:
|
def __init__(self, coordinator: FeedReaderCoordinator) -> None:
|
||||||
@ -80,6 +83,7 @@ class FeedReaderEvent(CoordinatorEntity[FeedReaderCoordinator], EventEntity):
|
|||||||
self._trigger_event(
|
self._trigger_event(
|
||||||
EVENT_FEEDREADER,
|
EVENT_FEEDREADER,
|
||||||
{
|
{
|
||||||
|
ATTR_DESCRIPTION: feed_data.get("description"),
|
||||||
ATTR_TITLE: feed_data.get("title"),
|
ATTR_TITLE: feed_data.get("title"),
|
||||||
ATTR_LINK: feed_data.get("link"),
|
ATTR_LINK: feed_data.get("link"),
|
||||||
ATTR_CONTENT: content,
|
ATTR_CONTENT: content,
|
||||||
|
@ -5,6 +5,7 @@ from unittest.mock import patch
|
|||||||
|
|
||||||
from homeassistant.components.feedreader.event import (
|
from homeassistant.components.feedreader.event import (
|
||||||
ATTR_CONTENT,
|
ATTR_CONTENT,
|
||||||
|
ATTR_DESCRIPTION,
|
||||||
ATTR_LINK,
|
ATTR_LINK,
|
||||||
ATTR_TITLE,
|
ATTR_TITLE,
|
||||||
)
|
)
|
||||||
@ -35,6 +36,7 @@ async def test_event_entity(
|
|||||||
assert state.attributes[ATTR_TITLE] == "Title 1"
|
assert state.attributes[ATTR_TITLE] == "Title 1"
|
||||||
assert state.attributes[ATTR_LINK] == "http://www.example.com/link/1"
|
assert state.attributes[ATTR_LINK] == "http://www.example.com/link/1"
|
||||||
assert state.attributes[ATTR_CONTENT] == "Content 1"
|
assert state.attributes[ATTR_CONTENT] == "Content 1"
|
||||||
|
assert state.attributes[ATTR_DESCRIPTION] == "Description 1"
|
||||||
|
|
||||||
future = dt_util.utcnow() + timedelta(hours=1, seconds=1)
|
future = dt_util.utcnow() + timedelta(hours=1, seconds=1)
|
||||||
async_fire_time_changed(hass, future)
|
async_fire_time_changed(hass, future)
|
||||||
@ -45,6 +47,7 @@ async def test_event_entity(
|
|||||||
assert state.attributes[ATTR_TITLE] == "Title 2"
|
assert state.attributes[ATTR_TITLE] == "Title 2"
|
||||||
assert state.attributes[ATTR_LINK] == "http://www.example.com/link/2"
|
assert state.attributes[ATTR_LINK] == "http://www.example.com/link/2"
|
||||||
assert state.attributes[ATTR_CONTENT] == "Content 2"
|
assert state.attributes[ATTR_CONTENT] == "Content 2"
|
||||||
|
assert state.attributes[ATTR_DESCRIPTION] == "Description 2"
|
||||||
|
|
||||||
future = dt_util.utcnow() + timedelta(hours=2, seconds=2)
|
future = dt_util.utcnow() + timedelta(hours=2, seconds=2)
|
||||||
async_fire_time_changed(hass, future)
|
async_fire_time_changed(hass, future)
|
||||||
@ -55,3 +58,4 @@ async def test_event_entity(
|
|||||||
assert state.attributes[ATTR_TITLE] == "Title 1"
|
assert state.attributes[ATTR_TITLE] == "Title 1"
|
||||||
assert state.attributes[ATTR_LINK] == "http://www.example.com/link/1"
|
assert state.attributes[ATTR_LINK] == "http://www.example.com/link/1"
|
||||||
assert state.attributes[ATTR_CONTENT] == "This is a summary"
|
assert state.attributes[ATTR_CONTENT] == "This is a summary"
|
||||||
|
assert state.attributes[ATTR_DESCRIPTION] == "Description 1"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user