Device SupportGroup Not Support

useCustomAlarm()

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

Description

Get the device’s custom alarm list and CRUD operations; supports single devices only, not groups

Parameters

None

Return Value

Type: CustomAlarmResult
Custom alarm data, loading state, and management methods

Referenced Types

typeCustomAlarmResult
PropertyTypeDescription
Custom alarm list for the device
loadingbooleanWhether the device’s custom alarm list is loading
Query the device’s custom alarm list by device ID
Add or edit a custom alarm rule
Enable or disable custom alarm rules
Delete custom alarm rules
typeOperator
type Operator = '==' | '<' | '>' | '<=' | '>=';
typeDpValueDatapoint value type, which can be boolean, number, or string.
export type DpValue = boolean | number | string;

Valid Values

Operator
ValueDescriptionSince
==--
<--
>--
<=--
>=--

Examples

Example

import { useCustomAlarm } from '@ray-js/panel-sdk';

function AlarmPage() {
  const { data, loading, getCustomAlarmList, setCustomAlarmStatus } = useCustomAlarm();

  React.useEffect(() => {
    getCustomAlarmList();
  }, []);

  const handleToggle = (item) => (value) => {
    setCustomAlarmStatus({ bindId: item.bindId, enable: value });
  };

  return data.map(item => (
    <Switch key={item.bindId} checked={item.enable} onChange={handleToggle(item)} />
  ));
}