Hub can produce several types of messages:
Note that each message contains "hub-id" header !
Field "action" is a shortcut for the MessageAction
This message must be sent firstly to identify hub.
Field "data" contains hub description and extra properties like heart beat period (hb)
{
"hub-id": "hub1",
"action":"start",
"data": "{\"description\":\"test-hub\", \"hb\":30}"
}
Field "data" contains disconnection reason
{
"hub-id": "0b97d1b9-9759-4adc-b9a6-b885e1e9b872",
"action":"shutdown",
"data":"{\"reason\": \"shutting down\"}"
}
Reserved for the future ...
Notify about some changes in configuration or handle some user request and send response
{
"hub-id": "0b97d1b9-9759-4adc-b9a6-b885e1e9b872",
"action":"hub-msg",
"data": "important message"
}
Hub must produce heart beat message with fixed period. For instance, each 30 seconds
{
"hub-id": "0b97d1b9-9759-4adc-b9a6-b885e1e9b872",
"action":"alive",
"data": "{\"ts\":1652919949,\"alive-devices\":5,\"total-devices\":10}"
}
Hub must send notification on device connection
- hub-id - const hub uuid
- device-id - const device uuid
- type - device type. Starts with "ACTUATOR__" or "SENSOR__"
- name - custom device name
- data - additional information can pe passed here as string (in json format)
{
"hub-id": "0b97d1b9-9759-4adc-b9a6-b885e1e9b872",
"device-id":"ada9ff04-ed3f-470f-9c30-23068b9b8c02",
"action": "device-connected",
"data":"{\"unit\":\"celsius\",\"type\":\"SENSOR__thermometer\",\"name\":\"temperature imitator1\"}"
}
Hub must send notification on devices disconnection
- hub-id - const hub uuid
- device-id - const device uuid
- data - - disconnection reason
{
"hub-id": "0b97d1b9-9759-4adc-b9a6-b885e1e9b872",
"device-id":"ada9ff04-ed3f-470f-9c30-23068b9b8c02",
"action":"devices-disconnected",
"data": "connection lost"
}
- hub-id - const hub uuid
- device-id - const device uuid
- data - parsed information given from device and presented as a string in json format
{
"hub-id": "0b97d1b9-9759-4adc-b9a6-b885e1e9b872",
"device-id":"ada9ff04-ed3f-470f-9c30-23068b9b8c02",
"action":"msg",
"data": "{\"value\": \"value\"}"
}