Skip to main content

Device Alerts: subscribe_alerts / get_alerts / mark_alerts_read / mark_all_alerts_read / get_alert_catalog

:::note Status Implemented and unit-tested; not yet verified against a live app or real device hardware. See Messaging for the backend pipeline this serves (detection in tcpserver, reconciliation in persistence-worker) and its current known gaps (some catalog bits have no screen code in any manual, a third model with no alerts at all, no "pending" status). :::

Outside the app, newly raised alerts also reach the owner's phone as push notifications (Android, iOS and browsers).

A separate feed from telemetry's active_faults/active_warnings strings (still there, unchanged): stable per-alert IDs, database history, per-user read state, and a live push independent of whether you're currently watching the device's telemetry.

One connection, one live scope. subscribe_alerts both returns the current summary and registers this WebSocket connection to receive alerts_changed pushes going forward, for as long as the connection stays open (no separate "keep this hot" call). Send it again with a different plantId to change scope; unsubscribe_alerts (or just disconnecting) turns pushes off.

// → client — every plant this user owns
{"type": "subscribe_alerts", "userId": "17833b2e-a851-4a17-a764-62524d667959", "plantId": "all"}
// ← server
{"type": "alerts_summary", "ok": true, "plantId": "all",
"unreadCount": 5,
"counts": {"all": 12, "critical": 1, "warning": 4, "info": 7},
"openCounts": {"all": 3, "critical": 1, "warning": 1, "info": 1},
"plants": [
{"plantId": "01JXYZ...", "reporting": false, "devicesOnline": 0, "devicesTotal": 2},
{"plantId": "01JABC...", "reporting": true, "devicesOnline": 3, "devicesTotal": 3}
],
"plantsTotal": 2, "plantsReporting": 1}
  • plantId is "all" or one specific plant id — the same deviceid.PlantID canonicalization and "all" sentinel get_devices/ delete_device already use, not a parallel convention. Authorized at subscribe time: naming a plant this userId owns no device in, and that no alert grant of a verified ticket covers, gets {"ok": false, "error": "not authorized for this plant"} instead of a silent empty subscription. The exception is a plant with no devices at all (a newly created plant before its first inverter is registered): that answers ok: true with zero counts, unreadCount: 0 and no plants entries. Re-send subscribe_alerts after registering the plant's first device to start receiving its live pushes. The authorization check also gates the live push itself (plantId: "all" only ever delivers events for devices you own or plants you are granted, never more; see Who can see what). Ownership matches per device (since 2026-12-02, BE-15): owning one device in a plant does not deliver the plant's other devices' alerts; only a grant on that plant (or an all-plants grant) does, the same scope get_alerts lists. A frozen plant (the ticket's xp) never matches, not even for a device you own. An alert on a device with no plant yet is pushed only to that device's owner (since 2026-11-12; before, every subscriber who owned some plant-less device received it). An all-plants grant never matches a plant-less device.
  • openCounts (since 2026-12-02) counts open alerts only (alerts_active) in the same scope, per severity: what get_alerts state: "active" lists. Use it for "open alerts" tiles. counts also includes alerts resolved within the summary's history window (the feed).
  • reporting is false when every device in that plant is currently disconnected — the "2 of 3 plants reporting, values are last known" banner.
  • plants holds at most 50 lines (since 2026-11-24): plants with no device connected come first, then the rest, each group by plant id. A caller whose grants reach a whole Business or the fleet can see thousands of plants; the reply lists the offline ones the banner names and leaves the rest out. Take the banner's numbers from plantsTotal and plantsReporting, which count every plant in scope; don't count plants yourself. plantsTruncated: true means plants holds fewer lines than plantsTotal. For one plant (plantId set) the reply has that plant's line only. All three are absent when zero or false. For every plant's status with paging, use the console's get_plant_health.
  • plantCounts (since 2026-12-01) is {total, byStatus: {online, partial, offline, fault, setup}}: the console's list_plants status counts with no filter, for the same caller. It uses the same plants (every plant you see whole that is not archived), the same status rule and the same query, so total equals Σ byStatus, list_plants counts.total and the number of get_plant_health rows. Use it for fleet status tiles, not plantsTotal: plantsTotal counts plants holding any device you see at alerts VIEW (archived plants and plants you see only partly included), so the two can differ. plantsTruncated never cuts it. Statuses come from the plant rollup, so they can lag live connectivity by one rollup run, exactly like list_plants. With plantId set it counts that one plant. Absent if it could not be computed.
  • plants and plantsTotal/plantsReporting/plantsTruncated come with this reply only. alerts_changed pushes carry counts, openCounts and plantCounts (all plants in scope), not plant lines; the mark-read replies carry counts only. Re-send subscribe_alerts to refresh the banner.
  • Re-sending subscribe_alerts on reconnect is expected and cheap — live push is a latency optimization, not the source of truth. A reconnecting client should also re-fetch get_alerts from its newest known raisedAt/resolvedAt to fill any gap a dropped connection missed.

