Contents
ioBroker integrates the sensor via MQTT. The sensor sends its values to a broker, and ioBroker reads them with the adapter MQTT Broker/Client
(mqtt). The adapter creates a datapoint for each value. Fill level, fill height and contents are numbers there. The temperature and the yes/no values (availability, fault) become usable datapoints through an alias each, if needed. The Sonoff adapter is not suitable for this sensor.
In all examples, <Hauptthema> stands for the value entered on the sensor under
Connections → Main topic (e.g. zisterne). The angle brackets are not part of it. For example, stat/<Hauptthema>/REL_LEVEL becomes
stat/zisterne/REL_LEVEL.
Prerequisites
- Sensor with firmware 4.2.8 or newer.
- ioBroker with js-controller 6.0.11 or newer and Admin 7.6.20 or newer, as required by MQTT adapter 8.1.2. Tested with js-controller 7.2.5 and Admin 8.3.5.
- An MQTT broker on the network, e.g. Mosquitto (recommended, option A). If you do not have one, you can run the adapter itself as a broker (option B).
Setting up the sensor
Sensor web interface → Connections. All fields are described in Interfaces of the level sensor for smart home systems; for ioBroker, these are the ones that matter:
| Field | Value |
|---|---|
| Connection type | MQTT Broker |
| Server | IP address of the broker (option B: that of the ioBroker computer) |
| Port | 1883 |
| Login / Password | only if the broker requires them |
| Main topic | e.g. zisterne
|
| Home Assistant | off |
Setup
Option A: ioBroker as a client on an existing broker (recommended)
-
In Admin, open Adapters and 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. -
Tab MQTT settings:
Field Value Publish own states on connect off Set retain flag off (default) Mask to publish own states mqtt.0.*(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. Open Objects and after a few seconds you will see the datapoints under
mqtt.0.stat.<Hauptthema>andmqtt.0.tele.<Hauptthema>.
Option B: ioBroker itself as the broker
Only useful if there is no broker. Like option A, with these differences:
| Field | Value |
|---|---|
| first selection field (labeled “IP”) | Server/Broker |
| Port | 1883 |
| User / Password | choose freely and enter on the sensor as login / password |
On the sensor, enter under Server the IP address of the ioBroker computer. The tab Client settings is omitted. In this option, only read; do not set any values (see Limitations).
Quick test
Go to Objects mqtt.0.stat.<Hauptthema> and expand it:
| Datapoint | Expected |
|---|---|
mqtt.0.stat.<Hauptthema>.REL_LEVEL |
Number, fill level in % |
mqtt.0.stat.<Hauptthema>.LEVEL |
Number, fill height in cm |
mqtt.0.stat.<Hauptthema>.FILLING |
Number, contents in liters |
mqtt.0.tele.<Hauptthema>.LWT |
Text Online
|
mqtt.0.tele.<Hauptthema>.STATE |
Text in curly braces, contains "rel_level"
|
If the datapoints are missing, search the Log for mqtt.0. There you must find
Connected to … and Subscribe on "stat/<Hauptthema>/#" listed. If the log shows a different main topic than the sensor, that is the cause.
In VIS, Jarvis and other interfaces, you select the datapoints by their object ID, like any other.
Optional
Temperature, availability and fault as separate datapoints
The temperature is only contained in the text of STATE. Boolean values arrive as the text
True/False and not as a switch. An alias turns this into a usable datapoint: under Objects select the source datapoint, then click Create alias from this object, then in the alias switch on
Use conversion functions and enter under Converter on read the following:
| Alias | Source (Alias state ID) | State type | Converter on read |
|---|---|---|---|
| Temperature in °C | mqtt.0.tele.<Hauptthema>.STATE |
Number | JSON.parse(val).temperature |
| Reachable | mqtt.0.tele.<Hauptthema>.LWT |
Boolean | val === 'Online' |
| Sensor element fault | mqtt.0.stat.<Hauptthema>.PROBLEM |
Boolean | val === 'True' |
| Outside the tank | mqtt.0.stat.<Hauptthema>.OUT_OF_RANGE |
Boolean | val === 'True' |
The same method works for any other value in STATE such as
JSON.parse(val).signal for the Wi-Fi signal strength.
Alarm
mqtt.0.stat.<Hauptthema>.ALERT contains MIN, MAX or (with no alarm) no value (null). The datapoint is only created once the sensor sends something under this topic for the first time. For a notification, check for “value is MIN” or “value is MAX”, not for “has changed”.
Setting values
Option A only. 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 and open Objects mqtt.0 to add a sub-object:
| Field | Value |
|---|---|
| Type | State |
| State type | Number (for ALERT_MIN/ALERT_MAX: string) |
| Name | cmnd.<Hauptthema>.MINI |
If you write 20 to this datapoint, ioBroker sends 20 to
cmnd/<Hauptthema>/MINI. When writing, do not tick “Acknowledged”, otherwise nothing is sent. The alarm switches expect the text ON or
OFF. A datapoint of type boolean would send true/false and does not fit. The same value twice in a row is only sent once.
With a script (JavaScript adapter), without a datapoint of its own:
sendTo('mqtt.0', 'sendMessage2Client',
{ topic: 'cmnd/<Hauptthema>/MINI', message: '20' });
Whether the sensor has accepted the value is shown by
mqtt.0.stat.<Hauptthema>.MINI. With cmnd/<Hauptthema>/UPDATE (any value), the sensor immediately sends a fresh STATE.
Limitations
-
Do not use the Sonoff adapter. The sensor uses the same topic names as Tasmota but is not a Tasmota device: the adapter does not create a single datapoint and sends the sensor an unsolicited
Statuscommand. -
Home Assistant discovery is of no use in ioBroker. The only adapter for it (
hass-mqtt0.0.7, as of 2022, available only in the beta repository) shows, for fill level, fill height, contents and distance,Noneinstead of the value. - Option B repeats commands. As a broker, the adapter sends a value that was set once again as soon as the sensor reconnects. A change made through 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. - In power saving mode,
LWTstays atOnline, even while the sensor is asleep.
Verification status
Tested with ioBroker (js-controller 7.2.5, MQTT adapter 8.1.2) and sensor firmware 4.2.8.