Skip to content

Backport async X-Sense client foundation#28

Open
Wheemer wants to merge 4 commits into
theosnel:developfrom
Wheemer:backport-hacs-client-foundation
Open

Backport async X-Sense client foundation#28
Wheemer wants to merge 4 commits into
theosnel:developfrom
Wheemer:backport-hacs-client-foundation

Conversation

@Wheemer

@Wheemer Wheemer commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Backport the reusable X-Sense client foundation from the current Home Assistant custom integration into python-xsense so this package can again act as the shared async client for X-Sense cloud, AWS IoT shadow, MQTT, ADDX camera, device, and action behavior.

This keeps Home Assistant platform code out of the library. The package now exposes clean async Python client/model/parser helpers; the HA integration can still decide separately how and whether to consume the library later.

What changed

  • Make the public package async-only by exporting AsyncXSense and removing the old sync XSense client.
  • Update Android app metadata, request signing fields, Cognito login/refresh handling, AWS token loading, AWS signing, and session-expiry behavior.
  • Backport X-Sense /app API behavior, AWS IoT shadow read/write helpers, entity/device/station/house mapping, and model normalization.
  • Backport MQTT helper behavior including topic construction, payload parsing, and shadow/presence topic handling.
  • Add ADDX/VicoHome camera support including IPC registration, camera discovery/metadata merging, status fields, thumbnails, live-view helpers, WebRTC ticket/signaling support, stream protocol detection, camera settings/actions, record history, and AI service/history helpers.
  • Add reusable event/parser helpers extracted from the HA coordinator for MQTT updates, camera history, AI detections, and self-test payloads.
  • Add documented non-camera history helpers for daily/monthly, station/device, CO, temperature/humidity, and dispatch history endpoints.
  • Add one-shot AWS shadow retry after 401/403 by refreshing AWS credentials, matching the ADDX auth retry pattern.
  • Normalize door/opening payload aliases into isOpen for door sensors, including SBS10 child shadow payloads.
  • Normalize security-line field notes from Thank you + show-and-tell: self-hosted control-room dashboard built on python-xsense #29 including openRemind, battery, RF, online, alarm, motion, armed, and alarm-mode surfaces.
  • Add reusable station alarm-mode/armed-state model helpers without moving HA alarm platform code into the library.
  • Consolidate the older open control-command PR work with async-only helpers for config writes, alarm/voice volume, station mode, SOS, fire drill, activation, install/signal/motion tests, light group power, and mute commands.
  • Add tests covering auth/request shape, AWS signing/shadow requests, camera discovery/settings/history parsing, AI/WebRTC parsing, action payloads, MQTT parsing, model normalization, public API shape, consolidated command helpers, and security-line field notes.
  • Update packaging/docs for the async client and Python 3.10+ support.

Supersedes older PRs

This PR supersedes the older overlapping PRs #22, #23, #24, and #25 by carrying their station action/data payload, device mapping/normalization, APK command, and MQTT live-update work forward in one async-only client branch with tests.

Upstream issue coverage

Deliberate boundary

This does not move Home Assistant entity descriptions, icons, device classes, config flows, registry cleanup, blueprints, translations, diagnostics, or platform setup into the library. It also does not reintroduce python-xsense as a dependency in the HACS integration.

Validation

  • pytest -q -> 110 passed
  • python -m compileall -q asynctest.py xsense tests
  • git diff --check
  • python setup.py check --metadata --strict
  • python -m build --sdist --wheel
  • clean wheel install, pip check, and import smoke for every xsense.* module
  • dependency freshness checked against PyPI for aiohttp, boto3, botocore, pycognito, paho-mqtt, and pytest

@Wheemer Wheemer marked this pull request as ready for review June 28, 2026 21:11
@Wheemer Wheemer marked this pull request as draft June 28, 2026 21:16
@Wheemer Wheemer marked this pull request as ready for review June 28, 2026 21:23
@Wheemer Wheemer changed the title [codex] Backport async X-Sense client foundation Backport async X-Sense client foundation Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant