diff --git a/homeassistant/components/input_number/__init__.py b/homeassistant/components/input_number/__init__.py index d5fffeba3f9..affad6ca30f 100644 --- a/homeassistant/components/input_number/__init__.py +++ b/homeassistant/components/input_number/__init__.py @@ -196,6 +196,22 @@ class NumberStorageCollection(collection.StorageCollection): """Suggest an ID based on the config.""" return info[CONF_NAME] + async def _async_load_data(self) -> dict | None: + """Load the data. + + A past bug caused frontend to add initial value to all input numbers. + This drops that. + """ + data = await super()._async_load_data() + + if data is None: + return data + + for number in data["items"]: + number.pop(CONF_INITIAL, None) + + return data + async def _update_data(self, data: dict, update_data: dict) -> dict: """Return a new updated data object.""" update_data = self.UPDATE_SCHEMA(update_data) diff --git a/tests/components/input_number/test_init.py b/tests/components/input_number/test_init.py index 4149627720b..bec05d3f344 100644 --- a/tests/components/input_number/test_init.py +++ b/tests/components/input_number/test_init.py @@ -416,7 +416,7 @@ async def test_load_from_storage(hass, storage_setup): """Test set up from storage.""" assert await storage_setup() state = hass.states.get(f"{DOMAIN}.from_storage") - assert float(state.state) == 10 + assert float(state.state) == 0 # initial is not supported when loading from storage assert state.attributes.get(ATTR_FRIENDLY_NAME) == "from storage" assert state.attributes.get(ATTR_EDITABLE) @@ -438,7 +438,7 @@ async def test_editable_state_attribute(hass, storage_setup): ) state = hass.states.get(f"{DOMAIN}.from_storage") - assert float(state.state) == 10 + assert float(state.state) == 0 assert state.attributes.get(ATTR_FRIENDLY_NAME) == "from storage" assert state.attributes.get(ATTR_EDITABLE)