States
The client can subscribe to Notify Invocations when a new State is recieved for one of the product’s children.
wss://interay.io/hubs/states | |||
type | object | ||
properties | |||
| Secret connection token | ||
type | string | ||
| Subscribe to entities | ||
type | array | ||
items | The parent unique identifier. Product Unique ID / Location Unique ID / Device Unique ID | ||
type | string (UUID) | ||
Notify
The server sends an Invocation message when a new State is recieved.
type | object | |||
properties | ||||
| Message Type | |||
type | number | |||
const | 1 | |||
| Function name | |||
type | string | |||
const | Notify | |||
| Function arguments | |||
type | array | |||
items | type | object | ||
properties | ||||
| Read Last Response | |||
type | array | |||
Notes
Notify is only send when the client is subscribed to entities.
Example connection
wss://interay.io/hubs/states?id=secret-connection-token&entities=00000000-0000-0000-0000-000000000000
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Example server request
{
"type": 1,
"target": "Notify",
"arguments": [
{
"states": [
{
"channel": "99999999-9999-9999-9999-999999999999:modbus_1.reported",
"value": 1.0,
"aggregated": "last",
"entity": "00000000-0000-0000-0000-000000000000",
"timestamp": 1767222000.001
}
]
}
]
}␞
Read Last
Read last state(s) | |||
type | object | ||
properties | |||
| Message Type | ||
type | number | ||
const | 1 | ||
| Invocation ID | ||
type | string | ||
| Function name | ||
type | string | ||
const | ReadLast | ||
| Function arguments | ||
type | array | ||
items | Read Last Request | ||
type | object | ||
Response
type | object | ||
properties | |||
| Message Type | ||
type | number | ||
const | 1 | ||
| Invocation ID | ||
type | string | ||
| Function result | ||
type | array | ||
items | Read Last Response | ||
type | object | ||
Example client request
{
"type": 1
"invocationId": "0",
"target": "ReadLast",
"arguments": [
{
"entity": "00000000-0000-0000-0000-000000000000"
}
]
}␞
Example server response
{
"type": 3,
"invocationId": "0",
"result": [
{
"channel": "99999999-9999-9999-9999-999999999999:modbus_1.reported",
"value": 1.0,
"aggregated": "last",
"entity": "00000000-0000-0000-0000-000000000000",
"timestamp": 1767222000.001
}
]
}␞
Read History
Read state(s) | |||
type | object | ||
properties | |||
| Message Type | ||
type | number | ||
const | 1 | ||
| Invocation ID | ||
type | string | ||
| Function name | ||
type | string | ||
const | Read | ||
| Function arguments | ||
type | array | ||
items | Read History Request | ||
type | object | ||
Response
type | object | ||
properties | |||
| Message Type | ||
type | number | ||
const | 1 | ||
| Invocation ID | ||
type | string | ||
| Function result | ||
type | array | ||
items | Read History Response | ||
type | object | ||
Example client request
{
"type": 1
"invocationId": "0",
"target": "Read",
"arguments": [
{
"entity": "00000000-0000-0000-0000-000000000000",
"timeRangeStart": "-1d"
}
]
}␞
Example server response
{
"type": 3,
"invocationId": "0",
"result": [
{
"channel": "99999999-9999-9999-9999-999999999999:modbus_1.reported",
"value": 1.0,
"aggregated": "last",
"entity": "00000000-0000-0000-0000-000000000000",
"timestamp": 1767222000.001
}
]
}␞
Write
Write state(s) | |||
type | object | ||
properties | |||
| Message Type | ||
type | number | ||
const | 1 | ||
| Invocation ID | ||
type | string | ||
| Function name | ||
type | string | ||
const | Write | ||
| Function arguments | ||
type | array | ||
items | Write Request | ||
type | object | ||
Example client request
{
"type": 1
"invocationId": "0",
"target": "Write",
"arguments": [
{
"device": "00000000-0000-0000-0000-000000000000",
"states": [
{
"channel": "modbus_1.reported",
"value": 1.0,
"timestamp": "2019-09-26T07:58:30.996+0200",
},
{
"channel": "modbus_2.reported",
"error": -11,
"timestamp": "2019-09-26T07:58:30.996+0200",
}
]
}
]
}␞
Example server response
{
"type": 3,
"invocationId": "0",
"result": null
}␞