custom_components/omni_pca/const.py:
+ CONF_TRANSPORT, TRANSPORT_TCP, TRANSPORT_UDP, DEFAULT_TRANSPORT='tcp'
custom_components/omni_pca/config_flow.py:
+ 'transport' field in _USER_SCHEMA with vol.In([tcp, udp]),
default tcp (so existing flows are unchanged)
+ transport stored in entry.data on create
+ reauth carries the existing transport over from entry.data
+ _probe() takes transport=, propagates to OmniClient
custom_components/omni_pca/coordinator.py:
+ transport= constructor arg, defaults to 'tcp'
+ _ensure_connected passes transport= through to OmniClient
custom_components/omni_pca/__init__.py:
+ reads transport from entry.data (default tcp), passes to coordinator
Backward-compat: existing config entries without a transport key fall
through to 'tcp', identical to current behavior. New entries get the
choice at the config-flow form. The reauth step preserves the existing
transport so users don't have to re-pick it.
357 tests pass; ruff clean across src/ tests/ custom_components/.
HA integration tests don't need updating because they don't pass
transport= explicitly (default tcp matches the mock's default).
41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
"""Constants for the HAI/Leviton Omni Panel integration."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
from datetime import timedelta
|
|
from typing import Final
|
|
|
|
DOMAIN: Final = "omni_pca"
|
|
|
|
DEFAULT_PORT: Final = 4369
|
|
DEFAULT_TIMEOUT: Final = 5.0
|
|
|
|
CONF_CONTROLLER_KEY: Final = "controller_key"
|
|
CONF_TRANSPORT: Final = "transport"
|
|
|
|
TRANSPORT_TCP: Final = "tcp"
|
|
TRANSPORT_UDP: Final = "udp"
|
|
DEFAULT_TRANSPORT: Final = TRANSPORT_TCP
|
|
|
|
MANUFACTURER: Final = "HAI / Leviton"
|
|
|
|
# Polling interval. Most state arrives via unsolicited push messages, so
|
|
# this is just a safety net that keeps `last_update_success` honest if the
|
|
# panel goes quiet.
|
|
SCAN_INTERVAL: Final = timedelta(seconds=30)
|
|
|
|
# Background event-listener task name, surfaced to ``asyncio.all_tasks()``
|
|
# for diagnostics.
|
|
EVENT_TASK_NAME: Final = "omni_pca-event-listener"
|
|
|
|
# Upper bound for the discovery walk. The protocol caps object indices at
|
|
# uint16, but Omni panels never approach that — most installs have <100
|
|
# zones / units / areas, so we stop early when discovery returns EOD.
|
|
MAX_OBJECT_INDEX: Final = 0xFFFF
|
|
|
|
# Length, in characters, of a hex-encoded 16-byte controller key.
|
|
CONTROLLER_KEY_HEX_LEN: Final = 32
|
|
|
|
LOGGER: Final = logging.getLogger(__package__)
|