The GitHub mirror is gone, so the HACS packaging and the GitHub-only CI no longer have anything to run against. Remove hacs.json and the .github/ workflow. Both of its jobs (hassfest and hacs/action) were gated on `github.server_url == 'https://github.com'` and are GitHub-hosted actions, so neither can run on the Gitea runner. Replace them with .gitea/workflows/ci.yml: - lint: ruff check + ruff format --check, version pinned because ruff's default rule set and formatter output move between releases - validate: byte-compile, then scripts/validate_integration.py, which covers the part of hassfest that matters for a manually installed custom component (manifest keys, domain/directory agreement, and translations matching strings.json key for key) README now documents manual installation only, and points at the local CI commands. manifest.json documentation and issue_tracker point at the Gitea repo; NOTICE keeps its upstream attribution. Adopting ruff surfaced two real defects, fixed here: - climate.async_set_hvac_mode raised HomeAssistantError for an unsupported mode from inside a try that catches Exception, so the message was re-wrapped as "Failed to set HVAC mode: Unsupported HVAC mode: ...". The validation is now hoisted above the try. - config_flow.async_step_reauth_confirm swallowed unexpected exceptions into a bare "unknown" error with no log, unlike the user step. It now logs via _LOGGER.exception. Remaining changes are mechanical: import ordering, docstrings on public methods, ClassVar on mutable class attributes, contextlib.suppress, and asyncio.TimeoutError -> TimeoutError (an alias since 3.11). The smoke test now reads the new DknCloudNaClient.socket_connected property rather than reaching into _socket. Co-authored-by: anthropic/claude-opus-5
77 lines
2.2 KiB
Python
77 lines
2.2 KiB
Python
"""Constants for DKN Cloud NA integration."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
|
|
DOMAIN = "dkncloudna"
|
|
LOGGER = logging.getLogger(__package__)
|
|
MANUFACTURER = "Daikin"
|
|
|
|
# API
|
|
BASE_URL = "https://dkncloudna.com"
|
|
API_BASE = "/api/v1"
|
|
API_LOGIN = f"{API_BASE}/auth/login/dknUsa"
|
|
API_IS_LOGGED_IN = f"{API_BASE}/users/isLoggedIn/dknUsa"
|
|
API_REFRESH_TOKEN = f"{API_BASE}/auth/refreshToken/{{refresh_token}}/dknUsa"
|
|
API_INSTALLATIONS = f"{API_BASE}/installations/dknUsa"
|
|
API_SOCKET_PATH = f"{API_BASE}/devices/socket.io/"
|
|
API_USERS_NAMESPACE = "/users"
|
|
|
|
# The DKN Cloud NA API requires a mobile-like User-Agent.
|
|
# This matches what the official DKN Cloud NA iOS app sends.
|
|
USER_AGENT = (
|
|
"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) "
|
|
"AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
|
|
)
|
|
|
|
REQUEST_TIMEOUT = 30 # seconds
|
|
SOCKET_RECONNECT_ATTEMPTS = 5
|
|
|
|
# Config/options keys
|
|
CONF_SCAN_INTERVAL = "scan_interval"
|
|
CONF_EXPOSE_PII = "expose_pii"
|
|
# These two are config-entry key names, not credentials.
|
|
CONF_USER_TOKEN = "user_token" # noqa: S105
|
|
CONF_REFRESH_TOKEN = "refresh_token" # noqa: S105
|
|
|
|
# Defaults
|
|
DEFAULT_SCAN_INTERVAL = 60 # seconds
|
|
MIN_SCAN_INTERVAL = 30
|
|
MAX_SCAN_INTERVAL = 300
|
|
|
|
# Optimistic overlay: safety bound for cloud-propagation lag. Overlays
|
|
# normally clear earlier via reconciliation once the device echoes the
|
|
# requested value; this TTL guarantees the UI cannot get stuck on a
|
|
# locally-set value indefinitely if the write was silently rejected.
|
|
OPTIMISTIC_TTL_SEC: float = 30.0
|
|
|
|
# Post-write coordinator refresh: coalesced delay after a device command.
|
|
POST_WRITE_REFRESH_DELAY_SEC: float = 1.0
|
|
|
|
# Bounded wait for the cloud to echo a dependent write (e.g. confirming a mode
|
|
# change before the matching setpoint is sent) and the poll step used while
|
|
# waiting.
|
|
DEVICE_ECHO_TIMEOUT_SEC: float = 8.0
|
|
DEVICE_ECHO_POLL_SEC: float = 0.25
|
|
|
|
# Device modes (from homebridge plugin src/types.ts)
|
|
# DeviceMode: 1=Auto, 2=Cool, 3=Heat, 4=Fan, 5=Dry
|
|
DEVICE_MODE_AUTO = 1
|
|
DEVICE_MODE_COOL = 2
|
|
DEVICE_MODE_HEAT = 3
|
|
DEVICE_MODE_FAN = 4
|
|
DEVICE_MODE_DRY = 5
|
|
|
|
# Fan speeds (SpeedState)
|
|
SPEED_AUTO = 0
|
|
SPEED_20 = 2
|
|
SPEED_40 = 3
|
|
SPEED_60 = 4
|
|
SPEED_80 = 5
|
|
SPEED_100 = 6
|
|
|
|
# Temperature units
|
|
TEMP_CELSIUS = 0
|
|
TEMP_FAHRENHEIT = 1
|