mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
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 import Entity
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.json import JSONEncoder, _orjson_default_encoder, json_dumps
|
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.setup import setup_component
|
||||||
from homeassistant.util.async_ import run_callback_threadsafe
|
from homeassistant.util.async_ import run_callback_threadsafe
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
@ -1291,11 +1291,6 @@ class MockEntity(entity.Entity):
|
|||||||
"""Return the ste of the polling."""
|
"""Return the ste of the polling."""
|
||||||
return self._handle("should_poll")
|
return self._handle("should_poll")
|
||||||
|
|
||||||
@property
|
|
||||||
def state(self) -> StateType:
|
|
||||||
"""Return the state of the entity."""
|
|
||||||
return self._handle("state")
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int | None:
|
def supported_features(self) -> int | None:
|
||||||
"""Info about supported features."""
|
"""Info about supported features."""
|
||||||
|
@ -1432,9 +1432,9 @@ async def test_override_restored_entities(
|
|||||||
component = EntityComponent(_LOGGER, DOMAIN, hass)
|
component = EntityComponent(_LOGGER, DOMAIN, hass)
|
||||||
await component.async_setup({})
|
await component.async_setup({})
|
||||||
|
|
||||||
await component.async_add_entities(
|
ent = MockEntity(unique_id="1234", entity_id="test_domain.world")
|
||||||
[MockEntity(unique_id="1234", state="on", entity_id="test_domain.world")], True
|
ent._attr_state = "on"
|
||||||
)
|
await component.async_add_entities([ent], True)
|
||||||
|
|
||||||
state = hass.states.get("test_domain.world")
|
state = hass.states.get("test_domain.world")
|
||||||
assert state.state == "on"
|
assert state.state == "on"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user