mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Adjust counter to not restore configuration parameters (#93344)
This commit is contained in:
parent
f2899a19c1
commit
7537667e53
@ -245,10 +245,6 @@ class Counter(collection.CollectionEntity, RestoreEntity):
|
|||||||
and (state := await self.async_get_last_state()) is not None
|
and (state := await self.async_get_last_state()) is not None
|
||||||
):
|
):
|
||||||
self._state = self.compute_next_state(int(state.state))
|
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
|
@callback
|
||||||
def async_decrement(self) -> None:
|
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:
|
async def test_restore_state_overrules_initial_state(hass: HomeAssistant) -> None:
|
||||||
"""Ensure states are restored on startup."""
|
"""Ensure states are restored on startup."""
|
||||||
|
|
||||||
attr = {"initial": 6, "minimum": 1, "maximum": 8, "step": 2}
|
|
||||||
|
|
||||||
mock_restore_cache(
|
mock_restore_cache(
|
||||||
hass,
|
hass,
|
||||||
(
|
(
|
||||||
State("counter.test1", "11"),
|
State("counter.test1", "11"),
|
||||||
State("counter.test2", "-22"),
|
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 state
|
||||||
assert int(state.state) == -22
|
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:
|
async def test_no_initial_state_and_no_restore_state(hass: HomeAssistant) -> None:
|
||||||
"""Ensure that entity is create without initial and restore feature."""
|
"""Ensure that entity is create without initial and restore feature."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user