Service Selectors

Overview

Service selectors allow users to select any specific service member, or group of service members, with a single string. Service selectors cannot select multiple service members across multiple devices at the same time. Their selection is always limited to one device at a time.

Selector paths can contain the following pieces:

  • Service name
  • Service member name
  • Service index
  • Service ID or alias

Indexed selectors use service indexes to target specific instances of a service implemented on a device. They are used when a device implements more than one service, and can be used to target one or multiple services at once. Quotation marks should not be used around index names.

Service indexes should have the following format:

  • 1-20 characters long
  • Either string or number type
  • No spaces
  • Valid characters
    • “A-Z”
    • “a-z”
    • “0-9”
    • “-” (hyphen)
    • “_” (underscore)

Compound index selectors are used to target more than one service at a time. These indexes can set a device property or call a device method over multiple devices. They cannot be used to read a device property value.

Types of Selectors

There are many possible ways to construct a service selector, depending on the number of service members being targeted. Each of these service selector variants can be used in the Droplit console or the REST API.

Basic Selector

A basic selector path specifies the service name and member name, as SERVICE-NAME.MEMBER-NAME.

General Index Selector

An indexed selector path, regardless of how many services the selector targets, has the general form of SERVICE-NAME[SERVICE-INDEX].MEMBER-NAME.

Index Number Range Selector

A range of indexes can be selected using numbers separated by two periods: ... For example, [5..8] selects indexes 5, 6, 7, and 8.

Index List Selector

A non-consecutive set of indexes can be selected with values separated by commas: ,. For example: [r1,r2] selects r1, and r2.

Index String Range Selector

A consecutive set of string indexes can be selected by separating the numeric range of those indexes by two periods: ...

Selecting a consecutive set of string indexes can be done where the index names are numerically differentiated by separating the numeric range of the identifier with ... For example: [r1..3] selects r1, r2, and r3.

Trailing characters are supported on both ends of an index. Letters preceding the range and following the range will be repeated automatically. For example, [some1..3thing] selects some1thing, some2thing, and some3thing.

Numbers that are not part of the range will be repeated. For example: [a1..3b4c] selects a1b4c, a2b4c, and a3b4c.

Only one range can exist per index. For example: [a1..3b4..5] is not allowed.

Index String Range List Selector

Ranges and lists can be combined in the index by using a comma: ,. For example: [r1..3,r5] selects r1, r2, r3, and r5.

Index Negation Selector

Indexes can be negated from a range selection using an exclamation mark prefix. Negation always overrides inclusion. For example: [r1..5,!r4] selects r1, r2, r3, and r5.

Index Range Negation Selector

Index ranges can be negated from a range selection. Negation always overrides inclusion. For example: [r1..7,!r3..5] Includes r1 through r7, then excludes r3 through r5. In total, this selects r1, r2, r6, and r7.