Fibaro Home Center 3 / Yubii Home: Integrating the KL LD and KL presence sensors

Learn how to integrate the KL LD and KL presence sensors into Fibaro Home Center 3 / Yubii Home, with all settings on the sensor and on the hub.

Applies to KL LD and KL · Sensor firmware KL LD 1.1.3, KL 3.2.3 and newer · As of 12/5/2026

Contents

The Home Center integrates the presence sensor through a small Quick App (Lua). The sensor and the Quick App are connected to the same MQTT broker. The sensor reports every change in presence immediately, and the Quick App passes it on to the Home Center without delay. The Quick App itself is a device of the type motion sensor, which you use in scenes and in the app like any other motion sensor. If you like, brightness, temperature, humidity and air pressure are added as child devices of their own. This applies equally to KL LD and KL.

In this guide, <Hauptthema> stands for whatever is entered on the sensor under Connections → Main topic. Enter your own, without the angle brackets.

Requirements

  • Home Center 3, Home Center 3 Lite or Yubii Home. For the child devices: firmware 5.030 or newer.
  • An MQTT broker on the network, e.g. Mosquitto on a NAS. The Fibaro hub itself is not a broker.
  • KL LD presence sensor with firmware 1.1.3 or KL with firmware 3.2.3 (older versions, see Limitations).

Setting up the sensor

Sensor web interface → Connections:

Field Value
Connection type MQTT Broker
Server Name or IP address of the broker
Port Port of the broker, usually 1883
Login / password only if the broker requires them
Client id unique for each sensor, e.g. wohnzimmer
Main topic freely selectable, only letters, digits and _
Home Assistant off (the Quick App does not need it)

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, Timeout), not in the Quick App.

Setup

  1. In the hub's web interface, open the device list (Devices), click the plus to add a device and select Other Device and then Quick App (names as shown in the English interface).

  2. Fill in the dialog:

    Field Value
    Name Präsenz (freely selectable)
    Room as you like
    Device type Motion sensor (com.fibaro.motionSensor)
  3. Open the new Quick App, tab Edit & Preview, replace the existing code completely with this one and adjust the lines marked with <<<:

    -- SENVOLON presence sensor KL LD / KL -> Fibaro HC3 / Yubii Home (MQTT)
    local BROKER   = "<IP des Brokers>"  -- <<< ANPASSEN: Name oder IP-Adresse des Brokers
    local PORT     = 1883                -- <<< ANPASSEN, falls abweichend
    local USER     = ""                  -- <<< nur wenn der Broker eine Anmeldung verlangt
    local PASSWORD = ""                  -- <<< nur wenn der Broker eine Anmeldung verlangt
    local TOPIC    = "<Hauptthema>"      -- <<< ANPASSEN: Hauptthema des Sensors
    local VALUES   = false               -- <<< true: Helligkeit, Temperatur, Luftfeuchte, Luftdruck
    local RETRY    = 30                  -- seconds until a new connection attempt
    
    -- Value children: field in tele/<topic>/STATE, name and device type
    local FIELDS = {
      {field = "brightness",  name = "Helligkeit",  type = "com.fibaro.lightSensor"},
      {field = "temperature", name = "Temperatur",  type = "com.fibaro.temperatureSensor"},
      {field = "humidity",    name = "Luftfeuchte", type = "com.fibaro.humiditySensor"},
      {field = "pressure",    name = "Luftdruck",   type = "com.fibaro.multilevelSensor", unit = "hPa"},
    }
    
    local PRESENCE = "stat/" .. TOPIC .. "/PRESENCE"
    local STATE    = "tele/" .. TOPIC .. "/STATE"
    local LWT      = "tele/" .. TOPIC .. "/LWT"
    
    class 'Value' (QuickAppChild)
    function Value:__init(device) QuickAppChild.__init(self, device) end
    function Value:show(v)
      if type(v) == "number" then self:updateProperty("value", v) end
    end
    
    function QuickApp:onInit()
      self:initChildDevices({
        ["com.fibaro.multilevelSensor"] = Value,
        ["com.fibaro.lightSensor"] = Value,
        ["com.fibaro.temperatureSensor"] = Value,
        ["com.fibaro.humiditySensor"] = Value,
      })
      if VALUES then
        for _, f in ipairs(FIELDS) do
          if not self:child(f.field) then
            local c = self:createChildDevice({name = f.name, type = f.type}, Value)
            c:setVariable("field", f.field)
            if f.unit then c:updateProperty("unit", f.unit) end
          end
        end
      end
      self:connect()
    end
    
    function QuickApp:child(field)
      for _, c in pairs(self.childDevices) do
        if c:getVariable("field") == field then return c end
      end
    end
    
    function QuickApp:connect()
      local options = {port = PORT, clientId = "hc3_praesenz_" .. self.id, keepAlivePeriod = 30}
      if USER ~= "" then
        options.username = USER
        options.password = PASSWORD
      end
      local ok, client = pcall(mqtt.Client.connect, "mqtt://" .. BROKER, options)
      if not ok then return self:retry(client) end
      self.client = client
      client:addEventListener('connected', function()
        if client ~= self.client then return end
        self:debug("Mit dem Broker verbunden")
        pcall(function() self:updateProperty("dead", false) end)
        client:subscribe(PRESENCE)
        if VALUES then client:subscribe(STATE) end
        client:subscribe(LWT)
      end)
      client:addEventListener('message', function(event)
        if client == self.client then self:onMessage(event.topic, event.payload) end
      end)
      client:addEventListener('closed', function()
        if client == self.client then self:retry("Verbindung getrennt") end
      end)
      client:addEventListener('error', function(event)
        if client == self.client then self:retry(event and (event.code or event.error)) end
      end)
    end
    
    function QuickApp:retry(reason)
      self:debug("Broker nicht erreichbar: " .. tostring(reason))
      pcall(function() self:updateProperty("dead", true) end)
      local old = self.client
      self.client = nil
      pcall(function() old:disconnect() end)
      fibaro.setTimeout(RETRY * 1000, function() self:connect() end)
    end
    
    function QuickApp:onMessage(topic, payload)
      if topic == PRESENCE then
        local on
        if payload == "True" then on = true elseif payload == "False" then on = false end
        if on ~= nil and on ~= self.last then
          self.last = on
          self:updateProperty("value", on)
          self:debug("Praesenz " .. tostring(on))
        end
      elseif topic == STATE then
        local ok, d = pcall(json.decode, payload)
        if not ok or type(d) ~= "table" then return end
        for _, c in pairs(self.childDevices) do c:show(d[c:getVariable("field")]) end
      elseif topic == LWT then
        local online = payload == "Online"
        pcall(function() self:updateProperty("dead", not online) end)
        if not online then self:debug("Sensor nicht erreichbar") end
      end
    end
    
    Setting in the code Value
    BROKER Name or IP address of the broker, e.g. 192.168.1.10
    PORT Port of the broker, the same as on the sensor (usually 1883)
    USER, PASSWORD leave empty unless the broker requires a login
    TOPIC Main topic of the sensor, note upper and lower case
    VALUES true: child devices for brightness, temperature, humidity, air pressure
  4. Save. The Quick App starts immediately and connects to the broker. The broker keeps the last state of presence ready, so it arrives right after connecting.

