Count Trait
API Service: CountApi
CountApi tracks both a positive and negative count of some quantity. Can be used for tickers, footfall sensors, and devices like that.
| Method | Request Type | Response Type | Description |
|---|---|---|---|
| GetCount | GetCountRequest | Count | Get the current count state |
| ResetCount | ResetCountRequest | Count | Reset the counts to 0 and update the reset time. |
| UpdateCount | UpdateCountRequest | Count | Update one or more properties of the count. |
| PullCounts | PullCountsRequest | PullCountsResponse stream | Subscribe to changes to the count. |
Info Service: CountInfo
Describes the capabilities of a specific named device with respect to this trait.
| Method | Request Type | Response Type | Description |
|---|---|---|---|
| DescribeCount | DescribeCountRequest | CountSupport | Get information about how a named device implements Count features |
Count
Count represents how many of a thing exist. The total measured count is added - removed. Some devices may adjust added up and down and leave removed at 0, some might increase both properties.
| Field Name | Type | Description |
|---|---|---|
| added | int32 | Total number of added items |
| removed | int32 | Total number of removed items |
| reset_time | google.protobuf.Timestamp | The time the counts were reset |
CountSupport
CountSupport describes the capabilities of devices implementing this trait
| Field Name | Type | Description |
|---|---|---|
| resource_support | smartcore.types.ResourceSupport | How a named device supports read/write/pull apis |
| two_way | bool | Two way counters count additions and removals separately. Do NOT use this as a way to ignore the Count.removed property, the total count is always added - removed. |
| supports_reset | bool | Does the api support resetting the count timer. |
| supports_delta | bool | When updating the count does this device support the delta property |
GetCountRequest
| Field Name | Type | Description |
|---|---|---|
| name | string | |
| read_mask | google.protobuf.FieldMask | The state fields to fetch |
ResetCountRequest
| Field Name | Type | Description |
|---|---|---|
| name | string | |
| reset_time | google.protobuf.Timestamp | if absent then the server timestamp will be used |
UpdateCountRequest
| Field Name | Type | Description |
|---|---|---|
| name | string | |
| count | Count | |
| update_mask | google.protobuf.FieldMask | |
| delta | bool | if true the added and removed properties of count should be treated as a change not an absolute value. |
PullCountsRequest
| Field Name | Type | Description |
|---|---|---|
| name | string | |
| read_mask | google.protobuf.FieldMask | The state fields to fetch |
| updates_only | bool | When true the device will only send changes to the resource value. The default behaviour is to send the current value immediately followed by any updates as they happen. |
PullCountsResponse
| Field Name | Type | Description |
|---|---|---|
| changes | repeated PullCountsResponse.Change |
PullCountsResponse.Change
| Field Name | Type | Description |
|---|---|---|
| name | string | |
| count | Count | |
| change_time | google.protobuf.Timestamp | when the change occurred |
DescribeCountRequest
| Field Name | Type | Description |
|---|---|---|
| name | string | The name of the device |