runtime.py
Home Assistant runtime bridge over the shared OpenAliro serial session.
Overview
Home Assistant runtime bridge over the shared OpenAliro serial session.
used by __init__.py diagnostics.py event.py sensor.py
API
Cclass OpenAliroRuntime
Own one direct serial session and fan out approved observations.
FOpenAliroRuntime.__init__(self, device: DeviceConfig, session: Optional[SerialSession]=None, access_callback: Optional[Callable[[AccessEvent], None]]=None) -> None
Initialize the OpenAliro runtime with a device configuration, optional serial session, and optional access callback. If no session is provided, create one via session_for_device. Set up internal state for distance, access events, listeners, and async tasks.
FOpenAliroRuntime.available(self) -> bool
Return true if the device session is ready to stream or in compatibility mode.
FOpenAliroRuntime.async_start(self) -> None
Start the runtime: spawn the maintenance coroutine to keep the serial session alive and the consumer coroutine to read observations indefinitely.
OpenAliroRuntime._consumeFOpenAliroRuntime.async_stop(self) -> None
Stop the runtime: set the stop flag, cancel and await the consumer and maintenance tasks (swallowing CancelledError), and close the session.
FOpenAliroRuntime.add_listener(self, listener: Listener) -> Callable[[], None]
Register a listener callback to be invoked whenever distance or access state changes. Return a callable that removes the listener.
FOpenAliroRuntime._consume(self) -> None
Coroutine that reads observations from the serial session indefinitely until _stop is set. For each observation: if DistanceReading, update distance_mm; if AccessEvent, update last_access and invoke the access callback if registered; otherwise skip. After each observation, notify all listeners.
OpenAliroRuntime.async_startUndocumented (1)
OpenAliroRuntime.remove