Examples

In the following example, we want to switch a light by using the REST API.

Before we can start, we have to make sure that the preparations for authentification are done (see topic "Preparation" and "Authentification"). With the received token, we are now able to send all requests and commands.

At first we send a GET request to `"http://[evon Smart Home_IP]/api/instances" and receive a list with all instances, which are currently active in the evon Smart Home system.


"statusCode": 200,
"statusText": "success",
"data": [
{
"ID": "SC1_M04.Light1",
"ClassName": "SmartCOM.Light.Light",
"Name": "Roomlight",
Group": "AreaOutdoor
},
...
]
}```

As we want to switch a light, we choose the 'Roomlight' and use its "ClassName": "SmartCOM.Light.Light" to send a GET request to `"http://[evon Smart Home_IP]/api/apps/SmartCOM.Light.Light"` and receive the available methods and properties.

```{
"statusCode": 200,
"statusText": "success",
"data": {
"methods": [
{
"parameter": [],
"name": "SwitchOn",
"type": 0,
"derived": false,
"tags": [
linkable
],
"returnType": "void",
"description": "switch light on",
"isStatic": false
},
...
],
"properties": [
{
"name": "IsOn",
"type": "boolean",
"remark": "light switched on",
"declaration": "2",
"derived": true,
"parameter": false,
"tags": [
linkable
],
"isStatic": false
},
...
],
"fullName": "SmartCOM.Light.Light",
"displayName": "Light",
"autoStart": false
}
}```

We are now sending a POST request to `"http://[evon Smart Home_IP]/api/instances/SC1_M04.Light1/SwitchOn"` with the following parameters in the header:
- instanceId: SC1_M04.Light1
- action: SwitchOn
- body: [ ]

This will call the specified method of the light and switch it on. We can also check the current status by sending a GET request to `"http://[evon Smart Home_IP]/api/instances/SC1_M04.Light1/IsOn"` and receive a response containing the current status, in this case 'true'.

```{
"statusCode": 200,
"statusText": "success",
"data": true
}```