ha(H5): обёртка ошибок ESPHome-канала, README/RELEASE/ru-ниты

- ESPHome connect/command/импорт оборачиваются в AcceptanceError; при сбое
  connect канал закрывается (loop закрыт), CLI даёт rc 2 без traceback
- self-test: connect error, command error, отсутствие aioesphomeapi через
  main (rc 2) — всего 15 acceptance-тестов
- RELEASE_HA: repaired-wheel в dist/manylinux + удаление linux-тега перед
  upload; README компонента — корректная ссылка на docs/RELEASE_HA.md
- translations/ru: options data «LAN-ключ»; план §2/§6 синхронизирован
This commit is contained in:
2026-09-29 15:04:20 +03:00
parent a03458f9bc
commit 1fc845d7f5
6 changed files with 132 additions and 16 deletions
+36 -9
View File
@@ -130,10 +130,25 @@ class EsphomeChannel:
self._loop.run_until_complete(self._connect())
async def _connect(self) -> None:
import aioesphomeapi # noqa: PLC0415
try:
import aioesphomeapi # noqa: PLC0415
except ImportError as err:
raise AcceptanceError(
"ESPHome-канал: пакет aioesphomeapi не установлен"
) from err
self._aio = aioesphomeapi
self._client = aioesphomeapi.APIClient(
try:
await self._connect_inner()
except AcceptanceError:
raise
except Exception as err: # noqa: BLE001
raise AcceptanceError(
f"ESPHome {self.host}: подключение/список сущностей: {err}"
) from err
async def _connect_inner(self) -> None:
self._client = self._aio.APIClient(
self.host, 6053, noise_psk=self.key or None
)
await asyncio.wait_for(
@@ -165,12 +180,15 @@ class EsphomeChannel:
mode = getattr(self._aio.ClimateMode, str(step.expected).upper())
else:
target = float(step.expected)
await asyncio.wait_for(
self._client.climate_command(
key=self._entity_key, mode=mode, target_temperature=target
),
timeout=self.timeout,
)
try:
await asyncio.wait_for(
self._client.climate_command(
key=self._entity_key, mode=mode, target_temperature=target
),
timeout=self.timeout,
)
except Exception as err: # noqa: BLE001
raise AcceptanceError(f"ESPHome: команда не отправлена: {err}") from err
def close(self) -> None:
try:
@@ -469,7 +487,16 @@ def _make_esphome(args: argparse.Namespace) -> Optional[EsphomeChannel]:
if not args.esphome_host:
return None
channel = EsphomeChannel(args.esphome_host, args.esphome_key, args.timeout)
channel.connect()
try:
channel.connect()
except AcceptanceError:
channel.close()
raise
except Exception as err: # noqa: BLE001
channel.close()
raise AcceptanceError(
f"ESPHome {args.esphome_host}: подключение не удалось: {err}"
) from err
return channel