mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Avoid unnecessary executor calls in onewire (#135187)
This commit is contained in:
parent
050a17db4d
commit
8705fd8546
@ -98,10 +98,7 @@ async def async_setup_entry(
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up 1-Wire platform."""
|
||||
entities = await hass.async_add_executor_job(
|
||||
get_entities, config_entry.runtime_data
|
||||
)
|
||||
async_add_entities(entities, True)
|
||||
async_add_entities(get_entities(config_entry.runtime_data), True)
|
||||
|
||||
|
||||
def get_entities(onewire_hub: OneWireHub) -> list[OneWireBinarySensor]:
|
||||
|
@ -45,10 +45,7 @@ async def async_setup_entry(
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up 1-Wire platform."""
|
||||
entities = await hass.async_add_executor_job(
|
||||
get_entities, config_entry.runtime_data
|
||||
)
|
||||
async_add_entities(entities, True)
|
||||
async_add_entities(get_entities(config_entry.runtime_data), True)
|
||||
|
||||
|
||||
def get_entities(onewire_hub: OneWireHub) -> list[OneWireSelectEntity]:
|
||||
|
@ -357,6 +357,8 @@ async def async_setup_entry(
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up 1-Wire platform."""
|
||||
# note: we have to go through the executor as SENSOR platform
|
||||
# makes extra calls to the hub during device listing
|
||||
entities = await hass.async_add_executor_job(
|
||||
get_entities, config_entry.runtime_data, config_entry.options
|
||||
)
|
||||
|
@ -158,10 +158,7 @@ async def async_setup_entry(
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up 1-Wire platform."""
|
||||
entities = await hass.async_add_executor_job(
|
||||
get_entities, config_entry.runtime_data
|
||||
)
|
||||
async_add_entities(entities, True)
|
||||
async_add_entities(get_entities(config_entry.runtime_data), True)
|
||||
|
||||
|
||||
def get_entities(onewire_hub: OneWireHub) -> list[OneWireSwitch]:
|
||||
|
Loading…
x
Reference in New Issue
Block a user