SmartDeviceModel.onDeviceInfoUpdated(listener: Function)

Requires:
@ray-js/panel-sdk≥1.0.0

Description

Listen for smart device info change events (including changes to device name, DP names, etc.)

Parameters

ParameterTypeRequiredDescription
listener(data: DeviceInfoChanged) => numberYesEvent callback that receives parameters containing deviceId, changed data, etc.

Return Value

Type: number
Listener ID used to unsubscribe via offDeviceInfoUpdated

Referenced Types

typeDeviceInfoChangedDevice info change event callback parameters
PropertyTypeRequiredDescription
deviceIdstringYesDevice ID
NoChanged DP data (may be empty)
typeDpStateDatapoint status object, where the key is the datapoint code and the value is the datapoint value.
export type DpState = Record<string, DpValue>;
typeDpValueDatapoint value type, which can be boolean, number, or string.
export type DpValue = boolean | number | string;

Examples

Example

const id = device.onDeviceInfoUpdated((data) => {
  console.log('Device info changed:', data.deviceId);
});
// Unsubscribe
device.offDeviceInfoUpdated(id);