Skip to main content
Version: v3

Stress

Start from API_LEVEL 2.0 . Please refer to API_LEVEL.

Stress Sensor.

info

permission code: data:user.hd.stress

Methods

getCurrent

Get the current pressure measurement

getCurrent(): Result

Result

PropertyTypeDescriptionAPI_LEVEL
valuenumberStress measurement values2.0
timenumberTime to obtain the measured value2.0

onChange

Register a callback function to listen for stress measurement change events

onChange(callback: () => void): void

offChange

Cancel a callback function to listen for stress measurement change events

offChange(callback: () => void): void

getToday

Start from API_LEVEL 3.0

Get the pressure measurements for the whole day, recorded every minute, the return value is an array of variable length, the maximum length of the array is 24 * 60

getToday(): Array<number>

StressInfo

PropertyTypeDescriptionAPI_LEVEL
secondnumberPressure value measurement time, UTC time stamp, in seconds3.0
stressnumberPressure value, 0 means invalid3.0

getTodayByHour

Start from API_LEVEL 3.0

Get the average pressure value for the whole day, the return value is a fixed-length array, the average pressure for each hour, the length of the array is 24

getTodayByHour(): Array<number>

getLastWeek

Start from API_LEVEL 3.0

Get the average pressure value for each day of the past week, the return value is a fixed-length array, the average pressure per day, the length of the array is 7, the position of index 0 represents six days ago, the position of index 6 represents today

getLastWeek(): Array<number>

getLastWeekByHour

Start from API_LEVEL 3.0

Get the hourly pressure average for the past week, the return value is a fixed-length array, the length of the array is 7 * 24

getLastWeekByHour(): Array<StressInfo>

StressInfo

PropertyTypeDescriptionAPI_LEVEL
secondnumberPressure value measurement time, UTC time stamp, in seconds3.0
stressnumberPressure value, 0 means invalid3.0

Example

import { Stress } from '@zos/sensor'

const stress = new Stress()
const { value } = stress.getCurrent()

const callback = () => {
console.log(stress.getCurrent())
}

stress.onChange(callback)

// When not needed for use
stress.offChange(callback)