Skip to content

Commit

Permalink
better to set PARALLEL_UPDATES = 1
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored and stephan48 committed Feb 22, 2025
1 parent fcf291d commit a7e15d3
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions homeassistant/components/thermopro/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from __future__ import annotations

import asyncio
from collections.abc import Callable, Coroutine
from dataclasses import dataclass
from typing import Any
Expand All @@ -18,7 +17,6 @@
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import EntityCategory
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.dispatcher import (
async_dispatcher_connect,
Expand All @@ -29,6 +27,8 @@

from .const import DOMAIN, SIGNAL_AVAILABILITY_UPDATED, SIGNAL_DATA_UPDATED

PARALLEL_UPDATES = 1 # one connection at a time


@dataclass(kw_only=True, frozen=True)
class ThermoProButtonEntityDescription(ButtonEntityDescription):
Expand Down Expand Up @@ -126,7 +126,6 @@ def __init__(
identifiers={(DOMAIN, address)},
connections={(dr.CONNECTION_BLUETOOTH, address)},
)
self._action_lock = asyncio.Lock()

async def async_added_to_hass(self) -> None:
"""Connect availability dispatcher."""
Expand Down Expand Up @@ -155,8 +154,4 @@ def _async_on_availability_changed(self, available: bool) -> None:

async def async_press(self) -> None:
"""Execute the press action for the entity."""
if self._action_lock.locked():
raise HomeAssistantError(f"Connecting to {self.name} already in progress")
async with self._action_lock:
# Only one connection at a time
await self.entity_description.press_action_fn(self.hass, self._address)
await self.entity_description.press_action_fn(self.hass, self._address)

0 comments on commit a7e15d3

Please sign in to comment.