Fix async issue in ViCare integration (#104541)
* use async executor for get_circuits * use async executor for get_burners and get_compressorspull/104514/head^2
parent
14387cf94b
commit
ad17acc6ca
|
@ -159,16 +159,19 @@ async def async_setup_entry(
|
|||
if entity is not None:
|
||||
entities.append(entity)
|
||||
|
||||
circuits = await hass.async_add_executor_job(get_circuits, api)
|
||||
await _entities_from_descriptions(
|
||||
hass, entities, CIRCUIT_SENSORS, get_circuits(api), config_entry
|
||||
hass, entities, CIRCUIT_SENSORS, circuits, config_entry
|
||||
)
|
||||
|
||||
burners = await hass.async_add_executor_job(get_burners, api)
|
||||
await _entities_from_descriptions(
|
||||
hass, entities, BURNER_SENSORS, get_burners(api), config_entry
|
||||
hass, entities, BURNER_SENSORS, burners, config_entry
|
||||
)
|
||||
|
||||
compressors = await hass.async_add_executor_job(get_compressors, api)
|
||||
await _entities_from_descriptions(
|
||||
hass, entities, COMPRESSOR_SENSORS, get_compressors(api), config_entry
|
||||
hass, entities, COMPRESSOR_SENSORS, compressors, config_entry
|
||||
)
|
||||
|
||||
async_add_entities(entities)
|
||||
|
|
|
@ -103,7 +103,7 @@ async def async_setup_entry(
|
|||
entities = []
|
||||
api = hass.data[DOMAIN][config_entry.entry_id][VICARE_API]
|
||||
device_config = hass.data[DOMAIN][config_entry.entry_id][VICARE_DEVICE_CONFIG]
|
||||
circuits = get_circuits(api)
|
||||
circuits = await hass.async_add_executor_job(get_circuits, api)
|
||||
|
||||
for circuit in circuits:
|
||||
entity = ViCareClimate(
|
||||
|
@ -154,7 +154,7 @@ class ViCareClimate(ViCareEntity, ClimateEntity):
|
|||
self._current_program = None
|
||||
self._attr_translation_key = translation_key
|
||||
|
||||
def update(self) -> None:
|
||||
async def async_update(self) -> None:
|
||||
"""Let HA know there has been an update from the ViCare API."""
|
||||
try:
|
||||
_room_temperature = None
|
||||
|
@ -205,11 +205,15 @@ class ViCareClimate(ViCareEntity, ClimateEntity):
|
|||
self._current_action = False
|
||||
# Update the specific device attributes
|
||||
with suppress(PyViCareNotSupportedFeatureError):
|
||||
for burner in get_burners(self._api):
|
||||
burners = await self.hass.async_add_executor_job(get_burners, self._api)
|
||||
for burner in burners:
|
||||
self._current_action = self._current_action or burner.getActive()
|
||||
|
||||
with suppress(PyViCareNotSupportedFeatureError):
|
||||
for compressor in get_compressors(self._api):
|
||||
compressors = await self.hass.async_add_executor_job(
|
||||
get_compressors, self._api
|
||||
)
|
||||
for compressor in compressors:
|
||||
self._current_action = (
|
||||
self._current_action or compressor.getActive()
|
||||
)
|
||||
|
|
|
@ -28,7 +28,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||
from . import ViCareRequiredKeysMixin
|
||||
from .const import DOMAIN, VICARE_API, VICARE_DEVICE_CONFIG
|
||||
from .entity import ViCareEntity
|
||||
from .utils import is_supported
|
||||
from .utils import get_circuits, is_supported
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -93,10 +93,11 @@ async def async_setup_entry(
|
|||
) -> None:
|
||||
"""Create the ViCare number devices."""
|
||||
api = hass.data[DOMAIN][config_entry.entry_id][VICARE_API]
|
||||
circuits = await hass.async_add_executor_job(get_circuits, api)
|
||||
|
||||
entities: list[ViCareNumber] = []
|
||||
try:
|
||||
for circuit in api.circuits:
|
||||
for circuit in circuits:
|
||||
for description in CIRCUIT_ENTITY_DESCRIPTIONS:
|
||||
entity = await hass.async_add_executor_job(
|
||||
_build_entity,
|
||||
|
|
|
@ -650,16 +650,19 @@ async def async_setup_entry(
|
|||
if entity is not None:
|
||||
entities.append(entity)
|
||||
|
||||
circuits = await hass.async_add_executor_job(get_circuits, api)
|
||||
await _entities_from_descriptions(
|
||||
hass, entities, CIRCUIT_SENSORS, get_circuits(api), config_entry
|
||||
hass, entities, CIRCUIT_SENSORS, circuits, config_entry
|
||||
)
|
||||
|
||||
burners = await hass.async_add_executor_job(get_burners, api)
|
||||
await _entities_from_descriptions(
|
||||
hass, entities, BURNER_SENSORS, get_burners(api), config_entry
|
||||
hass, entities, BURNER_SENSORS, burners, config_entry
|
||||
)
|
||||
|
||||
compressors = await hass.async_add_executor_job(get_compressors, api)
|
||||
await _entities_from_descriptions(
|
||||
hass, entities, COMPRESSOR_SENSORS, get_compressors(api), config_entry
|
||||
hass, entities, COMPRESSOR_SENSORS, compressors, config_entry
|
||||
)
|
||||
|
||||
async_add_entities(entities)
|
||||
|
|
|
@ -67,7 +67,7 @@ async def async_setup_entry(
|
|||
entities = []
|
||||
api = hass.data[DOMAIN][config_entry.entry_id][VICARE_API]
|
||||
device_config = hass.data[DOMAIN][config_entry.entry_id][VICARE_DEVICE_CONFIG]
|
||||
circuits = get_circuits(api)
|
||||
circuits = await hass.async_add_executor_job(get_circuits, api)
|
||||
|
||||
for circuit in circuits:
|
||||
entity = ViCareWater(
|
||||
|
|
Loading…
Reference in New Issue