SmartGroupModel(options?: SmartGroupModelOptions)

Requires:
@ray-js/panel-sdk≥1.5.0
Additional notesRead the full notes
All DP-related API types are inferred at compile time from the generic S (ReadonlyDpSchemaList). S comes from the Schema constant declared with as const in devices/schema.ts of your project. Mapping from Schema property.type to TypeScript types: - bool → boolean (true/false); - value → number (constrained at runtime by property.min/max/step; type is number only); - enum → props are string; the publishDps parameter is the literal union of property.range (e.g., 'white' | 'colour'); - bitmap → number (bitwise value; specify the bit position with actions on(idx)/off(idx)); - string → string; - raw (outer type='raw') → string. Similar to SmartDeviceModel, but dedicated for group-device scenarios. Group devices share the same DP Schema, and control commands are sent to all devices in the group. The Schema must use the as const assertion; otherwise, literal type inference degrades.

Description

Smart group device model that provides core capabilities such as DP state management, event listening, and command dispatch for group devices

Parameters

ParameterTypeRequiredDescription
NoGroup model initialization options, including abilities (advanced capability list) and interceptors (event interceptors), among other options

Return Value

Type: SmartGroupModel
SmartGroupModel instance

Methods

MethodDescription
initAsynchronously initialize the smart group and then return its instance
onInitializedRegister a callback for the smart group model initialized event
offInitializedRemove the listener for the smart group model initialized event
getDevInfoGet the first device information under the smart group and the data merged with the group
getGroupInfoGet smart group information
getDpSchemaGet the DP Schema (DP capability descriptions) mapping table for the smart group
getDpStateGet smart group DP states
getNetworkGet the network status of the environment the smart group is in
getBluetoothGet the Bluetooth status of the environment the smart group is in
onDpDataChangeListen for DP change events in group devices
onDeviceOnlineStatusUpdateListen for smart group online status changes
onDeviceInfoUpdatedListen for smart group device info change events
onGroupDpDataChangeEventListen for DP change events in group devices
onGroupInfoChangeListen for smart group info change events
onNetworkStatusChangeListen for network status change events
onBluetoothAdapterStateChangeListen for Bluetooth adapter state change events
offDpDataChangeStop listening for smart group DP change events
offDeviceOnlineStatusUpdateUnsubscribe from smart group online status changes
offDeviceInfoUpdatedUnsubscribe from smart group device info change events
offGroupDpDataChangeEventStop listening for group device DP change events
offGroupInfoChangeStop listening for smart group info change events
offNetworkStatusChangeStop listening for network status change events
offBluetoothAdapterStateChangeStop listening for Bluetooth adapter state change events
publishDpsBatch control smart group DPs
queryDpsActively query device DP state (not supported for groups)
destroyDestroy the current smart group instance and all event listeners

Examples

Basic initialization.

import { SmartGroupModel } from '@ray-js/panel-sdk';
import { defaultSchema } from './devices/schema';

type Schema = typeof defaultSchema;
const group = new SmartGroupModel<Schema>();
await group.init();

// After initialization, you can access the group state
const props = group.getDpState();      // { switch_led: boolean, work_mode: string, ... }
const groupInfo = group.getGroupInfo(); // Group info