Find the device IP
In the Drainbee app
Device settings → Local IP. This shows the last reported address, for example 192.168.1.42. Tap it to open the API overview in the app.
In your router
Find Drainbee’s IP in your router’s device list. You can also reserve a fixed address there.
Tip: The IP may change after your router restarts. Set up a DHCP reservation (‘always assign the same IP’) so your scripts keep working.
First request
A simple HTTP GET is enough. Replace the IP with your device’s address. You can also enter it directly in your browser’s address bar.
curl http://192.168.1.42/status - Method
- GET
- Path
- /status
- Port
- 80 (HTTP)
- Auth
- none
Response & fields
The response is a JSON object with Content-Type: application/json and Cache-Control: no-store. A request does not trigger a new measurement – it returns the last known value and its age.
{
"deviceId": "drainbee",
"firmwareVersion": "1.2.5",
"uptimeMs": 86400000,
"measurement": {
"cm": 42,
"ageMs": 3200
},
"wifi": {
"isConnected": true,
"localIp": "192.168.1.42",
"rssiDbm": -61
},
"mqtt": {
"isConnected": false
},
"memory": {
"freeHeapBytes": 142000,
"minFreeHeapBytes": 98000,
"largestFreeBlockBytes": 86000
}
} | Field | Type | Description |
|---|---|---|
| deviceId | string | Device identifier, as shown in the app. |
| firmwareVersion | string | Installed firmware, e.g. 1.2.5. |
| uptimeMs | number | Milliseconds since the device last started – not a calendar timestamp. |
| measurement.cm | number | null | Last smoothed water level in centimetres. null before the first measurement. |
| measurement.ageMs | number | null | Age of this measurement in milliseconds. A request does not trigger a measurement. null before the first measurement. |
| wifi.isConnected | boolean | Whether Drainbee is connected to Wi-Fi. |
| wifi.localIp | string | null | Current home-network IP. null when unavailable. |
| wifi.rssiDbm | number | null | Signal strength in dBm (closer to 0 is better; −60 is good, −80 is weak). null when unavailable. |
| mqtt.isConnected | boolean | Whether the Drainbee cloud connection is active. The local API works independently. |
| memory.freeHeapBytes | number | Currently free memory in bytes. |
| memory.minFreeHeapBytes | number | Lowest free memory since startup, in bytes. |
| memory.largestFreeBlockBytes | number | Largest contiguous free memory block in bytes. |
Later firmware versions may add fields. Do not rely on the order of keys.
Integration examples
All examples read measurement.cm and handle null – there is no value before the first measurement. These are ordinary HTTP requests; there is no native Drainbee integration, Matter or HomeKit support.
Home Assistant
sensor:
- platform: rest
name: "Drainbee water level"
unique_id: drainbee_water_level
resource: http://192.168.1.42/status
scan_interval: 60
timeout: 5
unit_of_measurement: "cm"
device_class: distance
state_class: measurement
availability: "{{ value_json.measurement.cm is number }}"
value_template: "{{ value_json.measurement.cm }}"
json_attributes_path: "$.measurement"
json_attributes:
- ageMs REST sensor configured in YAML. When measurement.cm is null, the sensor is unavailable. Add to your existing sensor: entries instead of creating a second sensor: block.
Node-RED
const measurement = msg.payload?.measurement;
if (typeof measurement?.cm !== "number") {
node.status({ fill: "grey", shape: "ring", text: "No measurement yet" });
return null;
}
msg.ageMs = measurement.ageMs;
msg.payload = measurement.cm;
node.status({ fill: "blue", shape: "dot", text: measurement.cm + " cm" });
return msg; Set an HTTP Request node to http://192.168.1.42/status and return a parsed JSON object. Trigger it with an Inject node every 60 seconds, then add this Function node.
ioBroker
const STATE_ID = "javascript.0.drainbee.water_level_cm";
createState(STATE_ID, null, {
type: "number", role: "value", unit: "cm",
read: true, write: false
}, () => {
schedule("*/1 * * * *", () => {
httpGet("http://192.168.1.42/status", { timeout: 5000 }, (err, response) => {
if (err || response.statusCode !== 200) {
setState(STATE_ID, null, true);
log("Drainbee unreachable", "warn");
return;
}
try {
const cm = JSON.parse(response.data).measurement?.cm;
setState(STATE_ID, typeof cm === "number" ? cm : null, true);
} catch {
setState(STATE_ID, null, true);
}
});
});
}); JavaScript adapter: creates a state and updates it every minute. Missing measurements or connection errors are stored as null so an old value does not appear current.
Python
import json
import urllib.error
import urllib.request
def water_level_cm(ip="192.168.1.42", timeout=5):
with urllib.request.urlopen(f"http://{ip}/status", timeout=timeout) as response:
data = json.load(response)
return data["measurement"]["cm"]
try:
cm = water_level_cm()
print("No measurement yet" if cm is None else f"{cm} cm")
except (OSError, urllib.error.URLError, ValueError, KeyError) as error:
raise SystemExit(f"Drainbee unreachable: {error}") One request using Python’s standard library, with no extra packages. A missing measurement returns None; connection failures are reported as errors.
Polling interval: 30–60 s is sufficient. Queries do not speed up measurements; use measurement.ageMs to detect stale values.
Errors & help
- 200
- OK
Status as JSON. Individual fields may be null.
- 404
- Not Found
Unknown path. Only /status exists – paths such as /value are not available in firmware 1.2.5.
- 405
- Method Not Allowed
Only GET is supported. POST, PUT and DELETE are rejected.
- 503
- Service Unavailable
The status could not be generated. Wait briefly and try again.
No response? Check these in order:
-
Is the IP correct?
Compare it with Device settings → Local IP in the app or your router’s device list. It may change after a router restart; a DHCP reservation helps.
-
Is the firmware up to date?
GET /status is available from 1.2.5. Older firmware does not respond on this path. Check the version in the app’s device settings.
-
On the same network?
Guest networks and separate Wi-Fi networks, such as an IoT VLAN, often block access between devices. Your client must share Drainbee’s network or have a route to it.
-
Does Drainbee have power and Wi-Fi?
Check the power supply and your router’s device list. The local API needs Wi-Fi. Losing the cloud connection alone does not prevent local access.
-
Wrong protocol?
Use http://, not https://. Some browsers add https automatically – enter the address with http:// explicitly.
Network & security
The local API is intended for your trusted home network. It has no authentication or HTTPS. Anyone who can reach Drainbee on the network can read its status, but cannot change anything through this API.
Do not expose it publicly
Do not forward port 80 to Drainbee on your router. For remote access, use the Drainbee app or a VPN into your home network.
Independent of the cloud
The request goes straight to the device and stays within your network. It also works when MQTT or the cloud connection is down, as long as Drainbee has power and Wi-Fi.
Not available in 1.2.5
- Other endpoints such as /value, /history or configuration
- Streaming, WebSockets or push notifications through the local API
- An offline history on the device – view history in the app
Questions about the API? [email protected]
← Back to the home page