Weather
warning
This interface has been deprecated, please refer to https://github.com/orgs/zepp-health/discussions/83
Start from API_LEVEL
2.0
. Please refer to API_LEVEL.
Weather Forecasts sensor.
Methods
getForecastWeather
Get weather forecast data
getForecastWeather(): ForecastWeather
ForecastWeather
Property | Type | Description | API_LEVEL |
---|---|---|---|
cityName | string | City Name | 2.0 |
forecastData | ForecastData | Weather Information | 2.0 |
tideData | TideData | Tide Information | 2.0 |
ForecastData
Property | Type | Description | API_LEVEL |
---|---|---|---|
data | Array<ForecastDataItem> | Weather Information Array, index 0 position represents the day | 2.0 |
count | number | The length of Weather Information Array | 2.0 |
ForecastDataItem
Property | Type | Description | API_LEVEL |
---|---|---|---|
high | number | Maximum temperature | 2.0 |
low | number | Lowest temperature | 2.0 |
index | number | The index value of the weather, see index below for a description of the value | 2.0 |
index
Value | Type | Description | API_LEVEL |
---|---|---|---|
0 | number | Cloudy | 2.0 |
1 | number | Showers | 2.0 |
2 | number | Snow Showers | 2.0 |
3 | number | Sunny | 2.0 |
4 | number | Overcast | 2.0 |
5 | number | Light Rain | 2.0 |
6 | number | Light Snow | 2.0 |
7 | number | Moderate Rain | 2.0 |
8 | number | Moderate Snow | 2.0 |
9 | number | Heavy Snow | 2.0 |
10 | number | Heavy Rain | 2.0 |
11 | number | Sandstorm | 2.0 |
12 | number | Rain and Snow | 2.0 |
13 | number | Fog | 2.0 |
14 | number | Hazy | 2.0 |
15 | number | T-Storms | 2.0 |
16 | number | Snowstorm | 2.0 |
17 | number | Floating dust | 2.0 |
18 | number | Very Heavy Rainstorm | 2.0 |
19 | number | Rain and Hail | 2.0 |
20 | number | T-Storms and Hail | 2.0 |
21 | number | Heavy Rainstorm | 2.0 |
22 | number | Dust | 2.0 |
23 | number | Heavy sand storm | 2.0 |
24 | number | Rainstorm | 2.0 |
25 | number | Unknown | 2.0 |
26 | number | Cloudy Nighttime | 2.0 |
27 | number | Showers Nighttime | 2.0 |
28 | number | Sunny Nighttime | 2.0 |
TideData
Property | Type | Description | API_LEVEL |
---|---|---|---|
data | Array<TideDataItem> | Tide Information Array, index 0 position represents the day | 2.0 |
count | number | The length of Tide Information Array | 2.0 |
TideDataItem
Property | Type | Description | API_LEVEL |
---|---|---|---|
sunrise | Sunrise | Sunrise time | 2.0 |
sunset | Sunset | Sunset time | 2.0 |
Sunrise
Property | Type | Description | API_LEVEL |
---|---|---|---|
hour | number | Sunrise time - hour | 2.0 |
minute | number | Sunrise time - minute | 2.0 |
Sunset
Property | Type | Description | API_LEVEL |
---|---|---|---|
hour | number | Sunrise time - hour | 2.0 |
minute | number | Sunrise time - minute | 2.0 |
Example
import { Weather } from '@zos/sensor'
const weather = new Weather()
const { forecastData, tideData, cityName } = weather.getForecast()
console.log(cityName)
for (let i = 0; i < forecastData.count; i++) {
const element = forecastData.data[i]
console.log('Index' + element.index)
console.log('Highest temperature' + element.high)
console.log('Lowest temperature' + element.low)
}
for (let i = 0; i < tideData.count; i++) {
const element = tideData.data[i]
console.log('Sunrise' + element.sunrise.hour + element.sunrise.minute)
console.log('Sunset' + element.sunset.hour + element.sunset.minute)
}