Get started
  • English
  • 简体中文
Official Site
Get started
  • English
  • 简体中文
Official Site
  • Get started
  • Concepts
  • Guides
  • Device capabilities & events
    • Browse by device type
    • Device capabilities
      • Common methods
      • Detection and alarms
      • Image
      • PTZ
      • Light
      • Recording
      • Audio
      • Media
      • Network
      • Power
        • Battery
        • Power saving / supply mode
          • power.mode.mode (Get power mode property)
          • power.mode.mode (Set power mode property)
          • power.mode.autoConstant (Get auto always-on property)
          • power.mode.autoConstant (Set auto always-on property)
          • power.mode.autoSave (Get auto power-saving property)
          • power.mode.autoSave (Set auto power-saving property)
          • power.mode.enterThreshold (Get enter power-mode threshold property)
          • power.mode.enterThreshold (Set enter power-mode threshold property)
          • power.mode.saveThreshold (Get power-saving level threshold property)
          • power.mode.saveThreshold (Set power-saving level threshold property)
          • power.mode.supplyState (Get device supply state property)
          • power.mode.state (Get power state property)
          • power.mode.vlog (Get VLog recording property)
          • power.mode.vlog (Set VLog recording property)
          • power.mode.switch (Supply state switch)
          • power.mode.changed (Power mode changed)
        • Sleep and wake
        • Outlet metering
      • Privacy
      • Call
      • Storage
      • System
      • Algorithm
      • Maintenance
      • Control
    • Events overview
    • Permission codes
    • Capability error codes
    • Alarm and capability messages
    • Capability FAQ
    • Legacy ability and push types
  • API reference
  • SDK and tools
  • Solutions
  • Platform and support
On this page
What it does
Request URL
Minimum permission
Request parameters
Request example
Response data fields
Response example
Error codes

power.mode.switch (Supply state switch)

power.mode.switch: Supply state switch

power.mode.switch · device scope · permission Config

What it does

Switches this device's supply state. Input is only inputData.work (0 battery, 1 adapter); model is output (power mode enum 2–14 after switch; see response). Returns ret: 0 success, 1 failure (switch to always-on without adapter plugged). Before and after, you can read Device supply state. Each call runs once.

Request URL

POST https://openapi-[DataCenter].easy4ip.com/openapi/v2/device.service.invoke

Minimum permission

The administrator does not need an extra permission on a device they bound. A shared device needs one of the capability row share_auth_code aliases (match the console share grant). See Permission codes. A bound sub-user does not. A sub-account needs Config. A timeout does not mean the action failed.

Request parameters

NameTypeRequiredDescription
tokenStringyesAccess token for an administrator, sub-user, or sub-account
deviceIdStringyesDevice serial number
productIdStringnoOptional. If sent and it does not match the device model → DV2009
serviceIdStringyespower.mode.switch
inputDataObjectyessee table below
NameDescriptionTypeRequiredValues
workMode. 0 battery, 1 adapter.enumyes0 battery; 1 adapter

For common request fields and signing, see Signing conventions and Common request payload.

JSON shape: Scalar enum/int values in OpenAPI may be string or number (device/TSL dependent). Examples below use one shape; the other may also be accepted—follow what the device returns.

Request example

{
 "id": "d5c287b4-5b2f-4f03-baf5-8032c5c354af",
 "system": {
 "ver": "1.0",
 "appId": "lcdxxxxxxxxx",
 "sign": "xjhCQBoJ9hRDsCjyDcHjtDNzRZ3ZJezcawsfWeiaoxU=",
 "time": 1706511734,
 "nonce": "f5a1ae2d-c09c-4d39-a744-83a5c2c653c2"
 },
 "params": {
 "token": "<yourAccessToken>",
 "deviceId": "TESTIPC000012345",
 "serviceId": "power.mode.switch",
 "inputData": {
 "work": "0"
 }
 }
}

Response data fields

Output is in result.data.outputData.

NameDescriptionTypeRequiredValues
modelPower mode after switch.enumno2 ultra power saving; 5 high performance; 6 custom; 7 standard; 8 continuous recording; 9 vlog recording; 10 AOV mode; 11 event recording; 12 smart schedule mode; 13 manual snapshot recording mode; 14 always-on power mode
retResult. 0 success, 1 failure (always-on without adapter).enumno0 success; 1 failure, always-on without adapter

Response example

{
 "id": "d5c287b4-5b2f-4f03-baf5-8032c5c354af",
 "result": {
 "code": "0",
 "msg": "Operation is successful",
 "data": {
 "outputData": {
 "model": "7",
 "ret": "0"
 }
 }
 }
}

Error codes

CodeMeaningNext step
SN1001Signature errorCheck sign per Development specification
TK1002Token invalid or expiredRefresh accessToken
OP1002Missing required parameterAdd required fields
OP1003Invalid parameterMatch this page’s parameter table
OP1009Permission deniedCheck token and device bind/share grants
OP1013Total call limit exceededReduce call rate
OP1014Daily per-interface limit exceededSee Interface call limits
DV1007Device offlineWait until the device is online

See Return codes · OP/SN/TK for the full catalog.

CodeMeaningNext step
DV2003Capability not on deviceUse device.capability.list
DV2007channelId vs scope mismatchRequired for channel scope; omit for device scope
DV2008Mixed device and channel in one callSplit the request
DV2009productId mismatchOmit or set actual model id
DV2011No capability permissionSee Permission codes

See Capability errors.

Power saving / supply mode

power.mode.vlog (Set VLog recording property)
power.mode.changed (Power mode changed)