Presence sensor for Home Assistant: local integration via MQTT

Presence sensor for Home Assistant: local integration via MQTT

A presence sensor for Home Assistant should reliably detect whether someone is in the room, providing true presence detection even when nobody is moving, and deliver its values without a detour through a cloud. The Senvolon presence sensors connect to your MQTT broker via Wi-Fi, and Home Assistant creates all entities automatically. Here you can read what matters and how to integrate the presence sensor in five steps.

What matters in a presence sensor for Home Assistant

  • True presence instead of motion: a radar also detects someone who is reading, sitting at a desk, or sleeping. An infrared motion detector (PIR) only sees motion, so the light goes out in the middle of the movie.
  • Local, without a hub: the values go via MQTT straight to the broker in your network. No manufacturer hub, no app, and no account are needed.
  • Automatic integration: with MQTT Discovery, the presence sensor registers itself with Home Assistant. You enter the broker once, and the rest happens on its own.
  • Zones as separate entities: on the KL MZ, every detection zone, such as the sofa or the dining table, becomes its own entity with the name you give it.
  • Room climate in the same device: the KL, KL LD, and KL MZ also measure temperature, humidity, and air pressure. You do not need a second sensor for heating and ventilation.

The overview of all presence sensors shows which model suits your room: the KL for single rooms, the KL LD with 9 m for large rooms, and the KL MZ with zones and multiple people.

Into Home Assistant in five steps

  1. Install an MQTT broker. If you are not using a broker yet: in Home Assistant, under Settings, Add-ons, Add-on Store, install and start the Mosquitto broker.
  2. Set up the MQTT integration. Under Settings, Devices & services, MQTT usually already appears as discovered. Click Configure and confirm.
  3. Create a login for the presence sensor. Under Settings, Add-ons, Mosquitto broker, open the Configuration tab and add an entry with user name and password under “Logins”, for example mqtt-sensor. Save and restart the add-on. A separate user in Home Assistant is not needed for this.
  4. Connect the presence sensor. Open the presence sensor's interface in the browser (its IP address), then Connections. Enter there:
    • Connection type: MQTT Broker
    • Server: the IP address of Home Assistant, port 1883
    • User and password from step 3
    • Main topic: a unique name without special characters, such as praesenz_wohnzimmer
    • Home Assistant: switch on
    Save. The presence sensor reconnects.
  5. Done. After about a minute, the presence sensor is listed under Settings, Devices & services, MQTT as a separate device. You name the zones in the presence sensor's interface, on the KL MZ under Zone names, on the KL and KL LD under Zones; Home Assistant adopts the name. How to create zones on the KL MZ is explained in Setting up zones on the KL MZ presence sensor.
KL MZ presence sensor in Home Assistant, discovered automatically via MQTT: presence, zone Sofa, number of people, brightness, temperature, humidity, air pressure, siren, LEDs, and settings
This is how the KL MZ appears in Home Assistant: discovered automatically via MQTT, without a hub and without an app.

These values arrive in Home Assistant

KL MZ KL and KL LD
Presence for the room and for each zone for the room, plus motion and stationary presence
People and zones number of people detected, presence per zone (up to 4 freely drawn zones) which zone is occupied (distance ranges with names, KL up to 3, KL LD up to 5)
Distance no distance of the detected person, separately for motion and stationary presence
Brightness in lux in lux
Temperature, humidity, air pressure yes yes
Switching from Home Assistant siren, LEDs siren, LED

On the KL MZ you can also set sensitivity, mounting type, timeout, and alarm mode from Home Assistant.

You use the same MQTT values when you run the presence sensor with ioBroker, openHAB, or Node-RED. With these values you build the typical automations: light only when someone is present and it is dark, heating only in occupied rooms, ventilation based on humidity. Step by step: lighting control with the KL MZ, smart alarm system, and presence simulation while on vacation.

If the presence sensor does not appear

  • Home Assistant switched on? Without the Home Assistant switch on the Connections page, Home Assistant does not create anything automatically.
  • User and password: both must match the entry under “Logins” in the Mosquitto broker; if the credentials are wrong, the log of the Mosquitto broker says “not authorised”.
  • Main topic used twice? Two devices with the same main topic overwrite each other.
  • Wi-Fi: the presence sensor uses 2.4 GHz. If the interface shows “connected”, the cause is the broker.
  • Values “unknown”: right after setup, until the first message arrives. This takes one send interval at most. Temperature, humidity, and air pressure need up to 30 minutes after power-on until they are accurate.
  • Check the connection: on the KL, KL LD, and KL MZ, the LED shows green when the MQTT connection is up and blue when only Wi-Fi is connected. If the “LED” switch is off, the LED goes dark 90 seconds after startup. Under System you can switch on a log that records errors of the Wi-Fi and MQTT connection.

Appendix: manual setup for older firmware

Older presence sensors (base model with firmware before version 2.4) do not support MQTT Discovery yet. It is best to update the firmware via the presence sensor's interface. Alternatively, enter the sensors by hand in configuration.yaml and replace TOPIC with your main topic:

mqtt:
  sensor:
    - name: "Brightness"
      unique_id: "PS_Brightness"
      state_topic: "tele/TOPIC/STATE"
      value_template: "{{ value_json.light }}"
      unit_of_measurement: "%"
    - name: "Presence"
      unique_id: "PS_Presence"
      state_topic: "stat/TOPIC/PRESENCE"
    - name: "Distance"
      unique_id: "PS_Distance"
      state_topic: "stat/TOPIC/DETECTION_DIST"
      unit_of_measurement: "cm"

Then check the configuration and restart Home Assistant.