Sensorlogger
MQTT settings
The general mqtt section is used to configure the parameters for the connections to the MQTT brokers. Any number of MQTT brokers can be set up. The following example shows a configuration for two separate brokers.
"mqtt": [ { "comment": "Configuration for Broker #1", "host": "192.168.1.3", "port": 1883, "qos": 1, "retained": false, "connected_topic": "Sensorlogger/status", "connected_message": "online", "lwt_topic": "Sensorlogger/status", "lwt_message": "offline", "enable_publish": true, "enable_subscribe": false, "topic_domain": "" }, { "comment": "Configuration for Broker #2", "host": "192.168.1.8", "port": 1883, "qos": 1, "retained": false, "connected_topic": "Sensorlogger/status", "connected_message": "online", "lwt_topic": "Sensorlogger/status", "lwt_message": "offline", "enable_publish": false, "enable_subscribe": true, "topic_domain": "House/Living_Room" } ]
"host": Hostname or IP address where the MQTT broker can be reached. May be omitted or set to null if you don’t want to configure any MQTT connection.
Standard value: null
"port": Port on the host to connect to the MQTT broker.
"qos": Quality of Service (QoS) for the connection to the MQTT broker.
Standard value: 1
"retained": If set to true, messages will be sent with the retained flag, which signals the MQTT broker to store any message until a new message for the respective topic arrives. This also affects the Last Will & Testament (LWT) message.
Standard value: false
"connected_topic": When Sensorlogger successfully connects to the MQTT broker, it can broadcast a first status message under this topic.
Standard value: null
"connected_message": Content of the message to be broadcast when successfully connecting to the MQTT broker.
Standard value: null
"lwt_topic": Topic for the Last Will & Testament (LWT) that the MQTT broker will use to broadcast a message if the connection to Sensorlogger is lost.
Standard value: null
"lwt_message": Message for the Last Will & Testament (LWT) that the MQTT broker will broadcast if the connection to Sensorlogger is lost.
Standard value: null
"topic_domain": Can be used to restrict this broker to a certain set of topics. All topics that this broker handles must start with this string. This parameter can be used as a filter mask when multiple MQTT brokers are defined. If the broker should handle all topics, an empty string can be used.
Standard value: ""
"enable_publish": If set to true, all values that belong to the topic domain will be published to this MQTT broker. Can be set to false to disable publishing to this broker. The connected and LWT messages will be sent to the broker regardless of this parameter.
Standard value: true
"enable_subscribe": If set to true, this MQTT broker will be used to subscribe to topics that belong to its topic domain. Can be set to false to disable any subscriptions for this broker.
Standard value: true
MQTT sensors
"sensors": [ ... { "sensor_id": "Shelly/AnalogTemp", "mqtt_subscribe": "shelly/tele/SENSOR", "json_key": ["ANALOG", "Temperature"], "factor": 1, "offset": 0, "counter": false, "mqtt_publish": "House/Living_Room/Temperature/current", "homematic_publish": "12345", "rest_period": {"value": 2, "unit": "s"} }, { "sensor_id": "Weather/Rainrocker", "mqtt_subscribe": "House/Weather/Rainrocker", "json_key": null, "factor": 0.5, "offset": 0, "counter": true, "rest_period": {"value": 100, "unit": "ms"} }, ... ]
"sensor_id": General, unique ID for the sensor that will later be referenced when defining statistics and logbooks.
"mqtt_subscribe": Topic that shall be subscribed for this sensor.
"json_key": If the value is not sent as a pure number, but embedded in a JSON structure, the value’s key sequence on the JSON tree can be specified here. To identify a key on the upper level, a simple string identifying the key’s name is enough. To reach deeper levels, you need to provide an array of key identifiers. If you need to access elements within JSON arrays, provide an integer number to specify the position within the array (note that indexing starts at 0).
Standard value: null
"factor": Correction factor, see next point.
Standard value: 1
"offset": Correction offset. The resulting sensor value is then calculated from factor·(measurement+offset).
Standard value: 0
"counter": Specifies if this sensor is a pure counter. In this case, the variable must be set to true. This means that no measurement value is kept in the data storage, but all messages are counted. For logbook statistics, it will only be possible to evaluate the number of received MQTT messages and their frequency, but none of the other statistical operations (such as mean) will give any meaningful results. If a sensor triggers very often, it can save memory not to keep all the events of a measurement cycle if only the number of events or their frequency is of interest (like for the wind sensor in the example above).
Note that measurements are always counted, irrespective of this configuration parameter. You will always be able to evaluate count and frequency when running the statistical analysis.
Standard value: false
"mqtt_publish": Topic that is used to republish the received and possibly corrected sensor value via MQTT. Cannot be the same topic as mqtt_subscribe.
Standard value: null
"homematic_publish": ISE ID of the HomeMatic system variable that should be set to the received and possibly corrected sensor value.
Standard value: null
"rest_period": Time for the sensor to rest between two measurements. This is the minimum time that must pass between two MQTT messages. Any measurements arriving within a shorter time period are rejected and not recorded. The numerical part for this parameter is set under "value", its unit under "unit". The following units are allowed: "ms", "s", "min", "h", "d".
Standard value: default_rest_period