VehicleObservation

class VehicleObservation(val vehicle_: Vehicle, api: VehicleApi, pollInterval: Duration = Duration.ofMinutes(5)) : AutoCloseable

Periodically polls VehicleApi.getStatus and exposes the latest VehicleStatus as a StateFlow.

Create via rsdev.ovh.weconnect.WeConnect.observe, then call start to begin polling. Collect status to receive updates.

Parameters

vehicle_

the vehicle to observe

api

the API client used for status polling

pollInterval

time between successive polls (default: 5 minutes)

Constructors

Link copied to clipboard
constructor(vehicle_: Vehicle, api: VehicleApi, pollInterval: Duration = Duration.ofMinutes(5))

Properties

Link copied to clipboard
val status: StateFlow<VehicleStatus?>

The latest vehicle status, or null if no poll has completed yet.

Link copied to clipboard
Link copied to clipboard
val vin: String

Shorthand for the observed vehicle's VIN.

Functions

Link copied to clipboard
open override fun close()
Link copied to clipboard
suspend fun refresh()

Fetches the current status immediately (outside the regular poll cycle).

Link copied to clipboard
fun start()

Starts the background polling coroutine. Idempotent -- calling twice has no effect.

Link copied to clipboard
fun stop()

Cancels the background polling coroutine without closing the underlying API client.