chore: drop HACS distribution and move CI to Gitea
CI / Validate integration (pull_request) Successful in 40s
CI / Lint (pull_request) Successful in 49s

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
This commit is contained in:
2026-09-19 10:09:11 -03:00
co-authored by anthropic/claude-opus-5
parent d6e935e8d7
commit 706580fab2
17 changed files with 461 additions and 99 deletions
+27 -5
View File
@@ -49,6 +49,11 @@ class DknCloudNaClient:
token: str | None = None,
refresh_token: str | None = None,
) -> None:
"""Initialise the client.
Either ``password`` (for a fresh login) or ``token`` /
``refresh_token`` (to resume an existing session) should be supplied.
"""
self._username = username
self._session = session
self._password = password
@@ -190,7 +195,11 @@ class DknCloudNaClient:
socketio_path=API_SOCKET_PATH.strip("/"),
namespaces=namespaces,
)
except Exception as err: # noqa: BLE001
except Exception as err: # noqa: BLE001 - socket is best-effort
# The Socket.IO connection is an optimisation on top of polling.
# python-socketio surfaces transport failures as a grab-bag of
# exception types, and none of them should take the integration
# down: returning False just means we fall back to the poll cycle.
LOGGER.debug("DKN socket connect failed: %s", err)
await sio.disconnect()
return False
@@ -220,6 +229,15 @@ class DknCloudNaClient:
async with self._socket_lock:
await self._disconnect_socket_locked()
@property
def socket_connected(self) -> bool:
"""Return whether the Socket.IO connection is currently up.
Live updates arrive over this connection; when it is down the
integration still works, but only refreshes on the poll interval.
"""
return self._socket is not None and self._socket.connected
async def async_send_machine_event(
self,
installation_id: str,
@@ -251,7 +269,7 @@ class DknCloudNaClient:
"ack": ack,
}
LOGGER.debug("DKN socket ack %s %s", namespace, ack)
except Exception as err: # noqa: BLE001
except Exception as err:
raise DknConnectionError(str(err) or type(err).__name__) from err
def pop_last_command_debug(self) -> dict[str, Any] | None:
@@ -275,8 +293,11 @@ class DknCloudNaClient:
if socket is not None:
try:
await socket.disconnect()
except Exception: # noqa: BLE001
pass
except Exception as err: # noqa: BLE001 - teardown must never raise
# The socket reference is already dropped, so a failed
# disconnect leaves nothing to act on. Log it rather than
# swallowing it silently, so a recurring failure is visible.
LOGGER.debug("DKN socket disconnect failed: %s", err)
def _store_tokens(self, data: Any) -> None:
"""Persist access and refresh tokens from an API response."""
@@ -397,7 +418,7 @@ class DknCloudNaClient:
timeout=REQUEST_TIMEOUT,
) as response:
data = await self._read_response(response)
except asyncio.TimeoutError as err:
except TimeoutError as err:
raise DknConnectionError("Request timed out") from err
except ClientError as err:
raise DknConnectionError(str(err) or type(err).__name__) from err
@@ -451,6 +472,7 @@ class DknCloudNaClient:
return f"HTTP {response.status}: {response.reason}"
def __repr__(self) -> str:
"""Return a debug representation with the username and token redacted."""
first = self._username[0] if self._username else "?"
token_state = "set" if self.token else "none"
return f"DknCloudNaClient(u={first}***, token={token_state})"