Hi all,
I am new to this community and designing my own devices which is capable to connect to openhab with MQTT. I searched through the forum and most of the solutions are code based whereas I do not wish to involved at this point. So I currently simply interact with Paper UI.
Because I wonder if my existing Json format is system friendly. For example,
config.json:
{ "config": { "type": "devicetype", "name": "home/room/device", "wifi": [ { "id": "wifi1id", "pw": "wifi1pw" }, { "id": "wifi2id", "pw": "wifi2pw" } ], "ota": { "host": "otahost", "port": otaport, "id": "otaid", "pw": "otapw" }, "mqtt": { "host": "brokerip", "port": 1883, "id": "mqttid", "pw": "mqttpw", "topic": "discoverytopic" } } }
params.json:
{ "params": { "smart": { "on": 0, "delay": 60, "sonic": { "on": 170, "spl": 3 }, "rt": { "on": 300, "spl": 3 }, "pir": { "spl": 100 } }, "on": 1 } }
status.json:
{ "status": { "on": "ON", "sonic": 100, "rt": 25.5, "pir": 100, "delay": 60000 } }
The device should transmit its status.json periodically.
Params.json should be different per device and be able to update remotely.
Config.json is preset and normally does not change.
Every device subscribes to its own topic “home/room/function” and can be discovered in “discoverytopic” topic.
With currently setting, their status can be shown in openhab with, for example, “On/Off switch” channel setting: MQTT state topic: “home/room/device” and Incoming value tranformation “JSONPATH:$.status.on”.
To change the parameters, the Things, for example, could be a “number value” Channel with settings MQTT command topic: “home/room/device” and Outgoing value format: {“params”:{“on”:%s}}
Not sure if this is the right way to do because, previously, I wish to transmit an updated params.json per request so as to update values in “Control” page but it failed due to restricted size of mqtt packet. So I am not sure how to retrieve and show the params.json in openhab. One way might be transmitting all parameters one by one peroidically but this would cause heavy load to bandwidth with redundancy data.
Is it common to keep the json in single level so there is no need to enter the “Incoming value tranformation” and “Outgoing value format” when creating a channel?
Does MQTT embedded broker supports wildcards? this possibly helps to eliminate the discovery topic.
appreciate for any suggestion.