API: Device type commands

From Yombo
Jump to: navigation, search

Summary

Each device type can have it’s own list of commands. For example, an appliance module or relay can only turn on and off, and will have those two commands associated with that device type.

GET - All device types

Retrieve all device types available to the current user.

Filters

List of available filters:

  • device_type_id
  • command_id

Request URLs

  • GET https://api.yombo.net/api/v1/device_type_command

Parameters

None

Example

  <div id="curl<random_number></random_number>" class="tab-pane fade in active" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
curl \
-H "x-api-key: abc123xyz789" \
-H "authorization: Bearer Waro7g0Mwl4YBJ..." \
https://api.yombo.net/api/v1/device_type_command?_pagelimit=2
  <div id="python<random_number></random_number>" class="tab-pane fade" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
import requests

url = 'https://api.yombo.net/api/v1/device_type_command?_pagelimit=2'
headers = {
    'x-api-key': 'abc123xyz789',
    'authorization': 'Waro7g0Mwl4YBJ...',
    }
response = requests.get(url, headers=headers)
  <div id="output<random_number></random_number>" class="tab-pane fade" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
 1 {
 2     "response": {
 3         "uri": "/api/v1/device_type_command?_pagelimit=2",
 4         "uri_description": "Map of device types to commands.",
 5         "doc_uri": "https://yombo.net/API:Device_type_commands",
 6         "device_type_command": [
 7             {
 8                 "id": "g0aYKR4v",
 9                 "device_type_id": "pyXnExEL",
10                 "command_id": "aWvzB0ENZ23JO",
11                 "created_at": 1482065387,
12                 "command_label": "On",
13                 "command_machine_label": "on",
14                 "device_type_label": "X10 Lamp",
15                 "device_type_machine_label": "x10_lamp"
16             },
17             {
18                 "id": "GpRj0a0g",
19                 "device_type_id": "pyXnExEL",
20                 "command_id": "6qBJKkN6kw3nW",
21                 "created_at": 1482065387,
22                 "command_label": "Off",
23                 "command_machine_label": "off",
24                 "device_type_label": "X10 Lamp",
25                 "device_type_machine_label": "x10_lamp"
26             }
27         ],
28         "locator": "device_type_command",
29         "locator_type": "objects"
30     },
31     "code": 200,
32     "warnings": [],
33     "pages": {
34         "total_items": 62,
35         "page_limit": 2,
36         "total_pages": 31,
37         "page_start": 1
38     },
39     "message": "OK",
40     "html_message": "OK"
41 }

GET - Specific device type command

Retrieve a specific device_type id. There are two ways to retrieve a single device type command:

  1. Using just the device type command id - Allows directly looking up information.
  2. Using the device type and command id - Search for the device type command.

Request URLs

  • GET https://api.yombo.net/api/v1/device_type_command/{device_type_command_id}
  • GET https://api.yombo.net/api/v1/device_type_command/{device_type_id}/{command_id}

Parameters

None

Example

Both search methods return the same results.

  <div id="curl<random_number></random_number>" class="tab-pane fade in active" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
curl \
-H "x-api-key: abc123xyz789" \
-H "authorization: Bearer Waro7g0Mwl4YBJ..." \
https://api.yombo.net/api/v1/device_type_command/j2z8GQl4qwMgbJxGQl4qwM6
  <div id="python<random_number></random_number>" class="tab-pane fade" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
import requests

url = 'https://api.yombo.net/api/v1/device_type_command/j2z8GQl4qwMgbJxGQl4qwM6
headers = {
    'x-api-key': 'abc123xyz789',
    'authorization': 'Waro7g0Mwl4YBJ...',
    }
response = requests.get(url, headers=headers)
  <div id="output<random_number></random_number>" class="tab-pane fade" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
 1 {
 2     "response": {
 3         "uri": "/api/v1/device_type_command/g0aYKR4v",
 4         "uri_description": "A single device type command.",
 5         "doc_uri": "https://yombo.net/docs/api/devicetypes/",
 6         "device_type_command": {
 7             "id": "g0aYKR4v",
 8             "device_type_id": "pyXnExEL",
 9             "command_id": "aWvzB0ENZ23JO",
10             "created_at": 1482065387,
11             "command_label": "On",
12             "command_machine_label": "on",
13             "device_type_label": "X10 Lamp",
14             "device_type_machine_label": "x10_lamp"
15         },
16         "locator": "device_type_command",
17         "locator_type": "object"
18     },
19     "code": 200,
20     "warnings": [],
21     "message": "OK",
22     "html_message": "OK"
23 }

