Device Online/Offline Detection

Virtuino Cloud watches the connections themselves: the moment a board connects, the moment it drops off and why. You add nothing to your firmware for this. Everything appears live in My Virtuino World, and the device status dashboard widget shows the same state on a dashboard and alerts you when a board stops.

Looking for command confirmation instead? Knowing a board is online is different from knowing a specific command was applied. For that, see MQTT Confirmed.

1How a board is recognised

MQTT

Every MQTT connection is identified by its client ID, exactly as written. A board that connects as kitchen-a1b2c3 appears under that name in My Virtuino World — nothing has to match a field, a topic or anything you set up in the console. The broker reports the connection and the disconnection directly, including a power cut, a crash or a network failure.

Give every board its own client ID. Two clients that connect with the same one keep kicking each other off the broker. When you flash the same sketch to several boards, add the chip ID:

// ESP32 — any name you like, made unique with the chip ID
String clientId = "kitchen-" + String((uint32_t)ESP.getEfuseMac(), HEX);
// ESP8266:  "kitchen-" + String(ESP.getChipId(), HEX)

mqtt.connect(clientId.c_str(), MQTT_USER, MQTT_PASS);
Avoid a random client ID. Some examples found online build the client ID from random(). Every restart then creates a new connection with a new name, and My Virtuino World fills up with boards that are really the same one. Keep it the same across restarts — the chip ID does exactly that.
Hardware with a fixed client ID? Off-the-shelf firmware (Tasmota, commercial gateways) often connects with a factory client ID such as tasmota_4C11AE. That is fine: it appears in My Virtuino World as soon as it connects, and you can give it a friendlier name there.

How fast is a power cut detected?

A board that loses power cannot say goodbye, so the broker notices only when the board misses its keep alive deadline. Detection takes roughly keep alive × 1.5:

Keep alive in your sketchPower cut detected within
mqtt.setKeepAlive(20)about 30 seconds
mqtt.setKeepAlive(60)about 90 seconds — less network traffic

A clean disconnect is reported immediately, with no waiting.

HTTP

HTTP has no connection that stays open, so a board is online as long as it keeps sending. Add an optional client_id to the body of every write, and the board appears in My Virtuino World under that name:

POST https://api.virtuino.com/api/data/write
{
  "client_id": "greenhouse-board",     // 1–64 characters: A-Z a-z 0-9 . _ : -
  "field":     "greenhouse/temperature",
  "value":     24.5
}
What it means
Online The board sent a value recently. The platform learns how often each board usually sends, so one that reports every 30 seconds and one that reports every hour are both judged fairly.
Offline Silence longer than three times its usual interval (at least 3 minutes). The reason shown is Stopped sending.
No client_id Every board of the sub-account that sends without one appears together as a single HTTP · no client_id entry, which cannot be named or watched on its own. Add a client_id to tell the boards apart.

Only writes count. Reading values (GET) does not make a board online — a read carries no client_id.

Apps are not devices

Phones and screens running an app also connect to the broker, sometimes thousands of them with a different client ID each. They are counted as apps, not devices: My Virtuino World shows up to ten one by one and more as one group with a number, and an app closing never counts as a board going offline and never sends an alert. Virtuino apps and the mosquitto command-line tools are recognised automatically; if your own app connects with a common prefix (for example app-), open the card of any app in My Virtuino World, then Settings, and add that prefix.

LWT is a reserved topic. You do not need a Last Will in your firmware — the broker already reports every connection. Do not create a field called LWT: messages on that topic are read as a connection state, never stored as a value.

Standard MQTT Last Will

If your firmware sets a Last Will on one of your field topics, it works exactly as on any MQTT broker: when the board drops off without a clean disconnect (power cut, crash, lost network), the broker publishes the Will message to that topic. The value is stored in the field like any other — dashboards, rules, scripts and your apps all receive it.

// ESP32 / PubSubClient — Will on the field "kitchen/online": "0" when the board drops off
mqtt.connect(clientId.c_str(), MQTT_USER, MQTT_PASS,
             "kitchen/online", 1, true, "0");   // will topic, QoS, retain, message
mqtt.publish("kitchen/online", "1", true);         // "1" right after connecting

Write the topic as usual, without the account key. A clean disconnect does not send the Will — that is how MQTT works — but the connection state above is reported in both cases.

2My Virtuino World

Open My Virtuino World in the console. Every board of your account is a point orbiting the Virtuino Cloud planet, and every value it sends or receives travels along its line in real time.

