Event event4+
Interface Declaration
Import Module
Interface Definition
event.publish (OBJECT)
Publish a public event.
Parameters:
| Parameter Name | Type | Required | Description |
| eventName | String | Yes | Event name. Reserved names for public events are occupied by the system and should not be used. |
| options | Object | No | Event parameters |
options Parameters:
| Parameter Name | Type | Required | Description |
| params | Object | No | Event parameters |
| permissions | Array<String> | No | Permissions for subscribers. Only packages with permissions can receive the sent event. |
Public Events Supported by the System:
| System Internal Event Name | Permissions Required for Subscribers | Description |
| usual.event.BATTERY_CHANGED | None | Battery level change. Parameter: level: between 0.0 and 1.0 |
| usual.event.DISCHARGING | None | Stop charging |
| usual.event.CHARGING | None | Start charging |
Return Value:
None
Example:
event.subscribe(OBJECT)
Subscribe to a public event.
Parameters:
| Parameter Name | Type | Required | Description |
| eventName | String | Yes | Event name |
| callback | Function | Yes | Callback function |
Callback Parameters:
| Parameter Name | Type | Required | Description |
| params | Object | No | Event parameters |
| package | String | No | Package name of the event sender |
Return Value:
| Type | Required | Description |
| Number | Yes | Event ID. Returns undefined if subscription fails. |
Example:
event.unsubscribe(OBJECT)
Cancel subscription to a public event.
Parameters:
| Parameter Name | Type | Required | Description |
| id | Number | Yes | Subscription ID |
Example:
Support Details
| Device Product | Description |
| Xiaomi S1 Pro Sports and Health Watch | Not supported |
| Xiaomi Band 8 Pro | Not supported |
| Xiaomi Band 9 / 9 Pro | Not supported |
| Xiaomi Watch S3 | Not supported |
| Redmi Watch 4 | Not supported |
| Xiaomi Wrist ECG Blood Pressure Monitor | Not supported |
| Xiaomi Band 10 | Supported |
| Xiaomi Watch S4 | Supported |
| REDMI Watch 5 | Supported |