Contents
ioBroker integrates the presence sensor via MQTT: the sensor sends its values via MQTT, and the adapter MQTT Broker/Client (mqtt) reads them and creates a datapoint for each topic. Zone and distances arrive as text or number. Presence, motion and stationary arrive as the text True/False; an alias for each turns them into real boolean values. Brightness, temperature, humidity and air pressure are also each taken from the status message by an alias. The Sonoff adapter is not suitable for the sensor.
In all examples, <Hauptthema> stands for the value entered on the sensor under
Connections → Main topic (e.g. wohnzimmer). The angle brackets are not part of it: stat/<Hauptthema>/PRESENCE becomes
stat/wohnzimmer/PRESENCE.
This guide applies to both presence sensors. Where they differ, this is stated (calibration on the KL LD, auto configuration on the KL).
Prerequisites
- KL LD or KL. Recommended: KL LD with firmware 1.1.3 or newer, or KL with 3.2.3 or newer (for older versions, see Limitations).
- ioBroker with js-controller 6.0.11 or newer and Admin 7.6.20 or newer. This is required by MQTT adapter 8.1.2. Tested with js-controller 7.2.5, Admin 8.3.5.
- An MQTT broker on the network, e.g. Mosquitto. The presence sensor is always an MQTT client and needs a broker. If you do not have one, the MQTT adapter itself can act as the broker (see “Without a broker of your own”).
Setting up the sensor
Sensor web interface → Connections. All fields are described in the user manual. For ioBroker, these are the ones that matter:
| Field | Value |
|---|---|
| Connection type | MQTT Broker |
| Server | IP address of the broker |
| Port | 1883 |
| Login / Password | only if the broker requires them |
| Client id | unique for each device; only letters, digits, _
|
| Main topic | freely selectable; recommended: only letters, digits, _
|
| Publish interval | how often brightness and temperature should arrive, e.g. 1 min
|
| Home Assistant | off (ioBroker does not need it) |
Presence arrives immediately with every change, regardless of the publish interval.
Setup
-
In Admin, under Adapters install the adapter MQTT Broker/Client (Add instance). This creates the instance
mqtt.0. -
Instance settings, tab Connection:
Field Value first selection field (labeled “IP”) Client/SubscriberURL IP address of the broker Port 1883User / Password only if the broker requires them -
Tab Client settings:
Field Value Subscribe pattern, 1st entry stat/<Hauptthema>/#Subscribe pattern, 2nd entry tele/<Hauptthema>/#Delete the default entry
#, otherwise every topic on the broker becomes a datapoint. Multiple presence sensors: these two entries for each device. -
Tab MQTT settings:
Field Value Publish own states on connect off Set retain flag off (default) Mask to publish own states mqtt.0.*(default)Do not subscribe own states off (default) With “Publish own states on connect” switched on, ioBroker sends all values to the broker again at every start, including commands set earlier.
-
Save. After a few seconds, the datapoints appear under Objects under
mqtt.0.stat.<Hauptthema>andmqtt.0.tele.<Hauptthema>.
Presence as a boolean value (alias)
Boolean values arrive as the text True/False. An alias without a converter does not help: it turns every non-empty text into true, even False.
So create an alias with a converter for each value: Under
Objects select the source datapoint, Create alias from this object, set the State type in the alias, switch on
Use convert functions and enter under
Read converter the following:
| Alias | Source (Alias state ID) | State type | Read converter |
|---|---|---|---|
| Presence | mqtt.0.stat.<Hauptthema>.PRESENCE |
Boolean | val === 'True' |
| Motion | mqtt.0.stat.<Hauptthema>.MOVING |
Boolean | val === 'True' |
| Stationary | mqtt.0.stat.<Hauptthema>.STATIONARY |
Boolean | val === 'True' |
| Brightness in lx | mqtt.0.tele.<Hauptthema>.STATE |
Number | JSON.parse(val).brightness |
| Temperature in °C | mqtt.0.tele.<Hauptthema>.STATE |
Number | JSON.parse(val).temperature |
| Humidity in % | mqtt.0.tele.<Hauptthema>.STATE |
Number | JSON.parse(val).humidity |
| Air pressure in hPa | mqtt.0.tele.<Hauptthema>.STATE |
Number | JSON.parse(val).pressure |
| Reachable | mqtt.0.tele.<Hauptthema>.LWT |
Boolean | val === 'Online' |
For the most important value, the first alias is enough. In the same way, any other value can be taken from STATE, e.g. JSON.parse(val).signal for the
Wi-Fi signal strength in dBm.
In VIS, Jarvis, scripts and other interfaces, you select the aliases by their object ID, like any other datapoint.
Quick test
Go to Objects mqtt.0.stat.<Hauptthema> and expand it, then walk back and forth in front of the sensor or leave the room:
| Datapoint | Expected |
|---|---|
mqtt.0.stat.<Hauptthema>.PRESENCE |
Text True, if someone is there; False after the timeout has elapsed |
mqtt.0.stat.<Hauptthema>.ZONE |
Name of the zone, - = nobody there or outside all zones |
mqtt.0.stat.<Hauptthema>.DETECTION_DIST |
Number, distance in cm, 0 = nobody there |
mqtt.0.tele.<Hauptthema>.LWT |
Text Online
|
mqtt.0.tele.<Hauptthema>.STATE |
Text in curly braces, contains "presence"
|
| Presence alias |
true / false
|
If the datapoints are missing, search the Log for mqtt.0. There you must find
Connected to … and Subscribe on "stat/<Hauptthema>/#". If the log shows a different main topic than the sensor, that is the cause.
Optional
Setting values
Commands go to cmnd/<Hauptthema>/…; which ones exist is listed in the user manual. Two ways:
With a datapoint. In Admin, switch on Expert mode, under Objects, select mqtt.0 and add a child object:
| Field | Value |
|---|---|
| Type | State |
| State type | Number |
| Name | cmnd.<Hauptthema>.DETECTION_TIMEOUT |
If you write 30 to this datapoint, ioBroker sends 30 to
cmnd/<Hauptthema>/DETECTION_TIMEOUT (timeout 30 s). When writing, do not tick “Acknowledged”, otherwise nothing is sent. Whether the sensor has accepted the value is shown by mqtt.0.stat.<Hauptthema>.DETECTION_TIMEOUT.
The same value twice in a row is only sent once.
As a switch with feedback (e.g. SIREN, LEDS), an alias with two sources is suitable. It reads the state under stat/… and writes the command under cmnd/…: Create the datapoint
cmnd.<Hauptthema>.SIREN as above, but with state type string, and then an alias with:
| Field | Value |
|---|---|
| State type | Boolean |
| Different IDs for read and write | on |
| Alias read state | mqtt.0.stat.<Hauptthema>.SIREN |
| Alias write state | mqtt.0.cmnd.<Hauptthema>.SIREN |
| Read converter | val === 'True' |
| Write converter | val ? 'ON' : 'OFF' |
The alias shows whether the siren is sounding and switches it on and off.
With a script (JavaScript adapter), without a datapoint of its own:
sendTo('mqtt.0', 'sendMessage2Client',
{ topic: 'cmnd/<Hauptthema>/PLAY', message: '5' }); // play sound 5 (Gong)
With cmnd/<Hauptthema>/UPDATE (any value), the sensor immediately sends a fresh STATE, including new values for brightness and temperature.
Calibration (KL LD, CALIBRATION) or auto configuration (KL,
AUTO_THRESHOLDS) is better started in the sensor's web interface: the room must be empty while it runs.
Without a broker of your own
Set in the tab Connection the following:
| Field | Value |
|---|---|
| first selection field | Server/Broker |
| Port | 1883 |
| User / Password | choose freely |
On the sensor, enter:
| Field | Value |
|---|---|
| Server | IP address of the ioBroker computer |
| Login / Password | the same credentials |
The tab Client settings is omitted. In this variant, only read; do not set any values (see Limitations).
Limitations
-
The distances change very often: with a person who is moving, several times per second. Trigger automations via presence and do not switch on recording (History, InfluxDB, SQL) for
MOVING,STATIONARYand the…_DISTdatapoints. - Brightness, temperature, humidity and air pressure are only as fresh as the Publish interval of the sensor.
- Do not use the Sonoff adapter. The sensor uses the same topic names as Tasmota but is not a Tasmota device.
- Home Assistant discovery is of no use in ioBroker. The datapoints are created through the subscribe patterns anyway.
- Without a broker of your own, the adapter repeats commands. As a broker, the adapter sends a value that was set once again as soon as the sensor reconnects. A change made in the sensor's web interface would therefore be overwritten.
- Unchanged values are not updated by the adapter. The timestamp of a datapoint therefore does not tell you when the sensor last sent. That is what
LWTis for. - Older firmware (KL LD up to 1.1.2, KL up to 3.2.2) only sends presence when it changes: after a restart of the sensor, the old value can remain until the first change. Update the firmware.
Verification status
Tested with ioBroker (js-controller 7.2.5, MQTT adapter 8.1.2) and the KL LD with firmware 1.1.3.