In order to control and monitor devices, the user must discover and add the devices to their account.
Some devices (zigbee, insteon, etc) require a gateway, in that case the user must first discover and link a gateway and then they can start discovering the devices to join the gateway
Discovering Gateways and WiFi devices
Request:
curl -X POST \ https://api.smartenit.io/v2/devices/discover \ -H 'Authorization: Bearer YOUR_ACCESS_TOKEN'
Response:
{ "data": [{ "_id": "5759a2c6fb73933d7b513bf2", "updatedAt": "2016-06-02T18:52:32.397Z", "createdAt": "2016-05-12T15:55:50.498Z", "name": "Demo 2 Harmony G2", "type": "gateway", "cognitoIdentityId": "us-east-1:b999aef9-26d8-4de6-9bdf-de4d3786f1e2", "parents": {}, "interfaces": [{ "updatedAt": "2016-05-12T15:55:50.498Z", "createdAt": "2016-05-12T15:55:50.498Z", "name": "eth0", "xIp": "186.82.139.246", "ip": "192.168.0.9", "mac": "d8:1c:14:76:55:41" }], "components": [], "areas": [], "topic": null, "accountId": null }] }
Linking the Gateways and WiFi devices to your account
Once a Gateway or Wi-Fi device is discovered it can be linked to a specific account.
Request:
curl -X POST \ https://api.smartenit.io/v2/devices/link \ -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \ -H 'Content-Type: application/json' \ -d '{ "deviceId": "5759a2c6fb73933d7b513bf2" }'
Response:
{ "data": { "_id": "5759a2c6fb73933d7b513bf2", "updatedAt": "2016-06-09T17:10:09.717Z", "createdAt": "2016-05-12T15:55:50.498Z", "name": "Demo 2 Harmony G2", "type": "gateway", "cognitoIdentityId": "us-east-1:b999aef9-26d8-4de6-9bdf-de4d3786f1e2", "parents": { "areas": [{ "updatedAt": "2016-06-09T17:10:09.717Z", "createdAt": "2016-06-09T17:10:09.717Z", "name": "JJ Home edited in the cloud once again", "id": "5734aae57db63447398fcabf" }] }, "interfaces": [{ "updatedAt": "2016-05-12T15:55:50.498Z", "createdAt": "2016-05-12T15:55:50.498Z", "name": "eth0", "xIp": "186.82.139.246", "ip": "192.168.0.9", "mac": "d8:1c:14:76:55:41" }], "components": [], "areas": [], "topic": null, "accountId": "56f084a4abd086104ce22895" } }
Discover and link devices through a Gateway
For devices that do not connect to a cloud directly, a gateway is required. Once you have added the gateway and are ready to discover ( also called pair, link, and join) the devices, follow the steps below.
A single method is used for discovery regardless of the protocols of the interfaces attached to the gateway. The interfaces currently supported are: Smartenit USB-CID (ZigBee-HA), Smartenit ZOE-VIPD (ZigBee-SE), Smartenit ZBPLM (ZigBee-HA, INSTEON and X10) and Smartenit EZIComm (INSTEON and X10). With this in mind, the endpoint for devices will have an entry for the gateway which will have a component per interface.
A gateway with two different interfaces (ZBP CID and VIPD) will have two different components. Each component will have a Discover processor which can be used as follow:
Request:
1 2 3 4 5 6 7 8 | curl -X GET -k --header 'Accept: application/json' --header 'Content-Type: application/json' --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' -d '{"duration":250}' Note: for Local API substitute with https: //YOUR_GW_LOCAL_DOMAIN:54443/v2/ |
Response:
{ "code" : 200, "success" : true } |
The discover method has to be sent to each interface in the device if it is desired to be in Discovery mode. When a zigbee or Insteon device joins the gateway interface, then it will be automatically added to the users account.