Skip to content

Universal connectivity within a bounded scope

Status: native serial, optional MQTT, and optional ESPHome Native API observation providers are implemented. The broader universal-connectivity design remains proposed. See the architecture audit for the source baseline, implementation sequence, and evidence limits. “Universal” describes normalization into PHOS semantics, not support for every device or protocol.

Current boundary and target scope

src/robot/hardware/controller_protocol.py separates phos-hw v1 JSON Lines from SerialControllerTransport and ControllerService in src/robot/hardware/serial_controller.py. src/robot/runtime.py::build_runtime routes accepted telemetry to existing sensor services. Existing Pi-local providers continue operating; they do not need a network protocol.

Initial connectivity work is limited to:

Path Current status Proposed responsibility
Existing native hardware and USB serial Implemented Preserve framing, discovery, heartbeat, session retirement, telemetry and resolved expressive LED output
MQTT Implemented as an optional provider Subscription-only typed observation mappings; see MQTT
ESPHome Native API Implemented as an optional encrypted provider with explicit numeric/binary mappings and separate authorization See the current integration guide; broader device/protocol expansion remains out of scope

No other protocol is to be implemented during this initiative. Home Assistant is not needed for any of these paths. A broker is required only when the operator enables MQTT; PHOS will neither embed a broker nor require one for core functionality. Network providers initially ingest observations only. Existing native expressive outputs retain their current authorized route.

flowchart LR
  serial[Native phos-hw serial] --> native[Existing controller adapter]
  broker[Optional local MQTT broker] --> mqtt[Optional MQTT adapter]
  device[Optional ESPHome device] --> esp[Optional Native API adapter]
  native --> validation[Typed validation and source binding]
  mqtt --> validation
  esp --> validation
  validation --> services[Existing domain services]
  services --> context[Semantic context and evidence]

MQTT design

Each explicitly configured binding associates a provider instance, allowed topic, bounded payload decoder, metric, unit, physical source ID, space, freshness TTL, and source-time policy. Start with a scalar or small fixed JSON schema, with finite numeric values and explicit units. No arbitrary template evaluation, Python expressions, dynamically imported decoders, or auto-created entities. Topic names and payload labels are data, never instructions to agents.

MQTT defines delivery quality, retained messages, and payload-agnostic transport; it does not define PHOS measurement semantics. QoS 1 can duplicate delivery. These protocol facts are described in the OASIS MQTT 5.0 specification. The following are PHOS design policies, not transport guarantees:

  • Explicit topic allow-lists and broker ACLs; no broad wildcard discovery by default. An upstream device cannot create source/space bindings.
  • Treat retained delivery as a cached candidate. Without verifiable source age or a live-reporting policy that establishes freshness, it cannot establish a fresh observation, restore source availability, or enter continuity evidence.
  • Use generation plus upstream sequence/message identity when available to reject replay. Equal numeric values alone are not duplicates: valid periodic measurements must refresh freshness. Without upstream identity, report the limitation; never promise exactly-once measurement capture.
  • Separate connection health from source availability. Broker connection does not imply a sensor is reporting. Optional availability topics are hints and cannot make an expired value fresh.
  • On reconnect, re-establish subscriptions with bounded backoff; never replay expired observation work. No MQTT action topics or general publish tool.

Protocol version, QoS/session options and optional client library remain open until the first MQTT slice. Do not promise MQTT 5-only features for every broker.

ESPHome Native API implementation and remaining design boundary

The initial bounded integration described by the guide is implemented. The following design notes remain applicable as constraints and future acceptance considerations; they are not a statement that the provider is absent.

Connect directly to configured devices; do not proxy through Home Assistant. Inventory supported entities, bind stable device/entity identifiers to configured physical sources, subscribe to state updates, and accept only mapped numeric or explicitly supported binary sensor observations. Names alone do not determine units, room, identity, trust, or capability. A binary motion detector is not automatically equivalent to PHOS's confirmed camera-presence state.

The official Native API reference describes the TCP/protobuf interface, optional encryption, and device-side connection and reboot limits. The implemented profile requires explicitly configured encrypted connections, resolves keys through SecretsService, and bounds configured devices. The optional aioesphomeapi client is declared in the esphome extra. Review device reboot-on-no-client settings during hardware acceptance; firmware must not be assumed to behave like the separate PHOS companion firmware.

On reconnect, enumerate and verify entity bindings before accepting observations in a new session generation. A changed entity key/unit/device identity invalidates the binding until revalidated. Unsupported entities remain absent from physical semantics; they are not exported as an agent device catalog. Device actions, switch control, camera streaming, firmware upload, and remote provisioning are outside this initiative.

Configuration, dependencies, and recovery

Future non-secret settings extend RuntimeConfig, config/phos.yaml, the same ConfigRepository validation/persistence, and Web domain coverage. New known sections need a documented scoped migration; unknown keys still fail. Secrets remain separate, with only references in configuration. Do not add executable mapping scripts, alternate files/schemas, or standalone runtime CLI settings.

Both network providers default disabled. ESPHome devices also default disabled when onboarded. Missing optional dependencies, missing secrets, authentication failures, or unreachable peers produce bounded diagnostics and unavailable or withheld observations while native PHOS continues. Structurally invalid canonical configuration still fails validation before startup; optionality does not justify accepting malformed settings.

Use the provider lifecycle, bounded ingress, and redacted diagnostics. Broker/device addresses are administrative metadata; MCP receives semantic observations rather than network connection details. ESPHome configuration is persisted and reconciled through the existing application/lifecycle boundary; zone-only metadata changes do not restart its connection. Do not copy native-controller hot-reconfiguration behavior to new providers without proving rollback semantics.

Acceptance and compatibility

Fake-peer tests must cover disabled operation without packages installed, two independent sources with one metric, malformed/oversized values, unit mismatch, retained/replayed MQTT data, duplicated delivery, ESPHome entity changes, missing/revoked secrets, timeout, reconnect, stale old-generation callbacks, flooding, and cancellation. No test needs physical hardware or a public broker.

Then run an optional local-peer integration test and a separate Pi 3 soak. Record source counts, latency/RSS limits, and dependency/firmware versions. Native serial frames, sensor availability, eyes, speech, signals, and existing MCP outputs must pass regression tests with both providers disabled and with either provider down. Neither integration may cause a global restart or make external device control available through MCP.