getWeatherDailyHistory(data: GetWeatherDailyHistoryParams)

版本要求:
@tuya-miniapp/cloud-api≥1.0.5

描述

根据设备 id 查询历史天气

参数

参数类型必填说明
是请求体

返回值

类型:Promise<Record<string, Weather>>
GetWeatherDailyHistoryResult(键为 YYYY-MM-DD 日期字符串,值为该日 Weather 对象;字段含义见类型定义与 minituya 返回参数)

引用对象

interfaceWeather单日天气字段集合:`date`、`localDate` 与文档一致;其余键为请求的 `weatherFieldNames` 对应取值。
属性类型描述
datestringformatDate,例如 2023-10-24
localDatenumber时间戳,例如 1698076800000

示例代码

请求示例

import { getWeatherDailyHistory } from '@tuya-miniapp/cloud-api';

getWeatherDailyHistory({
  devId: '6cbed8370dd694e247uk9u',
  ip: '',
  weatherFieldNames: 'pm25',
  beginTime: 1698028537000,
  endTime: 1698287737698,
})
  .then((response) => {
    console.log(response);
  })
  .catch();

返回示例

{
  "2023-10-24": {
    "date": "2023-10-24",
    "localDate": 1698076800000,
    "pm25": "31.82"
  },
  "2023-10-25": {
    "date": "2023-10-25",
    "localDate": 1698163200000,
    "pm25": "50.93"
  }
}