Control Device State (/api/v1/state
)
P1 Meter
Not supported
Energy Socket
Supported
Energy Display
Not supported
kWh Meter
Not supported
Watermeter
Not supported
Plug-In Battery
Not supported
See Supported Devices for more information.
The /api/v1/state
endpoint returns the actual state of the Energy Socket.
This endpoint accepts GET
and PUT
requests.
- With
GET
you will receive the actual state - With
PUT
you can control the state.
Parameters
Data | Type | Description |
---|---|---|
power_on | Bool | The state of the switch. Returns true when the relay is in the 'on' state. |
switch_lock | Bool | When set to true , the socket cannot be turned off. |
brightness | Number | Brightness of LED ring when socket is 'on'. Value from 0 (0%) to 255 (100%). |
Examples
Get Actual State
This response tells that the socket is 'on', switch-lock is 'off' and the brightness of the LED ring is set to maximum.
Request
curl http://<IP ADDRESS>/api/v1/state
Response
HTTP/1.1 200 OK
Content-Type: application/json
{
"power_on": true,
"switch_lock": false,
"brightness": 255
}
Turn on Socket
Request
curl http://<IP ADDRESS>/api/v1/state \
-X PUT \
-H "Content-Type: application/json" \
-d '{"power_on": true}'
Response
HTTP/1.1 200 OK
Content-Type: application/json
{
"power_on": true
}
Turn on Switch-lock
After enabling switch_lock
, the socket is 'on' and cannot be turned off until switch_lock
is disabled.
Request
curl http://<IP ADDRESS>/api/v1/state \
-X PUT \
-H "Content-Type: application/json" \
-d '{"switch_lock": true}'
Response
HTTP/1.1 200 OK
Content-Type: application/json
{
"switch_lock": true
}
Set Multiple Parameters
You can configure multiple parameters at the same time. In this example.
- Socket is turned off.
- Switch-lock is turned off.
- Brightness is set to 127 (50%).
The order of a combined request does not matter, if switch-lock
was on, the socket will still turn off.
The complete state has to make sense; It is not possible to set power_on
to false and switch_lock
to true. See error handling for more details.
Request
curl http://<IP ADDRESS>/api/v1/state \
-X PUT \
-H "Content-Type: application/json" \
-d '{"power_on": false, "switch_lock": false, "brightness": 127}'
Response
HTTP/1.1 200 OK
Content-Type: application/json
{
"switch_lock": false,
"power_on": false,
"brightness": 127
}