English | [简体中文](./README-zh_CN.md)

# LampScheduleSetFunction

## Usage

- Configure appid in `src/global.config.ts`

```ts
export const tuya = {
  // other content
  // ...xxxx

  functionalPages: {
    // other functional pages
    // ...xxxx

    // schedule functional page
    LampScheduleSetFunction: {
      appid: 'ty56cr7pi6rxiucspo',
    },
  },
};
```

```tsx
import { navigateToSchedule } from '@ray-js/lamp-schedule-core';

const handleJump = () => {
  // sigmesh note that the devId configured here needs to be under the family of your own account, otherwise you will not be able to get the devInfo data and cause various exceptions
  // not rtc_timer
  // const deviceId = 'vdevo174167890140766';
  // sigmesh with rtc_timer
  // const deviceId = 'vdevo174367051524181';
  // wifi
  const deviceId = '6c927ad99d26660de1nnta';
  const groupId = '';

  const transData = {
    // themeConfig is optional, default dark mode
    themeConfig: {
      // themeType is optional, dark or light, default dark
      themeType: 'light',
      // bgImg is optional, only remote image is supported
      bgImg: 'https://images.tuyacn.com/smart/uiconf/bg_57_s.jpg?t=1750749772928',
      // themeColor is optional, default #1082FE
      themeColor: 'rgba(255, 0, 255, 1)',
      // mainColor is optional, default #ffffff
      mainColor: 'rgba(255, 0, 0, 1)',
      // bgColor is optional, default #121222
      bgColor: 'rgba(255, 255, 255, 0.9)',
    },
    // Does the regular timer support the "Remarks" and "reminder" functions? By default, it does not support them
    // normalTimerAdvances: {
    //   remarks: true,
    //   notice: true,
    // },
    forceSupport: {
      // Normally, it is displayed based on whether dp exists. It supports force-not display, and it does not support force-not display, because if there is no corresponding dp, the function cannot run normally.
      countdown: false,
      rhythms: false,
      sleep: false,
      wakeup: false,
      // cycle: false,
      // random: false,
      // timer: false,
    },

    // Multilingual key value mapping, used for multilingual compatibility with old panels
    i18nKeyMap: {
      // Old multilingual key: New multilingual key
      rhythms_title: 'rhythms_title1',
    } as I18nKeys,
    countdownType: 'hourMinuteSecond',
    // If it is a cloud timer, you need to specify cloudTimerCategory, and the default is 'timer'
    switchDpCode: "switch_led", // custom power dp
    cloudTimerCategory: 'switch_led',
    // NoNature => Suitable for ceiling lamp UI style
    rhythmsType: ERhythmsType.Normal,
    // Jump to the route of the timed execution behavior, similar to /pages/xxx/index
    // timerActionRoute: '/pages/second/index',
    // The dp data passed by the page when the action is executed at regular intervals will obtain the corresponding dp value in the timerActionRoute page
    // timerActionOpenDpList: ['rtc_timer'],
  };

  navigateToSchedule(
    {
      deviceId,
      groupId,
    },
    transData,
    {
      timerDataChange: (res: { type: 'add' | 'delete' | 'edit' | 'cancel'; data: any }) => {
        // Here you can get the data when the timer operation changes
        console.warn('navigateTo timerDataChange res1:', res);
      },
    }
  );
};
```