【Share】TuyaOS Central Control Global Subscription

Gateway equipment, voice control devices, etc.


Post Reply
lightthgil
Posts: 39

Generally, when the central control SDK controls the device and obtains information, it needs to call tuya_home_ctrl_dev_open to obtain the device handle first, and then operate the device. This method will occupy some memory in the process of obtaining the handle; at the same time, the mapping relationship between the handle and the device dev_id also requires the application layer to store the corresponding relationship. Therefore, the SDK provides some global interfaces for some frequently used features.

Code: Select all

tuya_home_ctrl_subscribe_dev_online //Subscribe to device online and offline events
tuya_home_ctrl_subscribe_dev_shortcut //Subscribe to device shortcut switch events
tuya_home_ctrl_subscribe_dp_name_update //Subscribe to device dp name change events
tuya_home_ctrl_subscribe_dev_change //Subscribe to device add/delete/change/sync events
tuya_home_ctrl_subscribe_dev_icon_update //Subscribe to device icon update events
tuya_home_ctrl_subscribe_dev_name_update //Subscribe to device name update events
tuya_home_ctrl_subscribe_scene_change //Subscribe to scene add/delete events
tuya_home_ctrl_subscribe_scene_icon_update //Subscribe to scene icon update events
tuya_home_ctrl_subscribe_scene_name_update //Subscribe to scene name update events
tuya_home_ctrl_subscribe_dev_dps_update //Subscribe to device instruction set update events
tuya_home_ctrl_subscribe_room_change //Subscribe to room change events

In particular, for tuya_home_ctrl_subscribe_dev_change and tuya_home_ctrl_subscribe_scene_change, notifications of synchronization events of devices and scenes are also provided, which can replace the original cbs.all_info_sync_cb in tuya_home_init_ex. The original synchronization interface, in many cases, such as device image changes, device name changes, device additions and deletions, will be pushed back, causing the application layer to update all device information multiple times, which will affect the efficiency of the application layer. Therefore, the above interface can be used to accept refined push and only update data for changed devices. At the same time, in order to be compatible with the original code, cbs.all_info_sync_cb in tuya_home_init_ex is also pushed at the same time. If you want to make a refined push modification, you can ignore the push of cbs.all_info_sync_cb in tuya_home_init_ex

Post Reply