Create object counter config

POST/homes/{homeId}/smartModules/{moduleId}/counters/{counterId}

Base URL: https://api.tinkermode.com

Create a new object counter config. The request body should contain a valid object counter config object. The collection ID of the config allows wildcard character (*) which specifies all of the collections in the module.

Authentication

Send an Authorization header of the form ModeCloud <AUTH_CODE>.

Must contain a user, service account, or project API key.

Path parameters

NameTypeRequiredConstraintsDescription
homeIdintegerYesThe unique ID for a home.
moduleIdstringYesThe unique ID for a smart module.
counterIdstringYesCounter ID. It must be unique per collection.

Request body

Content type: application/json

PropertyTypeRequiredConstraintsDescription
areaSearchKeyPrefixstringYesThe target area ID prefix. The object counter counts objects in the found area and stores the results per area.
attributesobjectNoThe attribute names and values to search the objects.
Properties of attributes
PropertyTypeRequiredConstraintsDescription
namestringYesThe name of the attribute.
valuesarray<string>NoThe attribute values to search objects. When this values are not specified, use the search string in the area's attribute value.
collectionIdstringYesThe collection ID to count the number of objects. It allows you to specify wildcard character (*) to count objects in the all of collections in the module.
counterIdstringYespattern: ^[a-zA-Z0-9]([a-zA-Z0-9\-_\:]*[a-zA-Z0-9])*$Object counter ID. Must be unique within each home. Must be 1 or more alphanumeric characters and may contain dashes ('-'), underscores ('_'), and colons (':') can be used after the first alphanumeric character but must be followed by 1+ alphanumeric characters.
frequencystringYesone of: 5s, 30s, 60sThe frequency to count objects in the areas.
namestringNoThe name of the object counter config.
objectSearchKeyPrefixesarray<string>NoThe searchKey prefixes to filter the counted objects. The object counter counts objects searched with the keywords specified here

Request example

{
  "areaSearchKeyPrefix": "office::",
  "attributes": [
    {
      "name": "vendor",
      "values": [
        "max",
        "philips"
      ]
    }
  ],
  "collectionId": "*",
  "counterId": "number_of_tools",
  "frequency": "60s",
  "name": "The number of tools in area",
  "objectSearchKeyPrefixes": [
    "driver::",
    "hammer::"
  ]
}

Responses

204 Successfully created the object counter config.

400 Request failed because of invalid data or denied permission.

Content type: application/json

PropertyTypeRequiredConstraintsDescription
dataobjectNoread-only (server-generated)Any relevant data related to error.
reasonstringYesread-only (server-generated)Reason of error.

401 Authorization is required to access this resource.

500 An unexpected error has occurred.

Content type: application/json

PropertyTypeRequiredConstraintsDescription
dataobjectNoread-only (server-generated)Any relevant data related to error.
reasonstringYesread-only (server-generated)Reason of error.

503 The service is temporarily unavailable.

Content type: application/json

PropertyTypeRequiredConstraintsDescription
dataobjectNoread-only (server-generated)Any relevant data related to error.
reasonstringYesread-only (server-generated)Reason of error.