Quick test

  • Walk up and down in front of the sensor: the “Präsenz” device reports motion immediately. Leave the room: after the sensor's timeout, it resets.
  • The Quick App's log shows “Mit dem Broker verbunden” and, at every change, a line like Praesenz true.
  • Counter-check: enter a wrong main topic in the code and save. “Präsenz” then no longer changes. Afterwards, set it back to the correct one.

Optional

Brightness, temperature, humidity, air pressure: set VALUES = true and save. Four child devices are created once: “Helligkeit” (lx), “Temperatur” (°C), “Luftfeuchte” (%) and “Luftdruck” (general measured-value device with the unit hPa). The values arrive at the sensor's Publish interval (5 minutes as delivered). If you later set VALUES back to false, the child devices no longer receive values and show the last one. Then delete them in the device list.

Limitations

  • The Quick App only reads. You change the sensor's settings (timeout, LED, alert) in its web interface.
  • If the sensor fails, the broker reports it after about 20 to 30 seconds. The Quick App then marks the “Präsenz” device as unreachable, and the log shows “Sensor nicht erreichbar”. The last value stays, even “motion”. The child devices are not marked.
  • If the broker is not reachable, the Quick App also marks “Präsenz” as unreachable and tries again every 30 seconds. Once the connection is back, it removes the mark.
  • 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. Update the firmware.
  • The broker's login and password are in plain text in the code.

Verification status

This guide is based on public documentation for the Home Center 3; the code has been tested with Lua 5.3.6.

Next

Manual

KL LD presence sensor

Mounting, connecting to Wi-Fi, setting up.

Manual

KL presence sensor

Mounting, connecting to Wi-Fi, setting up.

Smart home

All systems

An overview of the guides for all presence sensors and systems.

Support

Help and contact

Phone, email and contact form.