Gateway equipment, voice control devices, etc.
-
pushu
- Posts: 13
- Joined: 2022年 Nov 10日 15:06
This topic describes how to get the weather data to display on the screen. The weather service regularly updates the weather data.
Weather data
The SDK supports the following weather data. For more information, see tuya_weather_api.h
.
Name | Identifier | Description |
Temperature | TY_WEATHER_TEMP_STR | Unit: °C |
The highest temperature | TY_WEATHER_TEMP_MAX_STR | Unit: °C. This variable only applies to countries or regions outside mainland China. |
The lowest temperature | TY_WEATHER_TEMP_MIN_STR | Unit: °C. This variable only applies to countries or regions outside mainland China. |
Humidity | TY_WEATHER_HUMIDITY_STR | Unit: % |
Wind scale | TY_WEATHER_WIND_LEVEL_STR | Unit: Wind class. This variable only applies to mainland China. |
Fan speed | TY_WEATHER_WIND_SPEED_STR | Unit: m/s |
Wind direction | TY_WEATHER_WIND_DIR_STR | Wind direction |
Air quality index | TY_WEATHER_AIR_AQI_STR | This variable only applies to mainland China. |
PM2.5 index | TY_WEATHER_AIR_PM25_STR | Unit: µg/m³. This variable only applies to mainland China. |
Sulfur dioxide index | TY_WEATHER_AIR_SO2_STR | Unit: µg/m³. This variable only applies to mainland China. |
City | TY_WEATHER_CITY_STR | City |
Type of weather | TY_WEATHER_CONDITION_NUM_STR | Type of weather |
Initialize weather service
Function prototype | OPERATE_RET tuya_weather_init(VOID) |
Function description | Initialize weather service. |
Return value | OPERATE_RET , 0 : Success. Other values: Failure. See the error code. |
Detailed description | This function has been called in home_init_ex , so there is no need to manually call it. |
Get the data of all weather variables
Function prototype | OPERATE_RET tuya_weather_all_data_get(OUT TY_WEATHER_DATA_S **data, OUT UINT_T *count) |
Function description | Get the data of all weather variables. |
Parameter | data : The data of all weather variables. <br> count : The number of weather variables. |
Return value | OPERATE_RET , 0 : Success. Other values: Failure. See the error code. |
Detailed description | data is the successfully returned weather data. After the function call, call tuya_weather_data_free to free the allocated resources. |
Get the data of the specified weather variable
Function prototype | OPERATE_RET tuya_weather_single_data_get(IN CHAR_T *code, OUT TY_WEATHER_DATA_S **data) |
Function description | Get the data of the specified weather variable. |
Parameter | code : The identifier of the requested weather variable. |
Parameter | data : The returned weather data. |
Return value | OPERATE_RET , 0 : Success. Other values: Failure. See the error code. |
Detailed description | data is the successfully returned weather data. After the function call, call tuya_weather_data_free to free the allocated resources. |
Free the resources for weather data
Function prototype | OPERATE_RET tuya_weather_data_free(IN TY_WEATHER_DATA_S *data, IN CONST UINT_T count) |
Function description | Free the resources for weather data. |
Parameter | data : The weather data. |
Parameter | count : The number of weather variables. |
Return value | OPERATE_RET , 0 : Success. Other values: Failure. See the error code. |
Detailed description | Free the memory |
Update the weather data proactively
Function prototype | OPERATE_RET tuya_weather_sync(VOID) |
Function description | Update the weather data. |
Return value | OPERATE_RET , 0 : Success. Other values: Failure. See the error code. |
Detailed description | The weather data is updated 100 milliseconds after this interface is called. |