integration/homeassistant/custom_components/openaliro/runtime.py
openaliro/openaliro
Module

runtime.py

Home Assistant runtime bridge over the shared OpenAliro serial session.

integration/homeassistant/custom_components/openaliro/runtime.py7 documented symbols

Overview

Home Assistant runtime bridge over the shared OpenAliro serial session.

used by __init__.py diagnostics.py event.py sensor.py

API

Cclass OpenAliroRuntime

integration/homeassistant/custom_components/openaliro/runtime.py:15

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

integration/homeassistant/custom_components/openaliro/runtime.py:18

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

integration/homeassistant/custom_components/openaliro/runtime.py:36

Return true if the device session is ready to stream or in compatibility mode.

FOpenAliroRuntime.async_start(self) -> None

integration/homeassistant/custom_components/openaliro/runtime.py:40

Start the runtime: spawn the maintenance coroutine to keep the serial session alive and the consumer coroutine to read observations indefinitely.

calls OpenAliroRuntime._consume

FOpenAliroRuntime.async_stop(self) -> None

integration/homeassistant/custom_components/openaliro/runtime.py:45

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]

integration/homeassistant/custom_components/openaliro/runtime.py:57

Register a listener callback to be invoked whenever distance or access state changes. Return a callable that removes the listener.

FOpenAliroRuntime._consume(self) -> None

integration/homeassistant/custom_components/openaliro/runtime.py:67

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.

called by OpenAliroRuntime.async_start
Undocumented (1)

OpenAliroRuntime.remove