Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust counter to not restore configuration parameters #93344

Merged
merged 1 commit into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions homeassistant/components/counter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,6 @@ async def async_added_to_hass(self) -> None:
and (state := await self.async_get_last_state()) is not None
):
self._state = self.compute_next_state(int(state.state))
self._config[CONF_INITIAL] = state.attributes.get(ATTR_INITIAL)
self._config[CONF_MAXIMUM] = state.attributes.get(ATTR_MAXIMUM)
self._config[CONF_MINIMUM] = state.attributes.get(ATTR_MINIMUM)
self._config[CONF_STEP] = state.attributes.get(ATTR_STEP)

@callback
def async_decrement(self) -> None:
Expand Down
11 changes: 0 additions & 11 deletions tests/components/counter/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,11 @@ async def test_initial_state_overrules_restore_state(hass: HomeAssistant) -> Non
async def test_restore_state_overrules_initial_state(hass: HomeAssistant) -> None:
"""Ensure states are restored on startup."""

attr = {"initial": 6, "minimum": 1, "maximum": 8, "step": 2}

mock_restore_cache(
hass,
(
State("counter.test1", "11"),
State("counter.test2", "-22"),
State("counter.test3", "5", attr),
),
)

Expand All @@ -332,14 +329,6 @@ async def test_restore_state_overrules_initial_state(hass: HomeAssistant) -> Non
assert state
assert int(state.state) == -22

state = hass.states.get("counter.test3")
assert state
assert int(state.state) == 5
assert state.attributes.get("initial") == 6
assert state.attributes.get("minimum") == 1
assert state.attributes.get("maximum") == 8
assert state.attributes.get("step") == 2


async def test_no_initial_state_and_no_restore_state(hass: HomeAssistant) -> None:
"""Ensure that entity is create without initial and restore feature."""
Expand Down