API: Device types

From Yombo
Jump to: navigation, search

Summary

A device type defines what commands can be used for a certain device. For example, lamp modules can be turned on, off, set to a brightness level, or a few other types of commands. Device types are added to modules to determine what devices a module can manage.

GET - All device types

Retrieve all device types available to the current user.

Filters

List of available filters:

  • label
  • machine_label
  • description
  • public
  • status
  • created_at
  • updated_at

Request URLs

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

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?_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?_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?_pagelimit=2",
  4         "uri_description": "List of device types. ",
  5         "doc_uri": "https://yombo.net/API:Device_types",
  6         "device_type": [
  7             {
  8                 "id": "7BxzOXpb",
  9                 "category_id": "dD8X67zW",
 10                 "machine_label": "x10_house",
 11                 "label": "X10 House Code",
 12                 "description": "Send an X10 housecode - A single letter A-P.",
 13                 "platform": null,
 14                 "public": 2,
 15                 "status": 1,
 16                 "created_at": 1482065387,
 17                 "updated_at": 1482065387,
 18                 "variable_groups": [],
 19                 "variable_fields": []
 20             },
 21             {
 22                 "id": "pyXnExEL",
 23                 "category_id": "dD8X67zW",
 24                 "machine_label": "x10_lamp",
 25                 "label": "X10 Lamp",
 26                 "description": "An X10 lamp module or device.",
 27                 "platform": "x10_light,light",
 28                 "public": 2,
 29                 "status": 1,
 30                 "created_at": 1482065387,
 31                 "updated_at": 1482065387,
 32                 "variable_groups": [
 33                     {
 34                         "id": "VnogrX2jXAzEJ",
 35                         "relation_id": "pyXnExEL",
 36                         "relation_type": "device_type",
 37                         "group_machine_label": "x10_address",
 38                         "group_label": "X10 Address 1",
 39                         "group_description": "X10 Address information",
 40                         "group_weight": 1,
 41                         "status": 1,
 42                         "created_at": 1482065388,
 43                         "updated_at": 1482065388
 44                     }
 45                 ],
 46                 "variable_fields": [
 47                     {
 48                         "id": "90MlzLxOo5XAr2",
 49                         "group_id": "VnogrX2jXAzEJ",
 50                         "field_machine_label": "house",
 51                         "field_label": "House Code",
 52                         "field_description": "House code A-P.",
 53                         "field_weight": 0,
 54                         "value_required": 0,
 55                         "value_max": 0,
 56                         "value_min": 0,
 57                         "encryption": "nosuggestion",
 58                         "value_casing": "none",
 59                         "input_type_id": "gowWdDyk",
 60                         "default_value": "",
 61                         "field_help_text": "The house code of the X10 module, in the range between A and P.",
 62                         "multiple": false,
 63                         "created_at": 1482065388,
 64                         "updated_at": 1482065389
 65                     },
 66                     {
 67                         "id": "XJYae1q6oANlp0",
 68                         "group_id": "VnogrX2jXAzEJ",
 69                         "field_machine_label": "unit_code",
 70                         "field_label": "Unit Code",
 71                         "field_description": "X10 unit code, 1-16",
 72                         "field_weight": 1,
 73                         "value_required": 0,
 74                         "value_max": 16,
 75                         "value_min": 1,
 76                         "encryption": "nosuggestion",
 77                         "value_casing": "none",
 78                         "input_type_id": "PLDAaDBX",
 79                         "default_value": "",
 80                         "field_help_text": "",
 81                         "multiple": false,
 82                         "created_at": 1482065388,
 83                         "updated_at": 1499459267
 84                     }
 85                 ]
 86             }
 87         ],
 88         "locator": "device_type",
 89         "locator_type": "objects"
 90     },
 91     "code": 200,
 92     "warnings": [],
 93     "pages": {
 94         "total_items": 40,
 95         "page_limit": 2,
 96         "total_pages": 20,
 97         "page_start": 1
 98     },
 99     "message": "OK",
100     "html_message": "OK"
101 }

GET - Specific device type

Retrieve a specific device_type id.

Request URLs

  • GET https://api.yombo.net/api/v1/device_type/{device_type_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..." \
https://api.yombo.net/api/v1/device_type/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/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/j2z8gbJxGQl4qwM6",
 4         "uri_description": "Detailed information for a single device.",
 5         "doc_uri": "https://yombo.net/API:Device_types",
 6         "device": {
 7             "id": "YnxO5X4gLqwOgWNE",
 8             "gateway_id": "km8M7lRv0E31ebmx",
 9             "device_type_id": "9oDQ0XVy",
10             "machine_label": "front_porch_string_light",
11             "label": "String Light",
12             "description": "Mini lights on the front patio.",
13             "location_id": "r3RbaPD1m1Y0Qw",
14             "area_id": "qYJXzmMjg60ZNW",
15             "notes": null,
16             "attributes": null,
17             "voice_cmd": null,
18             "voice_cmd_order": null,
19             "voice_cmd_src": null,
20             "pin_code": null,
21             "pin_required": 0,
22             "pin_timeout": null,
23             "statistic_label": "myhouse.outside.front.string_lights",
24             "statistic_lifetime": 365,
25             "statistic_type": null,
26             "statistic_bucket_size": null,
27             "data": null,
28             "status_set_at": "2018-02-12 14:59:27",
29             "energy_usage": 0,
30             "human_status": "0.0%",
31             "human_message": "Front Porch String Light is now 0.0%",
32             "machine_status": "0",
33             "machine_status_extra": "{'brightness': 0.0}",
34             "energy_type": "electric",
35             "energy_tracker_source": null,
36             "energy_tracker_device": null,
37             "energy_map": {
38                 "0.0": 0,
39                 "1.0": 0
40             },
41             "status": 1,
42             "created_at": 1496367526,
43             "updated_at": 1498782766,
44             "variable_data": [
45                 {
46                     "gateway_id": "",
47                     "id": "MBq9KeOv8LmRrEQ3YN",
48                     "field_id": "PANMDg4rqoY9Ox",
49                     "relation_id": "YngLqwOgWxO5X4NE",
50                     "relation_type": "device",
51                     "data": "11.11.11",
52                     "data_weight": 0,
53                     "created_at": 1496367527,
54                     "updated_at": 1496367527
55                 }
56             ]
57 
58         },
59         "locator": "device",
60         "locator_type": "object"
61     },
62     "code": 200,
63     "warnings": [],
64     "message": "OK",
65     "html_message": "OK"
66 }

