Features¶
Higher-level helpers built on top of the raw client: a device snapshot for dashboards, a store that applies streamed protobuf state updates, and asset syncing.
busylib.features
¶
DeviceSnapshot
¶
Bases: BaseModel
update_available_version
class-attribute
instance-attribute
¶
update_available_version: str | None = None
field_errors
class-attribute
instance-attribute
¶
field_errors: dict[str, str] = Field(default_factory=dict)
raw_time
class-attribute
instance-attribute
¶
raw_time: object | None = Field(default=None, exclude=True)
screen_front
class-attribute
instance-attribute
¶
screen_front: Frame | None = Field(default=None, exclude=True)
screen_back
class-attribute
instance-attribute
¶
screen_back: Frame | None = Field(default=None, exclude=True)
DeviceStateStore
¶
DeviceStateStore(initial: DeviceSnapshot)
Stateful store for snapshot updates driven by status websocket stream.
The store applies protobuf state deltas, updates current snapshot, and
notifies subscribers through two callback channels:
- on_state: receives full updated snapshot;
- on_diff: receives changed top-level fields and full snapshot.
Create a state store with initial snapshot value.
on_state
¶
on_state(callback: StateCallback) -> Callable[[], None]
Subscribe to full-state updates and return unsubscriber.
on_diff
¶
on_diff(callback: StateDiffCallback) -> Callable[[], None]
Subscribe to changed-fields updates and return unsubscriber.
apply_stream_message
¶
apply_stream_message(state_message: dict[str, object]) -> DeviceSnapshot
Apply one stream message and emit callbacks when state changes.
sync_app_assets
async
¶
sync_app_assets(client: AssetsClient, application_name: str, assets_dir: str | Path) -> list[str]
Sync local assets with device storage for the given application name. Uploads files that are missing or have different sizes.
apply_state_stream_update
¶
apply_state_stream_update(snapshot: DeviceSnapshot, state_message: dict[str, object]) -> DeviceSnapshot
Apply one protobuf /api/status/ws state message to an existing snapshot.
The function updates only fields present in state updates and preserves all previously known values for absent fields.
collect_device_snapshot
async
¶
collect_device_snapshot(client: AsyncBusyBar) -> DeviceSnapshot
Collect a best-effort device snapshot with per-field diagnostics.
Each field request runs independently. Failed fields are set to None and
reported in field_errors without aborting the whole snapshot.