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

  • id

Secret connection token

type

string

  • entities

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

  • type

Message Type

type

number

const

1

  • target

Function name

type

string

const

Notify

  • arguments

Function arguments

type

array

items

type

object

properties

  • states

Read Last Response

type

array

Notes

  1. 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

  • type

Message Type

type

number

const

1

  • invocationId

Invocation ID

type

string

  • target

Function name

type

string

const

ReadLast

  • arguments

Function arguments

type

array

items

Read Last Request

type

object

Response

type

object

properties

  • type

Message Type

type

number

const

1

  • invocationId

Invocation ID

type

string

  • result

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

  • type

Message Type

type

number

const

1

  • invocationId

Invocation ID

type

string

  • target

Function name

type

string

const

Read

  • arguments

Function arguments

type

array

items

Read History Request

type

object

Response

type

object

properties

  • type

Message Type

type

number

const

1

  • invocationId

Invocation ID

type

string

  • result

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

  • type

Message Type

type

number

const

1

  • invocationId

Invocation ID

type

string

  • target

Function name

type

string

const

Write

  • arguments

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
}␞