POST - Create new device type command

Creates a new device type command mapping. You must have access modify the device type in order to complete this.

Request URLs

  • POST https://api.yombo.net/api/v1/device_type_command

Parameters

Name Type Description
Required
device_type_id string Device type to map.
command_id string Command id to map to a device type.

Example

  <div id="curl<random_number></random_number>" class="tab-pane fade in active" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
curl \
-H "x-api-key: abc123xyz789" \
-H "authorization: Bearer Waro7g0Mwl4YBJ..." \
-X POST -d '{"device_type_id": "QAJqr8xZ", "command_id": "aWvzB0ENZ23JO"}' \
https://api.yombo.net/api/v1/device_type_command
  <div id="python<random_number></random_number>" class="tab-pane fade" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
import requests

url = 'https://api.yombo.net/api/v1/device_type_command'
headers = {
    'x-api-key': 'abc123xyz789',
    'authorization': 'Waro7g0Mwl4YBJ...',
    }

payload = {
    "device_type_id": "QAJqr8xZ",
    "command_id": "aWvzB0ENZ23JO",
    }

response = requests.post(url, headers=headers, json=payload)
  <div id="output<random_number></random_number>" class="tab-pane fade" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
 1 {
 2     "response": {
 3         "uri": "/api/v1/device_type_command",
 4         "uri_description": "Map of device types to commands.",
 5         "doc_uri": "https://yombo.net/API:Device_type_commands",
 6         "device_type_command": {
 7             "id": "rkRpyl1z",
 8             "device_type_id": "QAJqr8xZ",
 9             "command_id": "aWvzB0ENZ23JO",
10             "created_at": 1518574937,
11             "command_label": "On",
12             "command_machine_label": "on",
13             "device_type_label": "Cleaning Robot",
14             "device_type_machine_label": "cleaning_robot"
15         },
16         "locator": "device_type_command",
17         "locator_type": "object"
18     },
19     "code": 201,
20     "warnings": [],
21     "message": "Created",
22     "html_message": "Created"
23 }

DELETE - Delete a device type command

Delete a device type command mapping.

Request URLs

Both URLs perform the same action.

  • DELETE https://api.yombo.net/api/v1/device_type_command/{device_type_command_id}
  • DELETE https://api.yombo.net/api/v1/device_type_command/{device_type_id}/{command_id}

Parameters

None

Example

  <div id="curl<random_number></random_number>" class="tab-pane fade in active" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
curl \
-H "x-api-key: abc123xyz789" \
-H "authorization: Bearer Waro7g0Mwl4YBJ..." \
-X DELETE https://api.yombo.net/api/v1/device_type_command/rkRpyl1z
  <div id="python<random_number></random_number>" class="tab-pane fade" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
import requests

url = 'https://api.yombo.net/api/v1/device_type_command/rkRpyl1z'
headers = {
    'x-api-key': 'abc123xyz789',
    'authorization': 'Waro7g0Mwl4YBJ...',
    }

response = requests.put(url, headers=headers)
  <div id="output<random_number></random_number>" class="tab-pane fade" style="border: 1px solid #ccc; border-radius: 5px; padding: 0.7em;">
 1 {
 2     "response": {
 3         "uri": "/api/v1/device_type_command/rkRpyl1z",
 4         "uri_description": "Delete a device type to command mapping.",
 5         "doc_uri": "https://yombo.net/API:Device_type_commands",
 6         "device_type_command": "Deleted",
 7         "locator": "device_type_command",
 8         "locator_type": "string"
 9     },
10     "code": 200,
11     "warnings": [],
12     "pages": {
13         "total_items": 58,
14         "page_limit": 300,
15         "total_pages": 1,
16         "page_start": 1
17     },
18     "message": "Deleted",
19     "html_message": "Deleted"
20 }
This page was last edited on 14 September 2018.