What deviceKey actually is
deviceKey is the device's id: a UUID the backend generates when the
device is first registered (devices.id), for example
3f2504e0-4f89-41d3-9a0c-0305e82c3301. You get it from
register_result and
get_devices, and every device-addressed
request names the device by it: watch, write, get_registers,
update_device, delete_device, get_activity, get_alerts,
get_analytics, get_param_history and the rest.
It never changes. Not across reconnects, restarts or network blips — and
not when the device's logger is replaced: a completed logger swap
(update_device)
changes the device's loggerId, never its deviceKey, so the app keeps
watching, writing to and charting the same device, with all of its history.
It is safe to cache once you have it.
deviceKey is not the logger ID. The logger ID is the label printed on
the WiFi logger's QR code. It is what register
takes (as loggerId), and device messages also carry it as loggerId for
display — but it identifies a piece of hardware, and a device can have
several loggers over its life. A logger ID sent as deviceKey is refused
(INVALID_REQUEST, or DEVICE_NOT_FOUND on watch) with a message saying to
send the device id instead.
deviceKey | loggerId | |
|---|---|---|
| What it is | The device (one inverter) | The WiFi logger fitted to it now |
| Format | UUID, lowercase | The QR label, e.g. i30000252761006466 |
| Generated by | The backend, at registration | The hardware maker |
| Changes when | Never | A logger swap completes |
| Use it to | Address every request; key your client state | Show which logger the device has; register |
:::info Changed in the device-id release
Before this release deviceKey was the logger ID the device was registered
with, and get_devices showed the fitted logger separately as
currentLoggerId. Both are gone: deviceKey is the device UUID, and
loggerId is always the logger fitted now. A client from before this release
must be updated together with it.
:::
Where the device comes from. The hardware reports its own logger ID:
tcpserver asks it with AT+DTUPN? on connect, and it answers with the same
value printed on its QR label. Your register message tells the backend who
owns that logger, and the backend creates the device and its id. The device
and the app never talk to each other: they each tell the server, and the
server matches the two. See Server behavior's connect
flow for the full resolution order, including the cases where a connection is
refused.
A connection whose logger nobody registered is not visible to clients at
all. It has no device, so it has no deviceKey: tcpserver keys it
internally on its IP:port, holds it open with heartbeats only, and never polls
it — so it publishes no telemetry and no presence. Register it first.
Identifiers are normalised
Before anything is looked up, the gateway normalises the identifiers you send:
- Surrounding whitespace is trimmed from
deviceKey,loggerId,inverterSn,userId,plantId,activityIdandconfirmToken— a padded value could otherwise only ever fail, as a misleadingno such device. Send them verbatim anyway: the gateway logs a warning once per connection when it has to trim. (cursoris deliberately not trimmed.) - Identifiers are put into one canonical case:
deviceKeyandloggerIdlowercase (a UUID is printed lowercase),inverterSnandplantIduppercase (aplantIdofallis a keyword and staysall). Either spelling of a logger label works —I30000252761006466andi30000252761006466are the same logger.userIdis not case-converted (ownership checks compare it case-insensitively anyway).
Every reply that echoes a device identifier — watch_ack, telemetry,
presence, write_result, register_result, update_device_result,
all_registers, the delete messages — carries the canonical spelling,
and so does every reply that echoes a plantId (register_result,
devices, the delete messages): it comes back uppercase.
Key your client-side state on the deviceKey and plantId the server
sends back, not on what you sent.