Live push: alerts_changed​

Pushed, unsolicited, whenever a subscribed scope's alert set changes — batched per device scan, so one message can carry several raised/resolved alerts at once (never split into separate pushes per alert):

← {"type": "alerts_changed",
"events": [
{"op": "raised", "alert": {
"id": "b3f1...", "deviceKey": "3f2504e0-4f89-41d3-9a0c-0305e82c3301",
"loggerId": "i30000252760985713", "plantId": "01JABC...", "plantName": "Model Town rooftop",
"inverterSn": "Y24C16070610", "model": "Nexus",
"code": "aotai.F13", "displayCode": "F_S1_12", "displayText": "Fault GFD",
"source": "modbus_bit", "severity": "critical",
"title": "PV Insulation Fault", "message": "Fault GFD",
"description": "The solar panels or their cables have poor insulation to earth; have the PV wiring checked for damage or moisture.",
"category": "pv", "action": "...",
"raisedAt": "2026-09-28T10:00:00Z", "stale": false, "flapping": false, "read": false,
"assignee": null
}}
],
"unreadCount": 6,
"counts": {"all": 13, "critical": 2, "warning": 4, "info": 7},
"openCounts": {"all": 4, "critical": 2, "warning": 1, "info": 1}}
  • deviceKey is the device the alert belongs to — filter and group by it. loggerId is the logger that was fitted when the alert was raised, a snapshot like plantId: after a logger swap, older alerts still name the old logger, under the same deviceKey. Both are on every alert in alerts_changed and get_alerts.
  • displayCode is the code exactly as this inverter's screen prints it, and displayText is the event name the screen prints next to it (Aotai only). Both are on every alert in alerts_changed and get_alerts. See displayCode.
  • plantName is the name of the alert's plantId, as the HTTP server last sent it: its current name, so an old alert of a renamed plant shows the new one. category and action are the catalog entry's for the alert's model and code. All three are on every alert in alerts_changed and get_alerts, and left out when unknown (no plant, a plant the HTTP server has not sent, a code the catalog lacks), so you need no plant lookup or catalog join to label an alert row. Added 2026-11-17.
  • assignee is the installer the alert is assigned to: {sub, name}, or null when unassigned. It is always present, on every alert in alerts_changed and get_alerts. name is null for assignments made before 2026-11-23. A Crown staff assignee reads {"name": "Crown Support", "viaPlatform": true} to anyone who is not Crown staff. Assigning is done with the console's assign_alert. Added 2026-11-23.
  • op is "raised", "resolved" (then alert.resolvedAt/ resolvedTitle are present) or "updated". "updated" is sent since 2026-11-23 when an open alert's assignee changes. Treat it as a replacement of the alert with the same id.
  • flapping is true when the alert was raised again within 10 minutes of its previous raise on the same connection. It is set when the alert is raised, does not change while it stays open, and carries over to the resolved history entry. A raise after the logger reconnected starts a new connection, so it is not counted as flapping. (Before 2026-10-06 the server never stored this flag, so older alerts always show false.)
  • unreadCount/counts/openCounts are already recomputed for the receiving client — no follow-up request needed just to refresh a badge.
  • A message never arrives for something you don't own — see plantId's authorization note above.

Listing/history: get_alerts​

// → client
{"type": "get_alerts", "userId": "17833b2e-a851-4a17-a764-62524d667959",
"plantId": "all", "state": "active", "severity": "critical", "limit": 50}
// ← server
{"type": "alert_list", "ok": true,
"items": [ /* alertItem, same shape as alerts_changed's "alert" above, plus "read" */ ],
"nextCursor": "eyJ0Ijoi..."}
  • state: "active", "resolved", or "all" (both, merged newest-first by event time — an active alert sorts by raisedAt, a resolved one by resolvedAt).
  • severity ("critical"/"warning"/"info"), deviceKey, and from/to (RFC3339, either or both open-ended) all narrow the result; omit any of them for no filter on that dimension.
  • limit caps a page at up to 50 (the default when omitted) — never more, per this API's "no unbounded datasets" rule. Page with cursor (opaque, echo nextCursor back verbatim) the same way get_activity already works.
  • read on each item reflects that specific user's read state — the same alert looks different (read: true vs false) to two different users viewing the same plant.

