Skip to content

JSON mode

In JSON mode, DAELOC consumes JSON line bases data. Each received line is a JSON document and gets parsed. This mode is mostly used when logging data from an MQTT device, but you can also use other sources like Serial or TCP.

JSON Settings

The mapping is defined as a JSON document.

{
    "input":
        {
            "range": {
                "current": "A1:B1",
                "historical": "A3:B13"
            },
            "mapping": [
                "$.humidity",
                "$.temperature"
            ]
        },
    "output":
        {
            "range": "I2:I3",
            "mapping": [
                "interval",
                "unit"
            ]
        }
}

There are 2 sections in the config: input and output.

Input

In the input section, you define a range for the current and historical data ranges.

In the input section you also define a mapping that translates each property received into a value. Each column in the output range has a mapping. The mappings are defined using jsonpath expressions. You can read more about jsonpath in the RFC 9535.

Here's an example for the mapping... given an input of:

{ "id": 12345, "humidity": 45.12, "temperatue": 24.5  }

... the mapping produces a humidty value of 45.12 and a temperature value of 24.5.

Output

The output is also send as a JSON line. In the above mapping example, if I2 has the value 5 and I3 changes to value "C", the JSON line send to the source would become:

{ "interval":  5, "unit":  "C"}
This could be used by a temperature logger that now changes to Celcius an logs a value every 5 seconds.