Do not override state property in `MockEntity` (#114231)
Do not override state in `MockEntity`
This commit is contained in:
parent
44eeb2eb5e
commit
5c97049f2e
|
@ -83,7 +83,7 @@ from homeassistant.helpers.dispatcher import (
|
|||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.json import JSONEncoder, _orjson_default_encoder, json_dumps
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, StateType
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.util.async_ import run_callback_threadsafe
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
@ -1291,11 +1291,6 @@ class MockEntity(entity.Entity):
|
|||
"""Return the ste of the polling."""
|
||||
return self._handle("should_poll")
|
||||
|
||||
@property
|
||||
def state(self) -> StateType:
|
||||
"""Return the state of the entity."""
|
||||
return self._handle("state")
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int | None:
|
||||
"""Info about supported features."""
|
||||
|
|
|
@ -1432,9 +1432,9 @@ async def test_override_restored_entities(
|
|||
component = EntityComponent(_LOGGER, DOMAIN, hass)
|
||||
await component.async_setup({})
|
||||
|
||||
await component.async_add_entities(
|
||||
[MockEntity(unique_id="1234", state="on", entity_id="test_domain.world")], True
|
||||
)
|
||||
ent = MockEntity(unique_id="1234", entity_id="test_domain.world")
|
||||
ent._attr_state = "on"
|
||||
await component.async_add_entities([ent], True)
|
||||
|
||||
state = hass.states.get("test_domain.world")
|
||||
assert state.state == "on"
|
||||
|
|
Loading…
Reference in New Issue