Skip to content

Commit

Permalink
updated message format docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bjhandeland committed Aug 19, 2019
1 parent ad95556 commit 591a638
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 104 deletions.
30 changes: 11 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ Breaking down the example `pt:j1/mt:evt/rt:dev/rn:zw/ad:1/sv:out_bin_switch/ad:1

Lastly, not that each interface within a service share the same address and that a service can never have more than one interface of the same type.

Abstract diagram:

![Fimp Service overview](static/fimp-service.png)

Device example:

![Fimp Service overview](static/fimp-thing-example.png)

Message format:

[FIMP message format](message-format.md)
Expand Down Expand Up @@ -119,7 +111,7 @@ in | cmd.config.get_supp_list | null | Requests service to respond wi
in | cmd.config.set | str_map | Sets configuration. Value is a key-value pairs.
in | cmd.config.supp_list_report | str_map | List of supported configurations. Key - config name, value - short description.
out | evt.config.report | str_map | Reports configurations in form of key-value pairs.
-|-|-|-
-|||
in | cmd.group.add_members | object | Adds members to the group. Object has the same format as members_report
in | cmd.group.delete_members | object | Object has the same format as report.
in | cmd.group.get_members | string | Value is a group name.
Expand Down Expand Up @@ -165,7 +157,7 @@ Type | Interface | Value type | Properties | Description
-----|--------------------|------------|-------------------------|------------
in | cmd.binary.set | bool | | true is mapped to 255, false to 0
out | evt.binary.report | bool | |
-|-|-|-
-|||
in | cmd.lvl.get_report | null | |
in | cmd.lvl.set | int | `duration` |
in | cmd.lvl.start | string | `start_lvl`, `duration` |
Expand Down Expand Up @@ -354,7 +346,7 @@ Type | Interface | Value type | Properties | Description
-----|--------------------|------------|----------- |------------------
in | cmd.lvl.get_report | null | | Get battery level over level report.
out | evt.lvl.report | int | state |
-|-|-|-
-|||
out | evt.alarm.report | str_map | | val = {"event": "low_battery", "status": "activ"}

#### Interface props
Expand All @@ -376,11 +368,11 @@ Type | Interface | Value type | Description
in | cmd.mode.get_report | null |
in | cmd.mode.set | string | Set thermostat mode:
out | evt.mode.report | string |
-|-|-|-
-|||
in | cmd.setpoint.get_report | string | value is a set-point type
in | cmd.setpoint.set | str_map | val = {"type":"heat", "temp":"21.5", "unit":"C"}
out | evt.setpoint.report | str_map | val = {"type":"heat", "temp":"21.5", "unit":"C"}
-|-|-|-
-|||
in | cmd.state.get_report | null |
out | evt.state.report | string | Reports operational state.

Expand Down Expand Up @@ -519,15 +511,15 @@ Type | Interface | Value type | Description
in | cmd.lvl.get_report | null | The command is a request for current fan speed level.
in | cmd.lvl.set | int | Fan speed, value 0 - 100 %
out | evt.lvl.report | null | Current fan speed level.
-|-|-|-
-|||
in | cmd.mode.get_report | null | The command is a request for current fan mode report.
in | cmd.mode.set | string | Fan mode. Supported values: auto_low, auto_high, auto_mid, low, high, mid, humid_circulation, up_down, left_right, quiet
out | evt.mode.report | string | Current fan mode
-|-|-|-
-|||
in | cmd.modelvl.get_report | string | The command is a request for fan speed level for particular mode. If mode is set to "", the device should report levels for all modes.
in | cmd.modelvl.set | int_map | val = {"mid":90, "auto_low":10}
out | evt.modelvl.report | int_map | val = {"mid":90, "auto_low":10}
-|-|-|-
-|||
in | cmd.state.get_report | null | The command is a request for current fan state report
out | evt.state.report | string | Report operational state. Supported values: idle, low, high, mid

Expand Down Expand Up @@ -575,12 +567,12 @@ Type | Interface | Value type | Description
in | cmd.notiftype.get_report | null |
in | cmd.notiftype.set | bool_map | Configuration of notification type device is is using while opening/closing door.
out | evt.notiftype.report | bool_map |
-|-|-|-
-|||
in | cmd.op.stop | null | Emergency stop of any operation.
-|-|-|-
-|||
in | cmd.state.get_report | null | Get current state
out | evt.state.report | string | Current state
-|-|-|-
-|||
in | cmd.tstate.set | string | Setting target state

#### Service props
Expand Down
128 changes: 43 additions & 85 deletions message-format.md
Original file line number Diff line number Diff line change
@@ -1,87 +1,45 @@
# FIMP message format

## FIMP topic format format

### Device service topic

pt:j1/mt:evt/rt:dev/rn:zw/ad:1/sv:sensor_presence/ad:16_0

pt:j1/mt:cmd/rt:dev/rn:zw/ad:1/sv:out_bin_switch/ad:15_0

### Technology adapter topic

pt:j1/mt:evt/rt:app/rn:cloud-bridge/ad:1

pt:j1/mt:cmd/rt:app/rn:cloud-bridge/ad:1

### Application topic

pt:j1/mt:evt/rt:ad/rn:zigbee/ad:1

pt:j1/mt:cmd/rt:ad/rn:zigbee/ad:1

### Cloud API topic

pt:j1/mt:evt/rt:cloud/rn:auth-api/ad:1

pt:j1/mt:cmd/rt:cloud/rn:auth-api/ad:1

### FIMP JSON format.

Fields:

Property | Type |Required | Desc
---------|---------------------|---------|----------------------------------------------------------------
type | String | Yes | Interface type, defines message format.
serv | String | Yes | Service name the interface is part of.
val_t | String | Yes | Data format of `val` field. See below.
val | dynamic | Yes | "payload" - it can be either simple type or complex object.
tags | List<String> | No | List of tags.
props | Map<String, String> | Yes | Map of properties.
ctime | String | Yes | Message creation time, e.g. `"2019-05-31 17:36:31 +0200"`
ver | String | Yes | Version of the message format, default: `"1"`.
uid | String | Yes | Unique message identifier.
corid | String | No | Message correlation id. Used for request - response matching.
src | String | Yes | Source or of the message, should be set only for commands.
resp_to | String | No* | Response topic where requester will expect to receive response.

* Required for Prime Fimp messages.

List of supported `val` types:

* string
* int
* float
* bool
* null
* str_array
* int_array
* float_array
* int_map
* str_map
* float_map
* bool_map
* object - A complex object which can't be mapped to primitive types. The structure of an object is defined by interface type and is unique for every interface type.
* base64

Message example:

```json
{
"type": "evt.sensor.report",
"serv": "temp_sensor",
"val_t": "float",
"val": 21.5,
"tags": ["tag1", "alarm"],
"props": {
"prop1": "4",
"prop2": "6"
},
"ctime": "2016-12-21T13:34:14.085581515+01:00",
"ver": "1.0",
"uid": "fb033c27-e7b5-4834-97ec-632ccb987e9e",
"corid": "uid_of_request",
"src": "vinculum",
"resp_to": "/pt:j1/mt:rsp/rn:smarthome-app/ad:1"
}
```
Messages send using FIMP are JSON messages containing the following properties:

Property | Type | Required | Description
---------|---------------------|----------|------------
corid | String | No | Message correlation id. Used for request - response matching.
ctime | String | Yes | Message creation time, e.g. `"2019-05-31 17:36:31 +0200"`
props | Map<String, String> | Yes | Map of properties.
resp_to | String | No* | Response topic where requester will expect to receive response.
serv | String | Yes | Service name the interface is part of.
src | String | Yes | Source or of the message, should be set only for commands.
tags | List<String> | No | List of tags.
type | String | Yes | Interface type, defines message format.
uid | String | Yes | Unique message identifier.
val | dynamic | Yes | "payload" - type is defined by `val_t`.
val_t | String | Yes | Data format of `val` field. See below.
ver | String | Yes | Version of the message format, default: `"1"`.

\*Required for Prime Fimp messages.

Since `val` can be any type, `val_t` defines what type it is. List of supported `val` types:

`val_t` | Sample `val`
------------|-------------
string | `'Hello world!'`
int | `3`
float | `3.1415`
bool | `true`
null | `null`
str_array | `['hello, 'world']`
int_array | `[0, 1, 1, 2, 3, 5, 8, 13]`
float_array | `[3.14, 2.71]`
int_map | `{"answer": 42}`
str_map | `{"ip": "192.168.1.1"}`
float_map | `{"pi: 3.14"}`
bool_map | `{"normalityRestored": true}`
object* | `{"nested": {"objects": "supported"}}`
base64 | `U28gbG9uZywgYW5kIHRoYW5rcyBmb3IgYWxsIHRoZSBmaXNoLg==`

\*A complex object which can't be mapped to primitive types. The structure of an object is defined by interface type and is unique for every interface type.

# Example messages

TODO(alivinco): add sample FIMP messages.

0 comments on commit 591a638

Please sign in to comment.