Fix schedule entity can't delete icon (#150995)

This commit is contained in:
karwosts
2025-08-25 01:56:33 -07:00
committed by GitHub
parent 962b276a77
commit 1f25641e3b
2 changed files with 23 additions and 7 deletions

View File

@@ -242,7 +242,7 @@ class ScheduleStorageCollection(DictStorageCollection):
async def _update_data(self, item: dict, update_data: dict) -> dict:
"""Return a new updated data object."""
self.SCHEMA(update_data)
return item | update_data
return {CONF_ID: item[CONF_ID]} | update_data
async def _async_load_data(self) -> SerializedStorageCollection | None:
"""Load the data."""

View File

@@ -617,11 +617,26 @@ async def test_ws_delete(
@pytest.mark.freeze_time("2022-08-10 20:10:00-07:00")
@pytest.mark.parametrize(
("to", "next_event", "saved_to"),
("to", "next_event", "saved_to", "icon_dict"),
[
("23:59:59", "2022-08-10T23:59:59-07:00", "23:59:59"),
("24:00", "2022-08-11T00:00:00-07:00", "24:00:00"),
("24:00:00", "2022-08-11T00:00:00-07:00", "24:00:00"),
(
"23:59:59",
"2022-08-10T23:59:59-07:00",
"23:59:59",
{CONF_ICON: "mdi:party-pooper"},
),
(
"24:00",
"2022-08-11T00:00:00-07:00",
"24:00:00",
{CONF_ICON: "mdi:party-popper"},
),
(
"24:00:00",
"2022-08-11T00:00:00-07:00",
"24:00:00",
{},
),
],
)
async def test_update(
@@ -632,6 +647,7 @@ async def test_update(
to: str,
next_event: str,
saved_to: str,
icon_dict: dict,
) -> None:
"""Test updating the schedule."""
assert await schedule_setup()
@@ -654,7 +670,7 @@ async def test_update(
"type": f"{DOMAIN}/update",
f"{DOMAIN}_id": "from_storage",
CONF_NAME: "Party pooper",
CONF_ICON: "mdi:party-pooper",
**icon_dict,
CONF_MONDAY: [],
CONF_TUESDAY: [],
CONF_WEDNESDAY: [{CONF_FROM: "17:00:00", CONF_TO: to}],
@@ -671,7 +687,7 @@ async def test_update(
assert state
assert state.state == STATE_ON
assert state.attributes[ATTR_FRIENDLY_NAME] == "Party pooper"
assert state.attributes[ATTR_ICON] == "mdi:party-pooper"
assert state.attributes.get(ATTR_ICON) == icon_dict.get(CONF_ICON)
assert state.attributes[ATTR_NEXT_EVENT].isoformat() == next_event
await client.send_json({"id": 2, "type": f"{DOMAIN}/list"})