Contents
The presence sensor sends its values to a broker via MQTT, and openHAB reads them there. The simplest way to integrate it is via Home Assistant discovery: openHAB reads the sensor's device description and uses it to create the channels presence, motion, stationary person, distances, zone, brightness, temperature, humidity, air pressure, plus siren, timeout, LED and the selection fields for alert, sound, installation and resolution. This applies equally to KL LD and KL. If you prefer to work with text files, use the alternative at the end of “Setup”, although it comes with fewer settings.
In this guide, <Hauptthema> stands for whatever is entered on the sensor under Connections → Main topic. Enter your own without the angle brackets.
Requirements
- openHAB 5.2 (tested with 5.2.5). Older versions have not been tested.
- An MQTT broker (e.g., Mosquitto) that both the sensor and openHAB can reach.
- KL LD presence sensor with firmware 1.1.3 or newer, or KL with firmware 3.2.3 or newer (older versions also work, see Limitations).
- Add-ons from the Add-on Store, section Bindings:
| Add-on | Purpose |
|---|---|
MQTT Binding |
Connection to the broker |
Home Assistant Binding |
finds the sensor and creates the channels |
This route needs no other add-ons. The first installation downloads a few things and takes about a minute.
Setting up the sensor
Sensor web interface → Connections:
| Field | Value |
|---|---|
| Connection type | MQTT Broker |
| Server | Name or IP address of the broker |
| Port | 1883 |
| Login / Password | only if the broker requires them |
| Client id | unique for each sensor; only letters, digits and _
|
| Main topic | freely selectable; only letters, digits and _
|
| Home Assistant | turn on |
Save your settings. After a short time, “connected” appears at the bottom of the page. In openHAB, the sensor later appears under this name: System → Sensor name. All topics and values are listed in the user manual.
Setup
The openHAB sidebar follows your language setting, while the pages behind it show their buttons in English. The names are given here exactly as displayed.
-
Add-on Store → Bindings: Install
MQTT BindingandHome Assistant Bindingeach with Install. -
Create the broker (not needed if openHAB is already connected to the broker): Settings → Things → + →
MQTT Binding→MQTT Broker.Field Value Broker Hostname/IP Name or IP address of the broker Broker port 1883(only visible after clicking Show advanced)Username / Password only if the broker requires them (also under Show advanced) Save with Create Thing. Afterward, the broker must show
ONLINE. -
Settings → Things → Inbox: The sensor appears there under its sensor name. Tap it → Add as Thing.
-
Open the new Thing → tab Channels → Add Equipment to Model, tick the channels you want and, when creating them, check the field Unit:
Channel Meaning Unit Presenceperson detected (moving or stationary), the main value none Motionmoving person none Stationarystationary person none Zonename of the zone; -= nobody there or outside all zonesnone Distancedistance of the detected person cmBrightnessBrightness lxTemperatureTemperature °CHumidityHumidity %Air PressureAir pressure hPaSirenalarm sound on/off none TimeoutTimeout sopenHAB suggests
mfor the distances. Change this tocm, otherwise the Item shows2 minstead of250 cm.
Alternative: channels by hand (text files)
Instead of the Home Assistant Binding this needs the add-on JSONPATH Transformation (Add-on Store → Transformation Add-ons). Brightness, temperature, humidity and air pressure only arrive in the JSON status. Put the two files in the folders things and items of your openHAB configuration (for Linux packages /etc/openhab/). In them, replace <Hauptthema> and replace <Broker> with the ID of the broker Thing (the last part of its UID mqtt:broker:…).
things/praesenz.things:
Thing mqtt:topic:<Broker>:praesenz "Präsenzmelder" (mqtt:broker:<Broker>) [ availabilityTopic="tele/<Hauptthema>/LWT", payloadAvailable="Online", payloadNotAvailable="Offline" ] {
Channels:
Type switch : praesenz "Präsenz" [ stateTopic="stat/<Hauptthema>/PRESENCE", on="True", off="False" ]
Type switch : bewegt "Bewegung" [ stateTopic="stat/<Hauptthema>/MOVING", on="True", off="False" ]
Type switch : ruhend "Ruhend" [ stateTopic="stat/<Hauptthema>/STATIONARY", on="True", off="False" ]
Type string : zone "Zone" [ stateTopic="stat/<Hauptthema>/ZONE" ]
Type number : abstand "Abstand" [ stateTopic="stat/<Hauptthema>/DETECTION_DIST", unit="cm" ]
Type number : helligkeit "Helligkeit" [ stateTopic="tele/<Hauptthema>/STATE", transformationPattern="JSONPATH:$.brightness", unit="lx" ]
Type number : temperatur "Temperatur" [ stateTopic="tele/<Hauptthema>/STATE", transformationPattern="JSONPATH:$.temperature", unit="°C" ]
Type number : feuchte "Luftfeuchte" [ stateTopic="tele/<Hauptthema>/STATE", transformationPattern="JSONPATH:$.humidity", unit="%" ]
Type number : luftdruck "Luftdruck" [ stateTopic="tele/<Hauptthema>/STATE", transformationPattern="JSONPATH:$.pressure", unit="hPa" ]
Type switch : sirene "Sirene" [ stateTopic="stat/<Hauptthema>/SIREN", commandTopic="cmnd/<Hauptthema>/SIREN", on="True", off="False" ]
Type number : nachlauf "Nachlaufzeit" [ stateTopic="stat/<Hauptthema>/DETECTION_TIMEOUT", commandTopic="cmnd/<Hauptthema>/DETECTION_TIMEOUT", min=5, max=300, step=1, unit="s", formatBeforePublish="%.0f" ]
Type string : alarm "Alarm" [ stateTopic="stat/<Hauptthema>/BUZZER", commandTopic="cmnd/<Hauptthema>/BUZZER", allowedStates="0,1,2" ]
Type string : ton "Alarmton" [ stateTopic="stat/<Hauptthema>/SOUND", commandTopic="cmnd/<Hauptthema>/SOUND", allowedStates="0,1,2,3,4,5,6,7,8,9,10,11,12,13,14" ]
}
For the KL, set min=0 instead of min=5 in the line nachlauf.
items/praesenz.items:
Switch PM_Praesenz "Präsenz" { channel="mqtt:topic:<Broker>:praesenz:praesenz" }
Switch PM_Bewegt "Bewegung" { channel="mqtt:topic:<Broker>:praesenz:bewegt" }
Switch PM_Ruhend "Ruhend" { channel="mqtt:topic:<Broker>:praesenz:ruhend" }
String PM_Zone "Zone [%s]" { channel="mqtt:topic:<Broker>:praesenz:zone" }
Number:Length PM_Abstand "Abstand [%d cm]" { channel="mqtt:topic:<Broker>:praesenz:abstand", unit="cm" }
Number:Illuminance PM_Helligkeit "Helligkeit [%.0f lx]" { channel="mqtt:topic:<Broker>:praesenz:helligkeit", unit="lx" }
Number:Temperature PM_Temperatur "Temperatur [%.1f °C]" { channel="mqtt:topic:<Broker>:praesenz:temperatur", unit="°C" }
Number:Dimensionless PM_Feuchte "Luftfeuchte [%.0f %%]" { channel="mqtt:topic:<Broker>:praesenz:feuchte", unit="%" }
Number:Pressure PM_Luftdruck "Luftdruck [%.1f hPa]" { channel="mqtt:topic:<Broker>:praesenz:luftdruck", unit="hPa" }
Switch PM_Sirene "Sirene" { channel="mqtt:topic:<Broker>:praesenz:sirene" }
Number:Time PM_Nachlauf "Nachlaufzeit [%d s]" { channel="mqtt:topic:<Broker>:praesenz:nachlauf", unit="s" }
String PM_Alarm "Alarm [%s]" { channel="mqtt:topic:<Broker>:praesenz:alarm", stateDescription=""[ options="0=aus,1=bei Präsenz,2=ohne Präsenz" ], commandDescription=""[ options="0=aus,1=bei Präsenz,2=ohne Präsenz" ] }
String PM_Ton "Alarmton [%s]" { channel="mqtt:topic:<Broker>:praesenz:ton", stateDescription=""[ options="0=Standard,1=Martinshorn,2=Wecker,3=Räumung,4=Türklingel,5=Gong,6=SENVOLON,7=Für Elise,8=Bergkönig,9=Ode an die Freude,10=Wiegenlied,11=Entertainer,12=Rhapsody,13=Boléro,14=Fanfare" ], commandDescription=""[ options="0=Standard,1=Martinshorn,2=Wecker,3=Räumung,4=Türklingel,5=Gong,6=SENVOLON,7=Für Elise,8=Bergkönig,9=Ode an die Freude,10=Wiegenlied,11=Entertainer,12=Rhapsody,13=Boléro,14=Fanfare" ] }
formatBeforePublish="%.0f" ensures that openHAB sends whole numbers. The sensor does not accept values with decimal places. Multiple sensors: Copy the Thing block, give it an ID other than praesenz and adjust the Items.
Quick test
-
The sensor's Thing shows
ONLINE. -
Walk into the detection area: The Item for
Presence(orPM_Praesenz) changes toON, and zone and distance fill in. Leave the room: After the timeout, presence isOFF, the zone-and the distance0 cm. -
Brightness, temperature, humidity and air pressure only arrive with the status message, so after one Publish interval at the latest. You can trigger it immediately from the broker:
mosquitto_pub -h <Broker-Adresse> -t cmnd/<Hauptthema>/UPDATE -m 1
If the Inbox stays empty: on the sensor, Home Assistant is not turned on, or the sensor and openHAB are connected to different brokers.
Optional
Adjusting from openHAB. Via discovery you can operate:
Siren (alarm sound on/off), Timeout (timeout), Led, and the selection fields Alert (alert: off, with presence, without presence), Sound (alarm sound), Installation (ceiling/wall) and Distance resolution. openHAB only sends values within the permitted range. The sensor reports the accepted value back. The timeout needs an Item with Unit s (suggested when creating it). Numbers with decimal places are truncated.
Caution with the switch Calibration (KL LD) or Auto configuration (KL). It starts the learning of the thresholds. The calibration of the KL LD cannot be cancelled. It is better to start it in the sensor's web interface.
Availability. The Thing follows tele/<Hauptthema>/LWT: ONLINE, as long as the sensor is connected, OFFLINE a good 20 seconds after a connection drop. The Items keep their last value in the meantime.
Rules. For “is anyone there?”, check the presence Item for ON/OFF, not the distance.
Limitations
- The channel names from discovery are in English and come from the sensor. The labels of the Items are up to you.
- openHAB does not create the channel “Sound notification” (play a sound for a specific duration). The Home Assistant Binding does not know this type of entry. The selected sound is played by the switch
Siren. - Discovery shows temperature and the other measured values without decimal places. For more digits, change the State
Description in the Item (pattern, e.g.,
%.1f %unit%). -
RSSIneeds the UnitdBm, otherwise openHAB shows watts. -
The distances change very often (several times per second when people are walking). Every change ends up in the openHAB event log. Only create Items for
Motion DistanceandStationary Distanceif you need them, and do not include them in a persistence. - The range in gates (KL) is not available as a channel. It is set in the sensor's web interface.
- Older firmware (KL LD up to 1.1.2, KL up to 3.2.2): after the sensor restarts, the old presence value may remain until the first change. Please update the firmware.
- Multiple sensors: a separate Client id and a separate main topic for each device.
Verification status
Tested with openHAB 5.2.5 and sensor firmware KL LD 1.1.3 and KL 3.2.3.