Storage & Schema¶
Schema-driven per-device configuration rendered as UI forms by the host. DeviceStorage plus the JsonSchema* shapes.
camera_ui_sdk.storage ¶
OnSetCallback
module-attribute
¶
OnSetCallback = Callable[[Any, Any], None | Any] | Callable[[Any, Any], Awaitable[None | Any]] | Callable[[Any, Any], Coroutine[Any, Any, None | Any]]
Callback type for onSet handlers.
OnGetCallback
module-attribute
¶
OnGetCallback = Callable[[], None | Any] | Callable[[], Awaitable[None | Any]] | Callable[[], Coroutine[Any, Any, None | Any]]
Callback type for onGet handlers.
JsonSchemaType
module-attribute
¶
Available schema field types for configuration UI.
StringFormat
module-attribute
¶
StringFormat = Literal['date-time', 'date', 'time', 'email', 'uuid', 'ipv4', 'ipv6', 'password', 'qrCode', 'image']
String format types for validation/display.
Used on string-typed schemas to render a specialized UI control:
date-time— ISO 8601 date+time picker.date— date-only picker.time— time-only picker.email— email input with format validation.uuid— UUID input with format validation.ipv4— IPv4 address input.ipv6— IPv6 address input.password— masked input that hides characters.qrCode— value is rendered as a QR code (read-only display).image— value is a data URL or path; rendered as a thumbnail.
ButtonColor
module-attribute
¶
Button color variants.
SchemaConditionOperator
module-attribute
¶
Comparison operators for conditional field visibility.
T
module-attribute
¶
T = TypeVar('T', str, int, float, bool, list[str], list[int], list[float], list[bool], str | list[str])
Generic type variable for schema default values.
V2
module-attribute
¶
TypeVar for generic storage values type. Compatible with TypedDict.
JsonSchema
module-attribute
¶
JsonSchema = JsonSchemaString | JsonSchemaNumber | JsonSchemaBoolean | JsonSchemaEnum | JsonSchemaArray | JsonSchemaButton | JsonSchemaSubmit
Union of every top-level schema type (with callbacks).
Use this when defining the schemas you pass to defineSchemas,
addSchema, or changeSchema. Each entry describes one configurable
field rendered in the UI; the discriminator is the type property.
JsonSchemaWithoutKey
module-attribute
¶
JsonSchemaWithoutKey = JsonSchemaStringWithoutCallbacks | JsonSchemaNumberWithoutCallbacks | JsonSchemaBooleanWithoutCallbacks | JsonSchemaEnumWithoutCallbacks
Schema variant without the key field.
Used when the key is provided externally (e.g. as a dict property).
JsonSchemaWithoutCallbacks
module-attribute
¶
JsonSchemaWithoutCallbacks = JsonSchemaStringWithoutCallbacks | JsonSchemaNumberWithoutCallbacks | JsonSchemaBooleanWithoutCallbacks | JsonSchemaEnumWithoutCallbacks | JsonSchemaArrayWithoutCallbacks
Union type of schemas without callbacks. Use this for nested schemas (e.g., array items).
SchemaCondition ¶
Bases: TypedDict
Condition that controls when a field is visible. The field is shown only when the condition evaluates to true against the current form values.
Combine multiple conditions on a field via a list — all must pass (logical AND).
Example
Show apiKey only when authMode equals token::
{
"key": "apiKey",
"type": "string",
"title": "API Key",
"description": "",
"condition": {"key": "authMode", "value": "token"},
}
Show port only when protocol is one of the listed values::
{"key": "protocol", "operator": "in", "value": ["http", "https"]}
JsonFactorySchema ¶
Bases: TypedDict
Base schema interface for all schema types. Contains common fields like type, key, title, description.
JsonBaseSchemaWithoutCallbacks ¶
Bases: JsonFactorySchema, Generic[T]
Base schema without callbacks - used for nested schemas. Extends factory schema with common display options.
condition
instance-attribute
¶
Condition for conditional field visibility. List = all must be true (AND).
JsonBaseSchema ¶
Bases: JsonBaseSchemaWithoutCallbacks[T], Generic[T]
Base schema with callbacks - full schema interface. Adds storage and callback options for dynamic behavior.
JsonStringSchema ¶
JsonNumberSchema ¶
JsonBooleanSchema ¶
Bases: TypedDict
Boolean-specific schema options.
JsonEnumSchema ¶
JsonArraySchema ¶
JsonSchemaString ¶
Bases: JsonBaseSchema[str]
Complete string schema with callbacks.
JsonSchemaStringWithoutCallbacks ¶
JsonSchemaNumber ¶
JsonSchemaNumberWithoutCallbacks ¶
Bases: JsonBaseSchemaWithoutCallbacks[int | float]
Number schema without callbacks (for nested use).
JsonSchemaBoolean ¶
JsonSchemaBooleanWithoutCallbacks ¶
JsonSchemaEnum ¶
JsonSchemaEnumWithoutCallbacks ¶
Bases: JsonBaseSchemaWithoutCallbacks[str | list[str]]
Enum schema without callbacks (for nested use).
JsonSchemaArray ¶
Bases: JsonBaseSchema[list[str] | list[int] | list[float] | list[bool]]
Complete array schema with callbacks.
JsonSchemaArrayWithoutCallbacks ¶
Bases: JsonBaseSchemaWithoutCallbacks[list[str] | list[int] | list[float] | list[bool]]
Array schema without callbacks (for nested use).
JsonSchemaButton ¶
JsonSchemaSubmit ¶
Bases: TypedDict
Submit button schema - submits form data and can return updated schema.
onClick
instance-attribute
¶
Submit handler - receives form values, can return toast/schema updates.
ToastMessage ¶
Bases: TypedDict
Toast notification message.
Returned from a submit handler (JsonSchemaSubmit.onClick) inside a
FormSubmitResponse to surface a transient banner in the UI — for
example to confirm that a credential check succeeded or failed.
FormSubmitSchema ¶
Bases: TypedDict
Form submit input data.
FormSubmitResponse ¶
Bases: TypedDict
Form submit response — returned by JsonSchemaSubmit.onClick.
Used to react to a user-triggered submit (e.g. "Test connection", "Pair device") with optional UI feedback. Either field may be set:
toastshows a transient banner.schemareplaces the current form schema, useful for multi-step flows where the next step depends on the submitted values.
SchemaConfig ¶
DeviceStorage ¶
Bases: Protocol, Generic[V2]
Device storage interface for plugin/camera configuration.
Provides methods to read/write configuration values and manage schemas. Each plugin and camera can have its own storage instance.
Example
# Get a value with default
threshold = await storage.getValue("motionThreshold", 50)
# Set a value
await storage.setValue("motionThreshold", 75)
# Add a new schema field
await storage.addSchema(
{
"type": "number",
"key": "sensitivity",
"title": "Sensitivity",
"description": "Detection sensitivity (0-100)",
"minimum": 0,
"maximum": 100,
"defaultValue": 50,
}
)
getValue
async
¶
setValue
async
¶
Set a configuration value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Configuration key |
required |
new_value
|
Any
|
New value to set |
required |
submitValue
async
¶
Submit a value (for submit-type schemas).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Schema key |
required |
new_value
|
Any
|
Submitted value |
required |
Returns:
| Type | Description |
|---|---|
FormSubmitResponse | None
|
Optional response with toast/schema updates |
hasValue ¶
Check if a configuration value exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Configuration key |
required |
getConfig
async
¶
Get the full schema configuration.
Returns:
| Type | Description |
|---|---|
SchemaConfig
|
Schema definitions and current values |
setConfig
async
¶
Set the full configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_config
|
V2
|
New configuration values |
required |
addSchema
async
¶
Add a new schema field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
JsonSchema
|
Schema definition to add |
required |
removeSchema ¶
Remove a schema field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Schema key to remove |
required |
changeSchema
async
¶
Update an existing schema field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Schema key to update |
required |
new_schema
|
dict[str, Any]
|
Partial schema with updated fields |
required |
getSchema ¶
Get a schema definition by key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Schema key |
required |
Returns:
| Type | Description |
|---|---|
JsonSchema | None
|
Schema or None |
hasSchema ¶
Check if a schema exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Schema key |
required |
setInternalValue ¶
Set a system-internal value without requiring a schema and persist it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Internal key (typically prefixed with '_') |
required |
value
|
Any
|
Value to set |
required |