mirror of
https://github.com/home-assistant/core.git
synced 2026-05-30 04:05:01 +01:00
d766aae436
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: frenck <195327+frenck@users.noreply.github.com>
37 lines
833 B
Python
37 lines
833 B
Python
"""The zcc integration helpers."""
|
|
|
|
import logging
|
|
|
|
from zcc import ControlPoint, ControlPointDescription
|
|
|
|
from homeassistant.exceptions import ConfigEntryNotReady
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
async def async_connect_to_controller(
|
|
host: str, port: int, fast: bool = False
|
|
) -> ControlPoint:
|
|
"""Connect to Zimi Cloud Controller with defined parameters."""
|
|
|
|
_LOGGER.debug("Connecting to %s:%d", host, port)
|
|
|
|
api = ControlPoint(
|
|
description=ControlPointDescription(
|
|
host=host,
|
|
port=port,
|
|
)
|
|
)
|
|
await api.connect(fast=fast)
|
|
|
|
if api.ready:
|
|
_LOGGER.debug("Connected")
|
|
|
|
if not fast:
|
|
api.start_watchdog()
|
|
_LOGGER.debug("Started watchdog")
|
|
|
|
return api
|
|
|
|
raise ConfigEntryNotReady("Connection failed: not ready")
|