Adjust counter to not restore configuration parameters (#93344)
parent
f2899a19c1
commit
7537667e53
|
@ -245,10 +245,6 @@ class Counter(collection.CollectionEntity, RestoreEntity):
|
|||
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:
|
||||
|
|
|
@ -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),
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -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."""
|
||||
|
|
Loading…
Reference in New Issue