-
Notifications
You must be signed in to change notification settings - Fork 14
How to benefit of the full topic option
cflurin edited this page Sep 27, 2018
·
1 revision
If the configuration option topic_mode
is set to full
or both
, only the topic /from
change, the data (payload) is sent/received in a JSON format using following topics:
- xiaomi/from/{{sid}}/{{cmd}}/{{model}}
- xiaomi/from/{{sid}}/{{cmd}}/{{model}}/status (if status sent by device)
with sid
, cmd
, model
, replaced by the ones sent by the device. The payload is untouched, all information will be sent.
So for example you can have a new topic like:
topic: xiaomi/from/158d0003102db5/report/cube
payload:
{
"cmd":"report",
"model":"cube",
"sid":"158d0003102db5",
"short_id":46605,
"data":{"status":"move"}
}
If the device return a status, the topic is extended by status allowing for example to get only status change messages.
topic: xiaomi/from/158d0003102db5/report/cube/status
payload:
{
"cmd":"report",
"model":"cube",
"sid":"158d0003102db5",
"short_id":46605,
"data":{"status":"flip90"}
}
What does this means? You can do subscription filtering, have a look at documentation on this point.
subscribe to a specific device
topic: xiaomi/from/158d0003102db5/#
payload:
{
"cmd":"report",
"model":"cube",
"sid":"158d0003102db5",
"short_id":46605,
"data":{"status":"move"}
}
subscribe to all devices report event
topic: xiaomi/from/+/report/#
payload:
{
"cmd": "report",
"model": "magnet",
"sid": "158d0001f3651f",
"short_id": 57029,
"data": {
"status": "close"
}
}
subscribe to temperature humidity devices only
topic: xiaomi/from/+/+/sensor_ht/#
payload:
{
"cmd":"report",
"model":"sensor_ht",
"sid":"158d0001a2eb66",
"short_id":30124,
"data":{"voltage":3005,"temperature":16.7,"humidity":40.5}
}
subscribe to all cube status event
topic: xiaomi/from/+/+/cube/status
payload:
{
"cmd":"report",
"model":"cube",
"sid":"158d0003102db5",
"short_id":46605,
"data":{"status":"move"}
}
subscribe to all devices status event
topic: xiaomi/from/+/+/+/status
payload:
{
"cmd":"report",
"model":"cube",
"sid":"158d0003102db5",
"short_id":46605,
"data":{"status":"move"}
}