mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 05:37:44 +00:00
Fix plant doing IO in the event loop. (#41527)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
parent
d3734aae9d
commit
f268378f0f
@ -282,7 +282,8 @@ class Plant(Entity):
|
||||
"""After being added to hass, load from history."""
|
||||
if ENABLE_LOAD_HISTORY and "recorder" in self.hass.config.components:
|
||||
# only use the database if it's configured
|
||||
self.hass.async_add_job(self._load_history_from_db)
|
||||
await self.hass.async_add_executor_job(self._load_history_from_db)
|
||||
self.async_write_ha_state()
|
||||
|
||||
async_track_state_change_event(
|
||||
self.hass, list(self._sensormap), self._state_changed_event
|
||||
@ -293,7 +294,7 @@ class Plant(Entity):
|
||||
if state is not None:
|
||||
self.state_changed(entity_id, state)
|
||||
|
||||
async def _load_history_from_db(self):
|
||||
def _load_history_from_db(self):
|
||||
"""Load the history of the brightness values from the database.
|
||||
|
||||
This only needs to be done once during startup.
|
||||
@ -330,7 +331,6 @@ class Plant(Entity):
|
||||
except ValueError:
|
||||
pass
|
||||
_LOGGER.debug("Initializing from database completed")
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user