Intelligent Lighting Control with the Senvolon Presence Detector KL MZ: Light Only When Truly Needed
Time-controlled lighting automation often suffers from a fundamental problem: it ignores reality. On a cloudy November afternoon, a room may already be dark, while on a bright summer evening at 9 PM, no artificial light is needed.
The obvious countermeasure, using sunset as a trigger instead of a fixed time, only shifts the problem. While sunset time moves with the seasons, appearing dynamic, it remains at its core a calculated time. It knows nothing of dense cloud cover, a room's north-facing orientation, or lowered blinds. It merely estimates brightness instead of truly measuring it.
Control only becomes truly demand-driven when it evaluates the light actually arriving in your room and combines it with a second question: Are you there?
This is precisely what the KL MZ presence detector's integrated brightness sensor enables, locally, without a cloud, and with direct Home Assistant integration.
Prerequisites
The following components are required:
- The KL MZ presence detector is simply integrated into your WLAN, allowing direct access via a web browser.
- Home Assistant (version 2024.1 or newer, HA OS / Supervised recommended).
- Mosquitto MQTT Broker – installed and started as an official Home Assistant add-on.
-
A dimmable, switchable light – any HA-compatible lamp (Zigbee, Z-Wave, WLAN). Important: This guide uses brightness levels (brightness_pct) and night light mode. Both require a dimmable light. The automation fundamentally works with a simple on/off switch too – but then the brightness gradations are omitted, and you remove the brightness_pct lines.
Step-by-Step Guide
Step 1: Set up Mosquitto MQTT Broker
- In Home Assistant, navigate to Settings → Add-ons → Add-on Store.
- Search for "Mosquitto broker," install the add-on, and start it.
- Enable the "Start on boot" option so the broker is available even after an HA restart.
- Home Assistant automatically detects the local broker and offers MQTT integration. If not: Settings → Devices & Services → Add Integration → "MQTT" – Broker: localhost, Port: 1883.
Security Tip: Create a separate MQTT user within the Mosquitto add-on (or under HA users) instead of using anonymous connections or your main account. This keeps access cleanly separated and simplifies later troubleshooting.
Important: Which broker address do you enter for the sensor? The sensor is an independent device on the network and must always address the actual network address of your HA host (e.g., 192.168.1.100), never localhost. From the sensor's perspective, localhost would point to the sensor itself, not to Home Assistant. This applies regardless of whether HA runs as HAOS or in a Docker container. Only HA-internal communication to the broker runs via localhost. This refers to the MQTT integration from Step 1, not the sensor configuration in Step 2.
Step 2: Connect Senvolon KL MZ to MQTT
- Access the sensor's web app in your browser (e.g., http://[Sensor-IP]). If your router supports name resolution, you can also use the hostname (e.g., http://hostname.fritz.box).
- Navigate to the Connections settings.
- Select "MQTT Broker" as the connection type.
- Enter the following values:
- Server: IP address of the HA host (e.g., 192.168.1.100) – not localhost.
- Port: 1883.
- Login / Password: the MQTT credentials from Step 1.
- Main Topic: defines the topic under which data is published (e.g., wohnzimmer_praesenz).
- IMPORTANT: Make sure to enable the "Home Assistant" switch at the bottom of the page. Only when this is active will MQTT Discovery be enabled.
- Save the settings with "Save" for them to take effect.
Why the main topic is so important: This name becomes part of all MQTT topics (e.g., tele/wohnzimmer_praesenz/STATE). Renaming it later means all automations must be adjusted. So, take your time to consider the name.
Status Check: You can directly check if the connection is successful in the sensor's configuration menu. The current connection status is displayed in the bottom left. If it says "interrupted," there is no connection to the broker, and no data is transmitted to Home Assistant.
Step 3: Verify MQTT Auto-Discovery in Home Assistant
After correct MQTT configuration and the HA switch being activated, the presence detector will be automatically discovered and configured by Home Assistant.
- Navigate to Settings → Devices & Services → MQTT → Devices tab.
- The Senvolon sensor should appear there as a device, with all entities already created.
- Verify the entity IDs relevant for this automation under Developer Tools → States:
- binary_sensor.wohnzimmer_praesenz_presence (Presence: ON / OFF)
- sensor.wohnzimmer_praesenz_illuminance (Lux value, numerical)
Step 4: Create Two Lux Thresholds as Customizable Helpers
We deliberately create two thresholds: one for turning on and a higher one for turning off. The reason is hysteresis. With only a single threshold, the light would flicker second by second at dusk as the measured brightness fluctuates around that single value. You can find more about this in the box below.
We create both values as number helpers. This way, you can easily readjust them later via the dashboard, without any code changes.
Navigate to Settings → Devices & Services → Helpers → Create Helper → Number and create two helpers:
Helper 1 – On Threshold
- Name: Lux ON Threshold Living Room
- Minimum: 0 / Maximum: 1000
- Step: 10
- Unit: lx
- Default value: 200
Helper 2 – Off Threshold
- Name: Lux OFF Threshold Living Room
- Minimum: 0 / Maximum: 1000
- Step: 10
- Unit: lx
- Default value: 400
Why two thresholds instead of one? If ON and OFF had the same value (e.g., 200 lx), an endless loop would occur: the light turns on → its own lamp raises the measured brightness above 200 lx → the light turns off again → the room is dark → the light turns on again. By having a gap between turning on (below 200 lx) and turning off (above 400 lx), this effect is prevented.
Step 5: Create "Light ON" Automation
Navigate to Settings → Automations → Create Automation → Start with an empty automation and insert the following YAML code:
alias: "Living Room: Turn on light with presence and darkness"
description: >
Turns on the light when the Senvolon presence detector detects presence AND
the Lux value falls below the ON threshold. In absolute darkness, a
gentle night light mode is used.
triggers:
- trigger: state
entity_id: binary_sensor.wohnzimmer_praesenz_presence
to: "on"
id: presence_detected
- trigger: numeric_state
entity_id: sensor.wohnzimmer_praesenz_illuminance
below: input_number.lux_ein_schwelle_wohnzimmer
for:
minutes: 1
id: lux_dropped
# Debouncing: short brightness fluctuations are ignored.
conditions:
- condition: state
entity_id: binary_sensor.wohnzimmer_praesenz_presence
state: "on"
- condition: numeric_state
entity_id: sensor.wohnzimmer_praesenz_illuminance
below: input_number.lux_ein_schwelle_wohnzimmer
- condition: state
entity_id: light.deckenlampe_tv
state: "off"
# Logic:
# The light only turns on if someone is present, the room is dark enough,
# and the light is currently off.
actions:
- choose:
- conditions:
- condition: numeric_state
entity_id: sensor.wohnzimmer_praesenz_illuminance
below: 15
sequence:
- action: light.turn_on
target:
entity_id: light.deckenlampe_tv
data:
brightness_pct: 15
transition: 2
default:
- action: light.turn_on
target:
entity_id: light.deckenlampe_tv
data:
brightness_pct: 80
transition: 1
mode: single
The logic behind it: The light only turns on if both conditions are met (presence detected + room is dark), regardless of which event occurs first.
The "Night Light" Mode without Fixed Times
The light only turns on when it's dark. But how bright should it be? If you get a glass of water at 3 AM, 80% brightness is like an interrogation spotlight.
Since we are building smart brightness control, we simply use the Senvolon sensor's lux value to differentiate between "twilight" and "deep night," without fixed times. This is exactly what the choose block above does:
- Scenario A (twilight / cloudy): The lux value is below the ON threshold (e.g., 200 lx), but there's still some residual light. The light turns on at 80%.
- Scenario B (absolute darkness / night): The room is pitch black (below 15 lx). The system recognizes deep night and turns on the light gently at only 15%.
Step 6: Create "Light OFF" Automation
alias: "Living Room: Turn off light with absence or sufficient daylight"
description: >
Turns off the light when no presence is detected OR the Lux value
rises above the higher OFF threshold.
triggers:
- trigger: state
entity_id: binary_sensor.wohnzimmer_praesenz_presence
to: "off"
id: no_presence
- trigger: numeric_state
entity_id: sensor.wohnzimmer_praesenz_illuminance
above: input_number.lux_aus_schwelle_wohnzimmer
for:
minutes: 2
id: lux_sufficient
# Buffer: short brightness peaks do not trigger shutdown.
conditions: []
actions:
- action: light.turn_off
target:
entity_id: light.deckenlampe_tv
mode: single
Why the higher threshold and the for: 2min?
Turning off only takes effect when the measured brightness exceeds the OFF threshold (e.g., 400 lx), and only then if this state persists for two minutes. This prevents a short burst of brightness or the lamp's own light from abruptly turning off the light. Turning off due to absence (no_presence) occurs immediately, as there's no reason to wait here.
Step 7: Create a Dashboard Card for Adjustment
To make the effort of creating two helpers worthwhile, we'll create a small Lovelace card. It shows both thresholds for adjustment, as well as the current lux value and presence status, which is ideal for later fine-tuning. Simply open your dashboard, click on Add Card > Manual, and insert the following:
type: vertical-stack
cards:
- type: entities
title: Light Control by Lux Value
entities:
- entity: input_number.lux_ein_schwelle_wohnzimmer
name: ON Threshold
- entity: input_number.lux_aus_schwelle_wohnzimmer
name: OFF Threshold
- entity: sensor.wohnzimmer_praesenz_illuminance
name: Current Brightness
- entity: binary_sensor.wohnzimmer_praesenz_presence
name: Presence
- type: entities
title: Light
entities:
- entity: light.deckenlampe_tv
name: Ceiling Lamp
Tip for setting: Observe over a day what lux value is displayed on the card when you feel the light is currently needed. That is your ON value. Set the OFF threshold significantly higher (rule of thumb: double) to ensure enough separation.
Why isn't the night value also a helper? This is a conscious decision. In this guide, you work with three lux limits: the ON threshold, the OFF threshold, and the night limit (the below: 15 in the choose block of the ON automation, which switches between 80% and 15% brightness). You calibrate the first two empirically over several days, which is why they are on the dashboard as helpers.
The night limit ("practically pitch black"), on the other hand, is almost never adjusted, which is why it remains fixed in the automation for simplicity.
As a rule of thumb: values that you regularly tweak should be moved to helpers. Pure structural values that never change can be directly in the YAML. This includes the night limit or the debounce times (for: 1min and for: 2min). You could theoretically have hardcoded all three values into the automation. The helpers simply provide user comfort without having to open the editor every time.
Do you want to adjust the night value more often? Then simply create a third helper using the same pattern and replace below: 15 with below: input_number.lux_nacht_schwelle_wohnzimmer.
Tips & Troubleshooting
Brightness cannot be calibrated with an offset: Unlike temperature, humidity, and air pressure, the sensor does not offer an offset for brightness correction. If your sensor systematically measures too bright or too dark, do not correct this with an offset, but directly via the lux thresholds themselves. That's exactly what the helpers on the dashboard are for.
Lux automation reacts slowly: Presence is reported immediately, but the lux value via MQTT is only reported every 5 minutes by default (transmission interval). For lighting control, this is usually not critical because daylight changes slowly anyway. If you want it more reactive, you can reduce the transmission interval in the sensor's MQTT configuration.
False alarms due to interfering objects: Movements from fans or air conditioners can be detected by the radar sensor. Four zones are available for excluding interference. In addition to manual definition, automatic detection is also possible. However, before activating "Set Interference Zones," ensure that no one is present in the detection area.
Optimize hold time (DELAY): The hold time determines how long presence is maintained after a zone has been left. Thanks to 60 GHz FMCW radar technology, which registers even the slightest movements like breathing, even completely still or sleeping people are reliably detected. Extremely long hold times, as with classic infrared detectors, are unnecessary; values between 15 and 30 seconds are usually sufficient.
Light flickers or constantly switches: This is almost always a threshold or placement problem. Check whether the ON and OFF thresholds have enough distance and whether the controlled lamp directly illuminates the sensor. When in doubt, you should move the sensor or increase the distance between the thresholds.
Sensor does not appear in HA: Check whether the "Home Assistant" switch has been activated and saved in the sensor's web app. Take a look at the sensor's MQTT broker configuration menu: if the status at the bottom left is "disconnected", something is blocking communication. Also, check the Mosquitto log to see if the connection from the sensor was successfully established.
Conclusion
With our KL MZ presence detector and Home Assistant, you get a lighting control that is truly intelligent and dynamic. It provides no unnecessary artificial light during daylight, no abrupt extinguishing when sitting still, a soft night light in complete darkness, and thanks to the two thresholds, no annoying flickering at dusk. All of this works 100% locally.
Learn more about our presence detectors and their advanced functions, from zone-based room monitoring to multi-person tracking, directly on our product page.