StatusMeaning
ONLINEConnected now (MQTT) or sending as usual (HTTP).
OFFLINEIt dropped off. The card shows when, and the reason (see below).
WAITINGA board you named that has never connected yet — not a fault, it is still being set up.
LOST IN SPACEOffline for more than 24 hours. It leaves the map and moves to the Lost in space list at the top right, so old boards do not crowd the ones that work.

The card

Click a board to open its card:

LineMeaning
StatusAs in the table above.
ConnectionMQTT, HTTP, or both.
Online for / Last seen An MQTT board that is connected shows how long it has been connected. Otherwise the card shows when the board was last seen — for HTTP, the time of its last write.
Client IDThe identity the board connects with.
Sub-accountWhich sub-account the connection belongs to.
ReasonWhy it dropped off — shown only while it is offline.
Listens toThe topics an MQTT board has subscribed to. A command sent to a field only reaches the boards listening to it.

Settings in the card

SettingWhat it does
Name A friendlier name than the client ID. Give two connections the same name and they become one device — for example a board that sends over both MQTT and HTTP, or two boards inside the same machine. Reset name goes back to the client ID.
Real device Tick it for a board you want to watch. Only real devices can be chosen in the device status widget; test tools and screens stay out of that list.
Groups Put boards in your own groups (by building, customer, project…) and show one group at a time from the bar at the top.
Delete device Available only while the board is offline — an online board would reappear at once.

Disconnect reasons

ReasonWhat happened
timeoutNo response within the keep alive — the usual sign of a power cut, a crash or lost Wi-Fi.
conn_lostThe network connection broke.
io_errorA network error on the connection.
cleanThe board disconnected normally.
auth_failedWrong username or password.
admin_kickThe server closed the connection.
malformed_packet / protocol_errorThe board sent something the broker could not read — usually a problem in the MQTT library or the firmware.
oversize_packetA message was larger than the broker accepts.
Stopped sendingHTTP: silence longer than three times the board's usual interval.

3The device status widget

To see a board's status on a dashboard — and to be alerted when it drops off — add a device status widget: Add widget → Special → device status, then choose the device. The list shows the boards you ticked as Real device in My Virtuino World, by the name they have there.

ShowsMeaning
ONLINE The device is online. If it has several connections, the line underneath says how many are up, e.g. 2/2 boards.
OFFLINE When it was last seen and why. A device with several connections is offline as soon as any one of them drops, and the widget names the one that did.
WAITING The device has not connected yet — no data so far.
NO DEVICE No device is chosen. This happens when a dashboard is copied to another sub-account that has no device with the same name: open the widget settings and choose one.

Alert settings

The button on the widget opens the alert settings. They belong to the person using the dashboard, so each dashboard can be set up differently (hide the button with Show user settings button in the widget settings).

SettingWhat it does
Alert titleThe title of the alert.
MessageOptional text added to the alert. The alert always includes the device, when it was last seen and why it dropped off.
Alert after (seconds offline) How long the device must stay offline before an alert is sent — 60 seconds by default. A board that reconnects within that time sends nothing, so a quick restart does not flood your inbox.
Alerts onTurns the alerts for this widget on or off.
Email / Push How to be alerted. Email goes to the notification address set in the dashboard settings; push goes to the phones paired with that dashboard.
One alert per outage. You are alerted once when the device goes offline, not again until it comes back and drops off again. When it comes back, that is recorded in the dashboard's notifications.

4Troubleshooting

SymptomCause and fix
The board does not appear in My Virtuino World MQTT: it is not connecting — check the username (the Sub-account Key) and password; the Debug Monitor shows what arrives. HTTP: it must write at least once; reads do not count.
A new board appears after every restart The client ID changes on every boot (often built with random()). Use a fixed one — the chip ID keeps it unique and constant.
Two boards keep knocking each other offline They connect with the same client ID. Give each its own, e.g. with the chip ID.
All HTTP boards show as one HTTP · no client_id They send without a client_id. Add one to the body of each board's writes.
A power cut takes too long to show up It is detected after roughly keep alive × 1.5. Lower mqtt.setKeepAlive() to detect it sooner, at the cost of a little more network traffic.
A phone app appears as a device Its client ID has no known app prefix. Open the card of an app in My Virtuino World, Settings, and add the prefix your app uses.
The device is missing from the device status widget list Only boards ticked as Real device are listed. Open the board in My Virtuino World and tick it.
The widget says NO DEVICE after copying a dashboard The target sub-account has no device with the same name. Choose one in the widget settings.

For topics, broker settings and connection details, see the MQTT Broker Setup guide; for HTTP, the HTTP API guide. For confirming that a specific command was actually applied, see MQTT Confirmed.