saveDeviceCurrency(params: SaveDeviceCurrencyParams)

Requires:
@tuya-miniapp/cloud-api≥1.3.0

Description

Save or update the device currency configuration. After saving, subsequent electricity cost data will be displayed in the new currency; historical data will not be converted.

Parameters

ParameterTypeRequiredDescription
YesRequest parameters

Return Value

Type: Promise<boolean>
Whether the save was successful

Examples

Request example

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

saveDeviceCurrency({ devId: 'vdevo123', currency: 'CNY' })
  .then(result => {
    console.log('Currency configuration saved successfully:', result);
  })
  .catch(error => {
    console.error('Failed to save currency configuration:', error);
  });

Response example

true

FAQ

Why does the call to cloud capabilities fail?

Before using this API, please ensure that the product to which the device belongs has enabled the Electricity Statistics advanced capability on the Tuya IoT Development Platform. Products without this capability enabled cannot collect electricity consumption/cost data, and the API will return empty data or an error. If you need to use it, please create a product with electricity consumption/cost statistics functions and enable the corresponding advanced capabilities in the product details. At the same time, the API depends on cloud capabilities, and authorization configuration is required in Development Settings - Cloud Capabilities on the Mini Program Developer Platform.