Contents
The Miniserver and the sensor are connected to the same MQTT broker. The sensor reports every change in presence immediately. The Miniserver takes it over via Loxone's own MQTT (from Config 15.3, not Miniserver Gen. 1) and evaluates it at most every 2 seconds. Presence becomes 1/0 and can be used like a digital signal. In addition there are distance, brightness, temperature, humidity and air pressure, and the alarm sound can be switched. This applies equally to KL LD and KL.
Without a broker, or with a Miniserver Gen. 1, it also works through a Virtual HTTP Input (see Without a broker). However, the Miniserver then polls the sensor only every 10 seconds at most. That is how long it can take until the light comes on.
Replace the placeholders in this guide with your own values:
| Placeholder | Meaning |
|---|---|
<Hauptthema> |
what is entered on the sensor under Connections → Main topic |
<IP> |
IP address of the sensor, for the HTTP method and the alarm sound |
<Login>, <Passwort>
|
Login credentials of the sensor, for the HTTP method and the alarm sound, only when authentication is switched on |
Requirements
- Miniserver Gen. 2, Compact or Go with Loxone Config 15.3 or newer (for the HTTP method any Miniserver, including Gen. 1)
- an MQTT broker on the network, e.g. Mosquitto on a NAS or a LoxBerry. The Miniserver is only a client, not a broker. Without a broker, the HTTP method remains.
- KL LD presence sensor with firmware 1.1.3 or KL with firmware 3.2.3 (for older versions see Limitations) on the same network as the Miniserver
Setting up the sensor
Sensor web interface → Connections:
| Field | Value |
|---|---|
| Connection type | MQTT Broker |
| Server, port | those of the broker |
| Login, password | only if the broker requires them |
| Client id | unique, only letters, digits, _
|
| Main topic | free, only letters, digits, _
|
| Home Assistant | off (Loxone does not read the discovery) |
Save. After a short while, the bottom of the page shows “connected”.
How long presence continues after the last detection is set on the sensor (main page, Timeout), not in Loxone.
Setup
-
Select Network Periphery → Add network device → MQTT. Properties:
Property Value Broker address IP address of the broker Broker port the same as on the sensor, usually 1883Client ID free, but different from the sensor's Username / password only if the broker requires them -
Select the MQTT object and add one Subscription for each value. A subscription delivers text. Follow it with the Command Recognition block (input
T, outputLv):Topic of the subscription Command Recognition Lvstat/<Hauptthema>/PRESENCE\184= someone there (True),70= nobody (False)stat/<Hauptthema>/DETECTION_DIST\vDistance of the person in cm, 0= nobody theretele/<Hauptthema>/LWT\s1\1110= reachable (Online),102= not reachable (Offline)Turn
84/70into the values1/0, e.g. with the Formula block and the formulaMAX(0;(I1-70)/14).MAXkeeps the result at0in case the Command Recognition does not find a letter. ForLWT,\s1skips the first character, because both words start withO.Following the same pattern as presence, with
\1and the same formula:stat/<Hauptthema>/MOVING(moving person detected) andstat/<Hauptthema>/STATIONARY(stationary person detected). -
Brightness, temperature, humidity and air pressure are only available in the JSON: subscribe to
tele/<Hauptthema>/STATEand follow it with one Command Recognition for each value:Value Command Recognition Brightness in lx \i"brightness": \i\vTemperature in °C \i"temperature": \i\vHumidity in % \i"humidity": \i\vAir pressure in hPa \i"pressure": \i\vEnter the patterns exactly as shown, with the space after the colon. The values arrive at the Publish interval of the sensor (on the sensor under Connections).
-
Drag the Formula blocks onto a program page and connect presence to the input of the block that is to react (e.g. the lighting control). Save to the Miniserver.
At most 16 subscriptions per Miniserver. It evaluates changes every 2 seconds at the earliest. The broker keeps presence, distance and reachability ready, so after a restart of the Miniserver they are back right away.
Quick test
- Walk up and down in front of the sensor: in the live view, presence jumps to
1after 2 seconds at most. Leave the room: after the timeout, it is at0. - The subscription to
LWTshows the textOnline, the Command Recognition behind it110(reachable).
Without a broker: Virtual HTTP Input
This method does not need a broker and also works on the Miniserver Gen. 1. However, the Miniserver polls the sensor only every 10 seconds. The sensor needs a fixed IP address for this (permanently assign the address in the router). The settings under “Setting up the sensor” are not needed for this method. Check in the browser whether the sensor responds: http://<IP>/measurements returns a line like
{"presence": true, "detection_dist": 200, "brightness": 221.2, "temperature": 21.5, "pressure": 1014.4, "humidity": 48.3, "zone": "Short", "moving_gate_energies": [21, 84, 46, 6, 10, 10, 6, 10, 6, 9, 6, 7, 8], "stationary_gate_energies": [19, 31, 15, 10, 9, 10, 9, 8, 9, 10, 8, 10, 8], "moving": true, "stationary": false, "moving_target_energy": 84, "stationary_target_energy": 0, "moving_target_dist": 200, "stationary_target_dist": 0}
The order of the fields is not fixed. The patterns below can handle that.
-
In Loxone Config, select Virtual Inputs in the Periphery tree and add a Virtual HTTP Input. Properties:
Property Value URL http://<IP>/measurementsPolling cycle 10(seconds, the smallest permitted value)Timeout 4000(ms, permitted10…8000)Number of allowed timeouts 5If Authentication is switched on at the sensor under System, the URL is
http://<IP>/measurements?login=<Login>&password=<Passwort>. -
Select the HTTP input and add a Virtual HTTP Input Command for presence:
Property Value Command Recognition \i"presence": \i\1Use as digital input off Correction: Input value 1 102Correction: Display value 1 0Correction: Input value 2 116Correction: Display value 2 1Enter the pattern exactly as shown, with the space after the colon. Background: in the JSON, presence is the word
trueorfalse, not a number.\i…\ijumps to the position after the given text,\1reads the character code of the next letter:116fort(true),102forf(false). The correction turns these into1and0.You read moving or stationary in the same way, with the same correction:
\i"moving": \i\1and\i"stationary": \i\1. -
Add further commands as you like, here without a correction:
Value Command Recognition Result Distance of the person in cm \i"detection_dist": \i\ve.g. 200,0= nobody thereBrightness in lx \i"brightness": \i\ve.g. 221.2Temperature in °C \i"temperature": \i\ve.g. 21.5Humidity in % \i"humidity": \i\ve.g. 48.3Air pressure in hPa \i"pressure": \i\ve.g. 1014.4\vreads the number that follows the text. -
Drag the commands onto a program page and connect presence to the input of the block that is to react (e.g. the lighting control). Save to the Miniserver.
Quick test: in the command, open the editing window of the Command Recognition. It shows the sensor's response, that is, the JSON line from above. Walk up and down in front of the sensor: in the live view, presence jumps to 1 after one polling cycle at the latest. Leave the room: after the timeout and one polling cycle, it is at 0.
Optional
Switching the alarm sound
The alarm sound is switched by a Virtual Output over HTTP, even if the other values arrive via MQTT. For the alarm sound, the sensor only accepts the words ON/OFF, not the numbers 1/0 that a digital output delivers.
-
Select Virtual Outputs and add a Virtual Output:
Property Value Address http://<IP>Only the address, with no path after it.
-
Below it, add a Virtual Output Command:
Property Value Command for ON /siren?turn=onCommand for OFF /siren?turn=offIf authentication is switched on at the sensor, append
&login=<Login>&password=<Passwort>to both commands. -
On the program page, connect the command to the output that is to trigger the alarm sound (e.g. alarm system). You choose the sound itself on the sensor (main page, Sound).
LoxBerry with MQTT Gateway
Worthwhile if a LoxBerry is already running (the gateway and the broker have been built in since LoxBerry 3.0) or if the Miniserver Gen. 1 is to get MQTT.
- Enter the LoxBerry as the broker on the sensor. Server, port, user and password are found in the LoxBerry under System Settings → MQTT Gateway → MQTT Basics.
- On the Gateway tab under Text to Value Conversions, enter
True=1andFalse=0. - On the Subscriptions tab, tick
stat/<Hauptthema>/PRESENCE. - On the Incoming Overview tab, copy the name (do not type it) and create a Virtual Input in Loxone Config with exactly this name, here
stat_<Hauptthema>_PRESENCE.
Limitations
- Loxone evaluates MQTT messages at most every 2 seconds. The HTTP method polls at most every 10 seconds. That is how long it can take there until the light comes on.
- If the sensor fails, the last value stays (even a presence of
1). With MQTT,LWTshows102(not reachable) after a good 20 seconds. On the HTTP input, the Miniserver reports the failure after the set number of timeouts. - The HTTP method reads values and switches the alarm sound. Other settings of the sensor cannot be changed from Loxone.
- The name of the zone arrives as text and cannot be read as a number. Use the distance instead and define ranges in Loxone.
- The distance changes several times per second during movement. Loxone takes over at most one value every 2 seconds.
- HTTP method: the IP address is fixed in the URL. If it changes, nothing arrives any more. With login, the password is in plain text in the URL.
- Older firmware (KL LD up to 1.1.2, KL up to 3.2.2): After a restart of the sensor, the old presence value may remain on the broker until the first change. Update the firmware.
Verification status
This guide is based on the documentation from Loxone and LoxBerry.