Outlets
A Power Meter Outlet switches one load on or off and measures its power. With the Write API, you can switch an outlet.
To read an outlet and its power, use the Read API. To add outlets and change schedules, use the Growbud app.
Address
Use the DevEUI on the outlet label, for example f50be8ffff9ddd81. Get the list with GET /sensing/v1/outlets.
GET /sensing/v1/outlets/f50be8ffff9ddd81
GET /sensing/v1/outlets/f50be8ffff9ddd81/power
POST /control/v1/outlets/f50be8ffff9ddd81/switch {"on": true}
Switch an outlet
POST .../switch with {"on": true} or {"on": false} sends one command. If the radio loses it, the Edge Server sends it 3 times maximum. After 60 s, the command times out.
Add "retry": true when your system needs the outlet to stay in that state, for example a pump or a fan. The Edge Server then sends commands until the outlet reports the state: 5 commands maximum, for 10 minutes maximum. The answer has desired.
{"on": true} | {"on": true, "retry": true} | |
|---|---|---|
| What it does | Sends one command | Keeps sending until the outlet reports the state |
| Limit | 3 sends, 60 s | 5 commands, 10 minutes |
| Use it for | One action that you monitor | A state that your system needs |
curl -sk -X POST -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
-d '{"on": true, "retry": true}' "$EDGE/control/v1/outlets/f50be8ffff9ddd81/switch?wait=30"
If the outlet already reports the state, the Edge Server sends nothing. A retry switch to the other state replaces the first one. The Edge Server keeps the state after a restart.
Wait for the result
Add ?wait=0 to 30 (seconds). You get 200 when the result is final in that time. If not, you get 202 and a poll path. A final result is not always a success. Read command.status.
| Command status | Meaning |
|---|---|
pending | stage is queued or sent. |
confirmed | The outlet reported the new state. |
refused | The outlet did not do the command. reason tells why. |
timed_out | No answer by expiresAt. A late answer can change it. |
failed | The Edge Server could not send the command. |
With retry, also read desired.status, in the answer or in GET /sensing/v1/outlets/{devEui} at outlet.switch.desired:
desired.status | Meaning | What to do |
|---|---|---|
converging | The Edge Server is sending commands. | Read the outlet again. |
converged | The outlet reported the state. | No action. |
failed | No report of the state after 5 commands or 10 minutes. | Read desired.error. Make sure that the outlet has a good signal. Send the switch again. |
superseded | A switch without retry or a schedule asked for the other state. | If you still need your state, send the switch with retry again. |
overridden | The outlet changed state without a command: its button, a power cut or a protection trip. The Edge Server does not change it back. | Find the cause, then send the switch with retry again. |
Errors
Errors are JSON: {"error": {"code", "message", "reason", "details"}}. On a standby Edge Server, a switch gets 409 managed_elsewhere. See Errors and limits.