diff --git a/homeassistant/components/schedule/__init__.py b/homeassistant/components/schedule/__init__.py index ea569f4e277..63de3daaf15 100644 --- a/homeassistant/components/schedule/__init__.py +++ b/homeassistant/components/schedule/__init__.py @@ -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.""" diff --git a/tests/components/schedule/test_init.py b/tests/components/schedule/test_init.py index 6fd6314c6bb..9a9ccc0c47a 100644 --- a/tests/components/schedule/test_init.py +++ b/tests/components/schedule/test_init.py @@ -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"})