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 and zones become 1/0 and can be used like digital signals. In addition there are the number of people, brightness, temperature, humidity and air pressure, and the siren can be switched.
Without a broker, or with a Miniserver Gen. 1, it also works through a Virtual HTTP Input (see Without a broker). The Miniserver then polls the sensor only every 10 seconds at most. That is how long it can take until, for example, 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 |
<ZONE1> … <ZONE4>
|
Name of the detection zone as it appears in the MQTT topic: in capital letters |
<IP> |
IP address of the sensor, only for the HTTP method |
<Zonenname> |
Name of a detection zone, exactly as entered under Zones → Zone names (note upper and lower case), only for the HTTP method |
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 MZ multi-zone presence sensor with firmware 1.4.3 or newer on the same network as the Miniserver
Setting up the sensor
-
In the sensor's web interface under Zones → Zone names, name the detection zones you use before you enter them in Loxone (short, only letters, digits and
_, no spaces or umlauts, e.g.Sofa). Do not rename them afterwards: the name is part of the topics below. Do not choose a name that looks like a field of the response (presence,detection,temperature…). -
Sensor web interface → Connections:
Field Value Connection type MQTT BrokerServer, 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, Room timeout and Timeout per zone), 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>/ZONES/<ZONE1>(likewise<ZONE2>…)\184= zone occupied,70= freestat/<Hauptthema>/DETECTION\vNumber of people tele/<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). An empty message (zone without an area) also results in0. ForLWT,\s1skips the first character, because both words start withO.Example: if the zone on the sensor is called
Sofa, the topic isstat/<Hauptthema>/ZONES/SOFA. -
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 or a zone 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, number of people and zones ready, so after a restart of the Miniserver they are back right away.
Quick test
- Go into the room: in the live view, presence jumps to
1after 2 seconds at most, and so does the zone you are standing in. Leave the room: after the timeout, both are at0. - The Command Recognition behind the subscription to
LWTshows110(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). Check in the browser whether the sensor responds: http://<IP>/measurements returns a line like
{"presence": true, "detection": 1, "zones": {"Sofa": true}, "temperature": 21.5, "pressure": 1014.6, "humidity": 49.9, "brightness": 184.6}
Under zones there are only the detection zones for which an area has been drawn. The order of the fields is not fixed. The patterns below can handle that. Step 2 under “Setting up the sensor” (broker) is not needed for this method.
-
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.\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. -
For each detection zone you use, add a further command with the same correction (
102→0,116→1):Property Value Command Recognition \i"<Zonenname>": \i\1Example for the zone
Sofa:\i"Sofa": \i\1. Here the name is as you entered it, not in capital letters. -
Add further commands as you like, here without a correction:
Value Command Recognition Result Number of people \i"detection": \i\ve.g. 2,0= nobody detectedBrightness in lx \i"brightness": \i\ve.g. 184.6Temperature in °C \i"temperature": \i\ve.g. 21.5Humidity in % \i"humidity": \i\ve.g. 49.9Air pressure in hPa \i"pressure": \i\ve.g. 1014.6\vreads the number that follows the text. The number of people applies without timeout. For “light on/off”, use presence. -
Drag the commands onto a program page and connect presence or a zone 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. Go into the room: in the live view, presence jumps to 1 after one polling cycle at the latest, and so does the command of the zone you are standing in. Leave the room: after the timeout and one polling cycle, both are at 0.
Optional
Switching the siren
With MQTT, add a Publish object:
| Property | Value |
|---|---|
| Topic | cmnd/<Hauptthema>/SIREN |
| Value |
ON or OFF
|
| Retain | off |
Without a broker, a Virtual Output switches the sound over HTTP:
-
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 siren (e.g. alarm system). You choose the sound itself on the sensor (main page, Sound).
Whether the siren is currently sounding is returned by http://<IP>/siren ({"siren": true} or false). For this, add an HTTP input with the Command Recognition \i"siren": \i\1 and the same correction as for presence.
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>/PRESENCEand the zonesstat/<Hauptthema>/ZONES/<ZONE1>… - On the Incoming Overview tab, copy the names (do not type them) and create a Virtual Input in Loxone Config for each value, with exactly this name, e.g.
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, for example, the light comes on.
- If the sensor fails, the last value stays (even a presence of
1). With MQTT,LWTshows102(not reachable) after about 20–30 seconds. On the HTTP input, the Miniserver reports the failure after the set number of timeouts. - The HTTP method reads values and switches the siren. Other settings of the sensor cannot be changed this way.
- Zone names: the topic and the patterns contain the zone name. After renaming on the sensor, Loxone no longer finds the zone. In that case, also enter the new name in Loxone. A zone without a drawn area is not in the HTTP response and sends an empty message over MQTT. Create subscriptions only for zones with an area.
- The factory name
Detection 1contains a space (in the topicDETECTION 1). Therefore rename the zones beforehand (see “Setting up the sensor”). - Shortly after a restart of the sensor, temperature, humidity, air pressure and brightness are not yet set (
null). What Loxone then displays depends on the Miniserver. - 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.
Verification status
This guide is based on the documentation from Loxone and LoxBerry.