Device changes: device.MOVED_IN / device.MOVED_OUT / device.LOGGER_REPLACED​

When a device is moved to another plant with update_device, the server records an instantaneous info event in each plant's history: device.MOVED_OUT ("Device moved to another plant") in the plant it left, and device.MOVED_IN ("Device added to this plant") in the plant it joined. They have source: "system", no resolvedAt, and a context of {"action", "fromPlantId", "toPlantId"}. They are history rows, so they are returned by state: "resolved" and state: "all", never "active", and they count toward unread like any other alert.

They are not pushed: no alerts_changed, and no push notification. The app sees them on its next get_alerts or subscribe_alerts. They are not in get_alert_catalog, which lists only per-model device alerts.

Alerts still active when a device moves go with it to the new plant. Resolved alerts keep the plant they were raised in.

A completed logger swap records device.LOGGER_REPLACED ("Logger replaced") the same way, in the device's plant, with a context of {"action": "logger_replaced", "fromLoggerId", "toLoggerId"}. A device's alerts are keyed by its deviceKey, which a swap does not change, so its alert history is unaffected.

Read state: mark_alerts_read / mark_all_alerts_read​

// → client — a few specific alerts (e.g. the ones visible on screen)
{"type": "mark_alerts_read", "userId": "...", "alertIds": ["b3f1...", "c04a..."]}
// → client — a "mark all read" button, one plant or "all"
{"type": "mark_all_alerts_read", "userId": "...", "plantId": "all", "upTo": "2026-09-28T10:05:00Z"}
// ← server (either request)
{"type": "alerts_read", "ok": true, "alertIds": ["b3f1...", "c04a..."], "unreadCount": 4}
  • mark_alerts_read is capped at 100 ids per request — chunk a larger selection into multiple requests.
  • mark_all_alerts_read's upTo is required (RFC3339) — it moves that user's read watermark for plantId to that event time; anything at or before it counts read from then on, including history not yet fetched.
  • Both are echoed to this same user's OTHER live connections (phone and a web tab, say) as an unsolicited alerts_read push — so marking something read on one device updates the badge on the other without it polling.
  • Resolving an alert can make it unread again. A closed incident's feed position is its resolution time, not its original raise time — so active_faults clearing (a "Grid Restored"-style resolution) produces a fresh, unread entry in the feed, by design.

Reference data: get_alert_catalog​

// → client
{"type": "get_alert_catalog", "model": "Nexus"}
// ← server
{"type": "alert_catalog", "ok": true,
"entries": [
{"model": "Nexus", "code": "aotai.F13", "displayCode": "F_S1_12",
"displayText": "Fault GFD", "source": "modbus_bit", "severity": "critical",
"title": "PV Insulation Fault", "message": "Fault GFD",
"description": "The solar panels or their cables have poor insulation to earth; have the PV wiring checked for damage or moisture.",
"category": "device", "action": "view_device"},
{"model": "Yorker", "code": "ip20.F16", "displayCode": "18",
"displayCodeVariants": {"6KU": "Err 18"}, "source": "modbus_bit",
"severity": "critical", "title": "PV Reverse Polarity", "...": "..."}
]}

Omit model for every loaded model's catalog. "Yorker" returns both Yorker profiles' entries, the 2–12 kW's ip20.* and the 3.6 kW's y3k6.* (each entry also carries "profile": "IP20 3K6/5K" for the latter). The codes never collide, so key entries by code. Lets a client build a fault legend/help screen without hardcoding titles or severities per code — the same catalog tcpserver's detection logic evaluates against.

What each model detects​

source is "modbus_bit" (one vendor fault/warning bit is set) or "state" (a status register holds a particular value — fault mode, grid not connected, output short circuit, and so on). Clients should treat both the same way; the difference only matters for the server's detection.

Severity, as the app should treat it:

SeverityMeaningExamples
criticalThe inverter has stopped output, or needs attention now (many beep)battery not connected, output short circuit, inverter in fault mode, BMS fault, low-SOC shutdown
warningSomething is wrong but the inverter is still runninggrid/PV/generator abnormal, output overload, BMS alarm, fan locked
infoAn operating-state change, not a problem; notifyOnResolve is off for mostgrid not connected / restored, off-grid operation, weak PV energy (every evening), firmware upgrade, reserved vendor bits

