mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 04:37:06 +00:00
Update link when IO in event loop (#31519)
This commit is contained in:
parent
8d429d7676
commit
a3b3924e21
@ -365,13 +365,17 @@ class Entity(ABC):
|
|||||||
|
|
||||||
if end - start > 0.4 and not self._slow_reported:
|
if end - start > 0.4 and not self._slow_reported:
|
||||||
self._slow_reported = True
|
self._slow_reported = True
|
||||||
|
url = "https://github.com/home-assistant/home-assistant/issues?q=is%3Aopen+is%3Aissue"
|
||||||
|
if self.platform:
|
||||||
|
url += f"+label%3A%22integration%3A+{self.platform.platform_name}%22"
|
||||||
|
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"Updating state for %s (%s) took %.3f seconds. "
|
"Updating state for %s (%s) took %.3f seconds. "
|
||||||
"Please report platform to the developers at "
|
"Please create a bug report at %s",
|
||||||
"https://goo.gl/Nvioub",
|
|
||||||
self.entity_id,
|
self.entity_id,
|
||||||
type(self),
|
type(self),
|
||||||
end - start,
|
end - start,
|
||||||
|
url,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Overwrite properties that have been set in the config file.
|
# Overwrite properties that have been set in the config file.
|
||||||
|
@ -661,3 +661,22 @@ async def test_capability_attrs(hass):
|
|||||||
assert state is not None
|
assert state is not None
|
||||||
assert state.state == STATE_UNAVAILABLE
|
assert state.state == STATE_UNAVAILABLE
|
||||||
assert state.attributes["always"] == "there"
|
assert state.attributes["always"] == "there"
|
||||||
|
|
||||||
|
|
||||||
|
async def test_warn_slow_write_state(hass, caplog):
|
||||||
|
"""Check that we log a warning if reading properties takes too long."""
|
||||||
|
mock_entity = entity.Entity()
|
||||||
|
mock_entity.hass = hass
|
||||||
|
mock_entity.entity_id = "comp_test.test_entity"
|
||||||
|
mock_entity.platform = MagicMock(platform_name="hue")
|
||||||
|
|
||||||
|
with patch("homeassistant.helpers.entity.timer", side_effect=[0, 10]):
|
||||||
|
mock_entity.async_write_ha_state()
|
||||||
|
|
||||||
|
assert (
|
||||||
|
"Updating state for comp_test.test_entity "
|
||||||
|
"(<class 'homeassistant.helpers.entity.Entity'>) "
|
||||||
|
"took 10.000 seconds. Please create a bug report at "
|
||||||
|
"https://github.com/home-assistant/home-assistant/issues?"
|
||||||
|
"q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+hue%22"
|
||||||
|
) in caplog.text
|
||||||
|
Loading…
x
Reference in New Issue
Block a user