Panel Environment Initialization
initPanelEnvironment is a standard environment initialization tool for Tuya Panel MiniApps. It is not just an API, but an integrated implementation of Tuya panel standard interaction specifications. Through a one-click call, developers can quickly access a series of standardized capabilities such as offline, Bluetooth, OTA, and fault reminders for the panel.
DeviceKit must be introduced, and the @ray-js/ray version must be higher than 0.10.3.
Quick Start
Calling it as early as possible at the application entry or the main page of the panel will enable the standard environment (current Panel MiniApp templates already have this API call built-in):
Core Capabilities
The initPanelEnvironment API deeply integrates the following standard interaction capabilities:
1. Connectivity and Offline Guarantee
Real-time monitoring of device online status. Provides offline mask guidance for Wi-Fi devices; provides automatic reconnection, permission detection, and status floating window display for Bluetooth devices.
2. OTA Upgrade Check
Real-time detection of device firmware updates and guiding users to upgrade based on priority (mandatory/reminder).
Details: OTA Upgrade Mechanism Description
3. Cloud Activation and Device Monitoring
- Cloud Activation: For devices requiring activation, a prompt automatically pops up after entering the panel.
- Basic Monitoring: Automatically register basic monitoring such as device removal and status changes, simplifying business complexity.
4. Fault List Component
When the device supports and reports function points of type fault, the standard fault list description automatically pops up. Currently only supports function points with dpCode as fault.
Technical Reference
Type Definition
Parameter Details
bleCover
Whether to add an overlay to block interface interaction when the Bluetooth status floating window is displayed. Usually, if some functions can be used when the device is offline (such as: data chart viewing), the interface does not need to be covered.
customTop
When using a custom status bar, the distance between the Bluetooth status floating window and the top can be customized through this property. This parameter accepts standard CSS length values (such as: '100px', '10%', etc.).
bleConnectType
In the standard logic, selection of network connection methods for Bluetooth devices:
- 0: Try both phone direct connection and gateway connection (default).
- 1: Only use phone direct connection.
- 2: Only use gateway connection.
showBLEToast
Whether to display a Toast prompt when the Bluetooth device connection is successful or fails.
showFault
If set to true, the built-in capability is used to display device faults. Currently only supports fault display for dpCode as fault.
Underlying Atomic Implementation
initPanelEnvironment is deeply encapsulated based on the following underlying APIs:
- ty.panel.initPanelKit
- registerDeviceListListener
- getDeviceInfo
- getSystemInfoSync
- authorizeStatus
- openMiniWidget
- onWidgetDismiss
- offWidgetDismiss
- dismissMiniWidget
- authorize
- getDeviceOnlineType
- connectBluetoothDevice
- subscribeBLEConnectStatus
- onBLEConnectStatusChange
- onBluetoothAdapterStateChange
Precautions
- Standardized Logic Recommendation: The logic provided by
initPanelEnvironmentis the standard specification of Tuya panels. We recommend that developers prioritize using this interface and only refer to atomic interfaces for customization in special scenarios. - OTA Logic Enclosure: The OTA upgrade mechanism (detection, pop-ups, and jumps) currently does not support developer customization. Please be sure to complete it through the built-in capabilities.