SmartDeviceModel(options?: SmartDeviceModelOptions)
Requires:
@ray-js/panel-sdk≥1.0.0
Additional notesRead the full notes
All DP-related API types are inferred at compile time by the generic S (ReadonlyDpSchemaList).
S comes from the Schema constant declared with as const in the business project's devices/schema.ts. Mapping from Schema property.type to TypeScript types:
- bool → boolean (true/false)
- value → number (runtime-constrained by property.min/max/step; the type is number only)
- enum → props are string; publishDps parameters are a literal union of property.range (e.g., 'white' | 'colour')
- bitmap → number (bitwise value; use actions on(idx)/off(idx) to specify bit positions)
- string → string
- raw (outer type='raw') → string
Schema must use the as const assertion; otherwise literal type inference degrades.
S comes from the Schema constant declared with as const in the business project's devices/schema.ts. Mapping from Schema property.type to TypeScript types:
- bool → boolean (true/false)
- value → number (runtime-constrained by property.min/max/step; the type is number only)
- enum → props are string; publishDps parameters are a literal union of property.range (e.g., 'white' | 'colour')
- bitmap → number (bitwise value; use actions on(idx)/off(idx) to specify bit positions)
- string → string
- raw (outer type='raw') → string
Schema must use the as const assertion; otherwise literal type inference degrades.
Description
Smart device model that provides DP state management, event listening, and command publishing
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| No | Device model initialization config, including abilities (advanced capabilities) and interceptors (event interceptors) |
Return Value
Type: SmartDeviceModel
SmartDeviceModel instance
Referenced Types
type
InitDpStateInterceptortype
InitDevInfoInterceptortype
OnDpDataChangeInterceptortype
OnDeviceOnlineStatusUpdateInterceptortype
OnDeviceInfoUpdatedInterceptortype
OnNetworkStatusChangeInterceptortype
OnBluetoothAdapterStateChangeInterceptortype
InitDpStateInterceptorParams| Property | Type | Required | Description |
|---|---|---|---|
| Yes | Current device DP state | ||
| Yes | New device DP state | ||
action | "init" | "onDpDataChange" | "onDeviceInfoUpdated" | "dp-kit" | Yes | Interceptor action |
type
GetSmartDeviceModelDevInfo| Property | Type | Required | Description |
|---|---|---|---|
dpCodes | object | Yes | |
dps | object | Yes | |
idCodes | object | Yes | |
codeIds | object | Yes | |
schema | S | Yes |
type
SmartDeviceModelAbilityContainer type for SmartDeviceModel abilities, used only for generic constraints and internal composition.type
PublishDpsOptionsUnderlying option type of publishDps, reused by the SDK’s internal request chain.| Property | Type | Required | Description |
|---|---|---|---|
| No |
type
DpValueDatapoint value type, which can be boolean, number, or string.type
SendDpOptionDP send options. Can be used as the global default configuration for createDpKit, and can also be overridden in a single publishDps/action call.
The global `sendDpOption` suits product-level defaults;
options passed for a single send are suitable for temporarily overriding throttling, debouncing, protocol parsing, or optimistic update strategies.
Note: requires the dp-kit interceptor.| Property | Type | Required | Description | Since |
|---|---|---|---|---|
immediate | boolean | No | Whether to trigger a state update immediately; requires the dp-kit interceptor | - |
| No | Whether to ignore DP reports; default false | v1.11.0 | ||
| No | Whether to sync dpData with cloud device properties; default false | v1.11.0 | ||
ordered | boolean | No | Whether to send multiple DPs in the order of the object’s keys; requires the dp-kit interceptor; default false | - |
checkRepeat | boolean | No | Whether to check for duplicate values and skip sending; requires the dp-kit interceptor; default false Compared with the current `dpState`; duplicates are detected and not sent | - |
delay | number | No | Delayed send; requires the dp-kit interceptor; default 0, in ms | - |
throttle | number | No | Send throttling (conflicts with debounce); requires the dp-kit interceptor; default 0, in ms | - |
debounce | number | No | Send debounce (conflicts with throttle); requires the dp-kit interceptor; default 0, in ms | - |
| No | A per-call DP protocol converter; requires the dp-kit interceptor. The key is the dpCode and the value is a `{ parser, formatter }` object: - parser(dpValue: string) => any — parses the raw DP string into a structured object - formatter(parsedValue: any) => string — serializes the structured object into a DP string Affects only this invocation and does not override the global protocols configuration in createDpKit | - |
type
Capabilitytype
DevAttributeValid Values
LogConfig.level
| Value | Description | Since |
|---|---|---|
VERBOSE | - | - |
SUCCESS | - | - |
INFO | - | - |
WARN | - | - |
FATAL | - | - |
DevInfo.schema.mode
| Value | Description | Since |
|---|---|---|
rw | - | - |
ro | - | - |
wr | - | - |
DevInfo.schema.property.type
| Value | Description | Since |
|---|---|---|
string | - | - |
bool | - | - |
value | - | - |
enum | - | - |
bitmap | - | - |
raw | - | - |
DevInfo.schema.type
| Value | Description | Since |
|---|---|---|
raw | - | - |
obj | - | - |
FunConfig.tyabirysr4_app
| Value | Description | Since |
|---|---|---|
follow | - | - |
--app-B1 | - | - |
FunConfig.tyabis5d9w_app
| Value | Description | Since |
|---|---|---|
follow | - | - |
--app-M1 | - | - |
Methods
| Method | Description |
|---|---|
| init | Return the instance after asynchronously initializing the smart device |
| onInitialized | Register a callback for the smart device model initialization-completed event |
| offInitialized | Cancel the smart device model initialization-completed event listener |
| getDevInfo | Get smart device information, implemented based on ty.device.getDeviceInfo |
| getDpSchema | Get the smart device DP schema (function point) mapping |
| getDpState | Get smart device DP status |
| getNetwork | Get the network status of the smart device’s environment |
| getBluetooth | Get the Bluetooth status of the smart device’s environment |
| onDpDataChange | Listen for smart device DP change events |
| onDeviceOnlineStatusUpdate | Listen for smart device online/offline status changes |
| onDeviceInfoUpdated | Listen for smart device info change events (including changes to device name, DP names, etc.) |
| onNetworkStatusChange | Listen for network status change events |
| onBluetoothAdapterStateChange | Listen for Bluetooth adapter state change events |
| offDpDataChange | Unsubscribe from smart device DP change events |
| offDeviceOnlineStatusUpdate | Unsubscribe from smart device online/offline status changes |
| offDeviceInfoUpdated | Unsubscribe from smart device info change events |
| offNetworkStatusChange | Unsubscribe from network status change events |
| offBluetoothAdapterStateChange | Unsubscribe from Bluetooth adapter state change events |
| publishDps | Control multiple smart device DPs in batch, built on top of ty.device.publishDps |
| queryDps | Actively query device DP status (not supported for groups) |
| destroy | Destroy the current smart device instance and all event listeners |