1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-25 05:26:47 +00:00

Add system option to disable polling (#51299)

This commit is contained in:
Paulus Schoutsen
2021-05-31 15:36:40 -07:00
committed by GitHub
parent 5d6b6deed4
commit 4821484d2c
7 changed files with 123 additions and 54 deletions

View File

@@ -214,6 +214,7 @@ class EntityPlatform:
@callback
def async_create_setup_task() -> Coroutine:
"""Get task to set up platform."""
config_entries.current_entry.set(config_entry)
return platform.async_setup_entry( # type: ignore[no-any-return,union-attr]
self.hass, config_entry, self._async_schedule_add_entities
)
@@ -395,8 +396,10 @@ class EntityPlatform:
)
raise
if self._async_unsub_polling is not None or not any(
entity.should_poll for entity in self.entities.values()
if (
(self.config_entry and self.config_entry.system_options.disable_polling)
or self._async_unsub_polling is not None
or not any(entity.should_poll for entity in self.entities.values())
):
return