A single physical event can raise more than one alert, because inverters report the same condition in more than one place. A disconnected battery on an IP20, for example, can raise ip20.F33 (battery field of the status word) together with battery low-voltage or "BMS lost" warnings, and also ip20.F30 (warning word bit 0) when the inverter's own "battery open-circuit warning" setting is on (it is off by default). Group by device and time when displaying.

Some IP20 conditions are only checked while the inverter is running. The IP20's packed status word reads all-zero in standby, which would look like "grid not connected" and "battery disconnected". So I05, W29–W32, F32 and F33 are only evaluated while the inverter is in grid, PV, battery or generator mode. Outside those modes they neither raise nor clear. The mode itself is reported by F31 (fault), I02 (shutdown), I03 (test) and I04 (firmware upgrade).

Every vendor status bit raises on the first scan that sees it (scans run every 30 seconds), the way the inverter's screen shows it at once. Clearing needs two clean scans in a row. A condition that starts and ends between two scans is not seen.

After a logger reconnects, its alerts are re-confirmed before anything changes: the server waits until every condition has had enough scans to raise (about 60 seconds, set by the state conditions) before reconciling. A still-present warning therefore stays open (shown stale: true while the logger is away) instead of resolving and raising again.

conn.LOGGER_OFFLINE (raised once a logger has been disconnected for 5 minutes) is not resolved the moment the logger reconnects (since 2026-11-27). It resolves only after the logger has stayed connected for 10 minutes, checked by the once-a-minute offline sweep, so it resolves 10-11 minutes after the reconnect. If the logger drops again within those 10 minutes, the same alert stays open: no resolved event and no second raised. A logger on a weak Wi-Fi link therefore shows one long outage instead of a raise/resolve pair per drop. The alert's resolvedAt is the time of the reconnect that held, not the time the sweep ran.

A new alert code reaches the database only once both tcpserver and persistence-worker run a build that knows it. A code the worker doesn't know yet is skipped and logged. It opens on that device's next reported change or reconnect after the worker is upgraded.

displayCode: the code on the inverter's screen​