POST - Create new device type

Creates a new device type. Rules for public and status fields apply.

Request URLs

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

Parameters

Name Type Description
Required
machine_label string An ummutable label for developers to use. A computer version of the `label`.
label string A short human friendly label for the device type.
description string A description of what the device type does.
category_id string Categorize the device type. Must be a ‘device_typecategory.
Optional
status integer Default: 1 - A status for the device type.
public integer Default: 0 - If the device type should be public.

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 '{"gateway_id": "km8M7lRv0E31ebmx", "pin_required": 0,
"label": "Cleaning Robot",  "machine_label": "cleaning_robot",
"description": "A robot that cleans stuff.",
"category": "NKq9kVmM"}' \
https://api.yombo.net/api/v1/device_type
  <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'
headers = {
    'x-api-key': 'abc123xyz789',
    'authorization': 'Waro7g0Mwl4YBJ...',
    }

payload = {
    "label": "Cleaning Robot",
    "machine_label": "RoboClean",
    "description": "A robot that cleans stuff.",
    "category": "NKq9kVmM",
    }

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",
 4         "uri_description": "Create new device type.",
 5         "doc_uri": "https://yombo.net/API:Device_types",
 6         "device_type": {
 7             "id": "QAJqr8xZ",
 8             "category_id": "NKq9kVmM",
 9             "machine_label": "cleaning_robot",
10             "label": "Cleaning Robot",
11             "description": "A robot that cleans stuff.",
12             "platform": null,
13             "public": 0,
14             "status": 1,
15             "created_at": 1518558431,
16             "updated_at": 1518558431
17         },
18         "locator": "device_type",
19         "locator_type": "object"
20     },
21     "code": 201,
22     "warnings": [],
23     "message": "Created",
24     "html_message": "Created"
25 }

PUT / PATCH - Update a device type

Update a device type. When using PUT, all required parameters must be sent. When using PATCH, only send in desired changes.

Request URLs

  • PATCH https://api.yombo.net/api/v1/device_type/{device_type_id}
  • PUT https://api.yombo.net/api/v1/device_type/{device_type_id}

Parameters

See post new device type parameters.

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 PATCH -d '{"gateway_id": "km8M7lRv0E31ebmx", "pin_required": 0,
"description": "A robot that cleans up messes.",
"category": "NKq9kVmM"}' \
https://api.yombo.net/api/v1/device_type/QAJqr8xZ
  <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/QAJqr8xZ'
headers = {
    'x-api-key': 'abc123xyz789',
    'authorization': 'Waro7g0Mwl4YBJ...',
    }

payload = {
    "label": "Cleaning Robot",
    "machine_label": "RoboClean",
    "description": "A robot that cleans up messes.",
    "category": "NKq9kVmM",
    }

response = requests.patch(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/QAJqr8xZ",
 4         "uri_description": "Update (patch) device type.",
 5         "doc_uri": "https://yombo.net/API:Device_types",
 6         "device_type": {
 7             "id": "QAJqr8xZ",
 8             "category_id": "NKq9kVmM",
 9             "machine_label": "cleaning_robot",
10             "label": "Cleaning Robot",
11             "description": "A robot that cleans up messes.",
12             "platform": null,
13             "public": 0,
14             "status": 1,
15             "created_at": 1518558431,
16             "updated_at": 1518558612
17         },
18         "locator": "device_type",
19         "locator_type": "object"
20     },
21     "code": 200,
22     "warnings": [],
23     "message": "OK",
24     "html_message": "OK"
25 }

DELETE - Delete a device type

Delete a device type. This doesn't actually delete the device type right away, but simply marks it for deletion later. This is the same as setting the status to 2. To undelete the device type, simply change the status back to 1.

Request URLs

  • DELETE https://api.yombo.net/api/v1/device_type/{device_type_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/QAJqr8xZ
  <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/QAJqr8xZ'
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/QAJqr8xZ",
 4         "uri_description": "Delete a device type.",
 5         "doc_uri": "https://yombo.net/API:Device_types",
 6         "device_type": "Deleted",
 7         "locator": "device_type",
 8         "locator_type": "string"
 9     },
10     "code": 200,
11     "warnings": [],
12     "message": "Deleted",
13     "html_message": "Deleted"
14 }
This page was last edited on 14 September 2018.