On this page

ty.panel.initPanelKit

Initialize basic panel capabilities

  1. Initializes the basic capabilities of device panels. For example, register listeners of device or device group events. Without special requirements, you do not need to call the methods ty.device.registerDeviceListListener or ty.device.registerGroupChange in the business logic. For example, these methods are not needed if you do not require listeners for changes in data point (DP) status and details of other devices.
  2. Creates listeners for devices of going online or offline. If a device goes offline, a dialog box appears to show this event. Without special business requirements, you do not need to additionally develop the respective dialog box and business logic.

Type

Info

Either deviceId or groupId` must be provided.

type PanelKitInitConfig = {
  /**
   * @description The device ID.
   */
  deviceId?: string;
  /**
   * @description The device group ID.
   */
  groupId?: string;

  /**
   * @description Whether to use the default offline popup
   * @default true
   */
  useDefaultOffline: boolean;
  /**
   * Whether Bluetooth toast needs to cover the interface
   * @default false
   * @version 2.10.4
   */
  bleCover?: boolean;

  /**
   * @description After customizing the navigation bar, you need to configure the height
   * @default 0
   * @version 2.10.4
   */
  customTop?: string;

  /**
   * @description Whether to display a Bluetooth connection status prompt
   *
   * @default true
   * @version 2.10.4
   */
  showBLEToast?: boolean;

  /**
   * @description Bluetooth connection type. 0: Both the gateway and the app are required. The default value is that both the local and gateway channels are valid. 1: Only the app determines whether the local is online and whether the local connection is successful. 2: only the gateway is connected, and whether the gateway connection is successful
   * @default 0
   */
  bleConnectType?: number;
};

Request parameters

ParameterData typeDescriptionRequired
configPanelKitInitConfigInitializes the configurations of basic panel capabilities.Yes

Return parameters

None.

Sample request

ty.panel.initPanelKit({ deviceId: 'vdev1234567' });

Sample response

None.

Things to note

If you do not require custom multilingual settings for devices of getting offline, the following JSON settings are recommended. Specifically, you can go to Tuya Developer Platform > App > Multi-language or App Language, and configure desired multilingual settings.

{
  "en": {
    "openBle": "Enable System Bluetooth",
    "openBleShare": "Enable Bluetooth Sharing",
    "openBleShareStep": "Settings > Find Your App > Enable Bluetooth Sharing",
    "deviceOfflineHelpNew": "① Make sure that the device is powered on or that the battery capacity is sufficient.\n② Place the mobile phone as close as possible to the device.\n③ If the device has been connected to another mobile phone, close the connection and try to ",
    "offline_link": "reconnect the router.",
    "backToHome": "Homepage",
    "checkHelp": "View Help",
    "offline_alreadyOffline": "Offline Device",
    "offline_pleaseCheck": "Check the following items:",
    "offline_linkFront": "3. Whether the name or password of the router is modified. You can try to ",
    "offline_moreHelp": "More Help",
    "offline_textLinkMore": "",
    "bluetoothShareTip": "Limited functionality, please turn on \"Bluetooth Sharing\"",
    "bluetoothOfflineTip": "Enable Bluetooth on your mobile phone.",
    "deviceOffline": "Device Connection Failure"
  }
}