displayCode is the code exactly as the inverter's own screen prints it for the condition: same characters, same spacing. A user can match an app alert to what they see on the device. It comes from the model's user manual or, where the inverter's firmware prints it differently, from photos of its screen, because the screen's code is not readable over Modbus.

  • On every alert. alerts_changed and get_alerts carry it directly; no catalog lookup is needed. tcpserver records the code as that device's screen prints it when the alert is raised, so an IP20 6KU's fault reads "Err 18" while another IP20 model's reads "18".
  • displayText is the event name the screen prints after the code, where it prints one (the Aotai's Error Code page: W_S1_01:Under Ugrid → displayCode "W_S1_01", displayText "Under Ugrid"). To render the screen's line, join them with :.
  • Absent when no manual gives a code for the condition, including every "state" alert.
  • code, not displayCode, is the identifier. Show title/message as the main text and displayCode next to it.
  • description is one plain-language sentence that tells the user what the alert means and, where useful, what to check ("The battery charge is low."). Show it under the title. Every alert in every model's catalog has one, and so does conn.LOGGER_OFFLINE. It comes from the current catalog each time an alert is sent, not from the stored alert, so older alerts carry it too and a reworded description reaches every alert after the next deploy. message stays the vendor's short event name ("Fault GFD"). Enforced by modbus.TestAlertDescriptions.
  • title, message, description, resolvedTitle and displayText are English only. The vendor sheets name each bit in English and Chinese; the server keeps only the English (enforced by modbus.TestAlertTextHasNoChinese).
ModelWhat the screen prints → displayCodeSource
Yorker, alarmsALA 56 → "ALA 56"Yorker 6 kW manual p. 39, 2 kW p. 47
Yorker, faults18 next to the ERROR icon → "18". On a 6KU (register 57 = 0x10/0x11): Err 18 → "Err 18"2 kW p. 44, 6 kW p. 36; the catalog's displayCodeVariants
Nexus, warningsW_S1_09:Under Ugen → "W_S1_09" + displayText. W_S<table>_<row>: table 1 = register 135, 2 = 136; row = bit, two digitsPhotos of the bench inverter's Error Code page, 2026-10-07; rows from NEXUS manual §5
Nexus, faultsF_S1_15:AC Stop → "F_S1_15" + displayText. Table 1–3 = registers 131–133same

Coverage:

  • IP20: 50 of 64 bit alerts have a screen code. 16 of those come from the IP20 3.6/5 kW manuals, which list codes the 2/6 kW manuals omit.
  • Aotai: 80 of 96 bit alerts have one. The exceptions are register 134 (aotai.F47–F51 and catch-alls), for which the manual has no table.

The telemetry record's active_display_codes lists the same codes for every bit set in that cycle, without the alert thresholds.

Every status bit is covered. A bit no vendor document defines raises an info alert titled "Undocumented Status Bit" (ip20.I06–I10, and the Aotai's aotai.I02–I31 except the three below) with that bit's screen code where the manual's table has the row (e.g. aotai.I15, W_S1_07). So whatever the screen shows also reaches the app.

Aotai screen format and names, corrected 2026-10-07. The NEXUS manual prints W_1:1 / F_1_15; the bench inverter's firmware prints W_S1_01 / F_S1_15, and every Aotai displayCode now uses the screen's form. Its Error Code page also names three warning-1 bits the manual lists as Reserved. They are now warnings with real titles:

CodedisplayCode / displayTextTitle (was "Undocumented Status Bit", info)
aotai.I17W_S1_09 / Under UgenGenerator Undervoltage
aotai.I18W_S1_10 / AC StopAC Output Stopped
aotai.I21W_S1_13 / Gen_to_GridGenerator to Grid Transfer

aotai.F16 (F_S1_15) is now titled "AC Output Stopped", with displayText "AC Stop", as the screen prints it (the manual calls it "Remote Shutdown"). displayText for aotai.W06/W07/F05 is the screen's Under Upv1 / Under Upv2 / Over Temp. Generator Undervoltage stays active on every unit with no generator connected, as it does on the screen. The W_S2_…/F_S2_…/F_S3_… forms follow the table-1 pattern but haven't been photographed yet.

An alert raised before the correction is served with the corrected displayCode. Its title, severity and message are updated on the device's next session while it stays open; closed history keeps the old title until scripts/sql/2026-10-07_aotai_alert_titles_from_screen.sql is run.

Before 2026-10-06, displayCode held catalog sequence numbers (F01, W06, …), and bit alerts had placeholder titles such as "Inverter Fault F13". Alerts raised before then are served with the right displayCode. Their old title stays in closed history; an alert still open takes the current catalog's title, severity and message on the device's next session. For those, the code is the catalog's default form ("18", not a 6KU's "Err 18"), because the device form wasn't recorded then.

ModelDetected conditions
Nexus66 vendor fault/warning bits (aotai.F01–F51, W01–W15), 3 warning bits named only by the inverter's screen (aotai.I17 generator undervoltage, I18 AC output stopped, I21 generator to grid transfer), 27 "Undocumented Status Bit" catch-alls (aotai.I02–I31, except those three), plus inverter fault mode (aotai.F52) and off-grid operation (aotai.I01, resolves as "Grid Restored"). W14 (battery transient undervoltage) and W15 (DC stop) were added on 2026-10-06 from the NEXUS manual. The manual's warning tables also confirm the warning registers (135/136).
Yorker59 vendor fault/warning bits (ip20.F01–F30, W01–W28, I01), 5 "Undocumented Status Bit" catch-alls (ip20.I06–I10), plus state conditions: fault / shutdown / test / upgrade mode (F31, I02–I04), grid not connected (I05, resolves as "Grid Restored"), grid / generator / PV abnormal (W29–W31), output overload (W32) and short circuit (F32), battery disconnected (F33), and BMS fault / alarm (F34, W33 — the BMS words' individual bits are undocumented, so any bit set raises them).
IP20 3K6/5KSince 2026-11-23, 53 codes from its ASCII replies: the GWS fault code (y3k6.F01–F29, no F27; displayCode the LCD fault number, "1"–"29"), the two GWS alarm words (y3k6.W100–W115, W204–W215; displayCode the LCD alarm, "ALA 52"), inverter fault mode (y3k6.F30) from the work mode, shut down (y3k6.I01, resolves as "Inverter Running") while power_switch reads off (standby or shutdown), and fan 1 / fan 2 stopped (y3k6.W301, W302). See IP20 3K6/5K.

Severities of a few existing codes changed on 2026-10-06: aotai.W05 → info, aotai.W09 → critical; ip20.W12, F26, W04, W07, W11, W15 → info; ip20.W17, W20 → critical. On 2026-10-07 aotai.I17, I18 and I21 went from info to warning (see above). Closed history keeps the severity an alert was raised with. Since 2026-10-07 an open alert takes the current catalog's title, severity and message at the start of each device session.