DIY-IOT: The API

This article is a part of the DIY-IOT series.

API Description

The access is restricted by HTTP Digest

The credentials are:
Username: XXX
Password: XXX

The structure os an API command:
https://domæne.dk/control.php?action=<ACTION>&device=<DEVICE>

Where ACTION can take following values (case sensitive!):
ON : Turn on the device
OFF : Turn off the device
STATUS : Return if the device is on or off

And DEVICE is the power outlet in question. Two devices are supported, so DEVICE can take values 1 and 2.

Examples:

Turn on the first device:

https://domæne.dk/control.php?action=ON&device=1
Return value:
DEVICE_1_ON

Turn off the first device:

https://domæne.dk/control.php?action=OFF&device=1
Return value:
DEVICE_1_OFF

Ask for status on the first device:
https://domæne.dk/control.php?action=OFF&device=1
Return value:

DEVICE_1_ON or DEVICE_1_OFF

Error messages:

API_ERROR
Wrong value in ‘action ‘ or ‘device’. E.g. “action=status” will return API_ERROR, where “action=STATUS” is correct.

WRONG_CREDENTIALS
Wrong username or password.

UNAUTHORIZED
Digest information missing in the HTTP header of the request

SYSTEM_ERROR
API is correct, but someting inside the box went haywire.

INVALID_DEVICE
Wrong device. Only device=1 or 2 is supported