powersync-docs/docs/api/index.en.md
Patrick Schurig 4a7a1bddf4
All checks were successful
Build & Deploy docs / build-deploy (push) Successful in 3m57s
api : référence régénérée depuis le banc en 1.15.2+etm71 (droits NymeaEnergy.* séparés, GetOptimizerProtocol)
Le badge PUBLIC de PermissionScopeNone devient AUTH : sur un transport
authentifié, nymea exige un token valide pour toute méthode sauf
JSONRPC.Hello, Authenticate et RequestPushButtonAuth
(jsonrpcserverimplementation.cpp, tag 1.15.2). « Lecture publique, aucun
token requis » était faux, en trois langues.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 08:49:15 +02:00

48 lines
1.9 KiB
Markdown

---
hide:
- toc
---
!!! info "Reference in English"
The method, field and type names and the descriptions below are the API's
own, **in English**. They are left verbatim: they are the exact strings you
will write in your requests.
# JSON-RPC API reference
ETM PowerSync exposes **nymea's JSON-RPC API** locally, including the ETM
extensions (`Energy`, `AirConditioning`, `EvDash`).
## Connection
| Mode | Address | Notes |
| --- | --- | --- |
| **Raw TCP** | `<ip>:2222` | nymea speaks first (welcome JSON, `\n`-delimited) |
| **WebSocket** | `ws://<ip>:4444` | the client sends `JSONRPC.Hello` first |
## Authentication
1. Call [`JSONRPC.Authenticate`](metier/jsonrpc.md#jsonrpcauthenticate) with
`username`, `password` and `deviceName` → you receive a `token`.
2. Include the `token` in every subsequent request.
3. Enable push: `JSONRPC.SetNotificationStatus` `{ "enabled": true }`.
## Energy conventions
| Quantity | Convention |
| --- | --- |
| PV output | **negative value** (producer convention) |
| `currentPowerAcquisition` | grid — positive = import, 0 when exporting |
| `currentPowerStorage` | battery — positive = charging, negative = discharging |
| Energy totals | in **kWh** |
| Timestamps | in **seconds** (Unix epoch) |
## Permission badges
| Badge | Scope | Description |
| --- | --- | --- |
| <span class="badge perm-none">AUTH</span> | `PermissionScopeNone` | Any authenticated account (token required whenever the transport requires authentication; only `JSONRPC.Hello`, `Authenticate` and `RequestPushButtonAuth` work without one) |
| <span class="badge perm-control">CONTROL</span> | `PermissionScopeControlThings` / `ExecuteRules` | Control of things and rules |
| <span class="badge perm-configure">CONFIGURE</span> | `PermissionScopeConfigureThings` / `ConfigureRules` | Configuration |
| <span class="badge perm-admin">ADMIN</span> | `PermissionScopeAdmin` | System administration |