tesla-fleet-api 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/README.md +269 -1
  2. package/dist/_virtual/_rolldown/runtime.cjs +10 -0
  3. package/dist/bluetooth/adapters/shared.cjs +38 -0
  4. package/dist/bluetooth/adapters/shared.mjs +36 -0
  5. package/dist/bluetooth/async.cjs +121 -0
  6. package/dist/bluetooth/async.d.cts +10 -0
  7. package/dist/bluetooth/async.d.mts +10 -0
  8. package/dist/bluetooth/async.mjs +116 -0
  9. package/dist/bluetooth/broadcast.cjs +153 -0
  10. package/dist/bluetooth/broadcast.d.cts +59 -0
  11. package/dist/bluetooth/broadcast.d.mts +59 -0
  12. package/dist/bluetooth/broadcast.mjs +151 -0
  13. package/dist/bluetooth/constants.cjs +96 -0
  14. package/dist/bluetooth/constants.d.cts +68 -0
  15. package/dist/bluetooth/constants.d.mts +68 -0
  16. package/dist/bluetooth/constants.mjs +70 -0
  17. package/dist/bluetooth/framing.cjs +125 -0
  18. package/dist/bluetooth/framing.d.cts +45 -0
  19. package/dist/bluetooth/framing.d.mts +45 -0
  20. package/dist/bluetooth/framing.mjs +122 -0
  21. package/dist/bluetooth/homey.cjs +165 -0
  22. package/dist/bluetooth/homey.d.cts +84 -0
  23. package/dist/bluetooth/homey.d.mts +84 -0
  24. package/dist/bluetooth/homey.mjs +159 -0
  25. package/dist/bluetooth/names.cjs +24 -0
  26. package/dist/bluetooth/names.d.cts +10 -0
  27. package/dist/bluetooth/names.d.mts +10 -0
  28. package/dist/bluetooth/names.mjs +20 -0
  29. package/dist/bluetooth/noble.cjs +178 -0
  30. package/dist/bluetooth/noble.d.cts +58 -0
  31. package/dist/bluetooth/noble.d.mts +58 -0
  32. package/dist/bluetooth/noble.mjs +177 -0
  33. package/dist/bluetooth/streamglue.cjs +157 -0
  34. package/dist/bluetooth/streamglue.d.cts +37 -0
  35. package/dist/bluetooth/streamglue.d.mts +37 -0
  36. package/dist/bluetooth/streamglue.mjs +154 -0
  37. package/dist/bluetooth/teslabluetooth.cjs +67 -0
  38. package/dist/bluetooth/teslabluetooth.d.cts +41 -0
  39. package/dist/bluetooth/teslabluetooth.d.mts +41 -0
  40. package/dist/bluetooth/teslabluetooth.mjs +66 -0
  41. package/dist/bluetooth/transport.cjs +10 -0
  42. package/dist/bluetooth/transport.d.cts +97 -0
  43. package/dist/bluetooth/transport.d.mts +97 -0
  44. package/dist/bluetooth/transport.mjs +10 -0
  45. package/dist/bluetooth/vehiclebluetooth.cjs +1272 -0
  46. package/dist/bluetooth/vehiclebluetooth.d.cts +495 -0
  47. package/dist/bluetooth/vehiclebluetooth.d.mts +495 -0
  48. package/dist/bluetooth/vehiclebluetooth.mjs +1270 -0
  49. package/dist/bluetooth/verify.cjs +93 -0
  50. package/dist/bluetooth/verify.d.cts +35 -0
  51. package/dist/bluetooth/verify.d.mts +35 -0
  52. package/dist/bluetooth/verify.mjs +91 -0
  53. package/dist/bluetooth.cjs +52 -0
  54. package/dist/bluetooth.d.cts +10 -0
  55. package/dist/bluetooth.d.mts +10 -0
  56. package/dist/bluetooth.mjs +9 -0
  57. package/dist/commands.cjs +1080 -85
  58. package/dist/commands.d.cts +585 -54
  59. package/dist/commands.d.mts +583 -51
  60. package/dist/commands.mjs +1084 -93
  61. package/dist/const.cjs +22 -0
  62. package/dist/const.d.cts +21 -0
  63. package/dist/const.d.mts +21 -0
  64. package/dist/const.mjs +20 -1
  65. package/dist/energy.cjs +24 -19
  66. package/dist/energy.d.cts +21 -15
  67. package/dist/energy.d.mts +21 -15
  68. package/dist/energy.mjs +24 -19
  69. package/dist/energyisland.cjs +38 -0
  70. package/dist/energyisland.mjs +37 -0
  71. package/dist/energyparsers.cjs +118 -0
  72. package/dist/energyparsers.d.cts +39 -0
  73. package/dist/energyparsers.d.mts +39 -0
  74. package/dist/energyparsers.mjs +116 -0
  75. package/dist/energyspecific.cjs +375 -17
  76. package/dist/energyspecific.d.cts +199 -19
  77. package/dist/energyspecific.d.mts +197 -16
  78. package/dist/energyspecific.mjs +370 -18
  79. package/dist/exceptions.cjs +3 -2
  80. package/dist/exceptions.d.cts +3 -2
  81. package/dist/exceptions.d.mts +3 -2
  82. package/dist/exceptions.mjs +3 -2
  83. package/dist/funnel.cjs +297 -0
  84. package/dist/funnel.d.cts +118 -0
  85. package/dist/funnel.d.mts +118 -0
  86. package/dist/funnel.mjs +292 -0
  87. package/dist/index.cjs +61 -0
  88. package/dist/index.d.cts +22 -8
  89. package/dist/index.d.mts +22 -8
  90. package/dist/index.mjs +19 -6
  91. package/dist/log.cjs +75 -0
  92. package/dist/log.d.cts +4 -0
  93. package/dist/log.d.mts +4 -0
  94. package/dist/log.mjs +71 -0
  95. package/dist/oauth.cjs +143 -0
  96. package/dist/oauth.d.cts +69 -0
  97. package/dist/oauth.d.mts +69 -0
  98. package/dist/oauth.mjs +143 -0
  99. package/dist/powerwall/client.cjs +818 -0
  100. package/dist/powerwall/client.d.cts +297 -0
  101. package/dist/powerwall/client.d.mts +297 -0
  102. package/dist/powerwall/client.mjs +807 -0
  103. package/dist/powerwall/components.cjs +188 -0
  104. package/dist/powerwall/components.d.cts +45 -0
  105. package/dist/powerwall/components.d.mts +45 -0
  106. package/dist/powerwall/components.mjs +182 -0
  107. package/dist/powerwall/energysite.cjs +216 -0
  108. package/dist/powerwall/energysite.d.cts +104 -0
  109. package/dist/powerwall/energysite.d.mts +104 -0
  110. package/dist/powerwall/energysite.mjs +214 -0
  111. package/dist/powerwall/exceptions.cjs +59 -0
  112. package/dist/powerwall/exceptions.d.cts +38 -0
  113. package/dist/powerwall/exceptions.d.mts +38 -0
  114. package/dist/powerwall/exceptions.mjs +51 -0
  115. package/dist/powerwall/gateway.cjs +102 -0
  116. package/dist/powerwall/gateway.d.cts +57 -0
  117. package/dist/powerwall/gateway.d.mts +57 -0
  118. package/dist/powerwall/gateway.mjs +101 -0
  119. package/dist/powerwall/merge.cjs +163 -0
  120. package/dist/powerwall/merge.d.cts +63 -0
  121. package/dist/powerwall/merge.d.mts +63 -0
  122. package/dist/powerwall/merge.mjs +159 -0
  123. package/dist/powerwall/models.d.cts +95 -0
  124. package/dist/powerwall/models.d.mts +95 -0
  125. package/dist/powerwall/queries.cjs +17 -0
  126. package/dist/powerwall/queries.mjs +10 -0
  127. package/dist/powerwall/transport.cjs +232 -0
  128. package/dist/powerwall/transport.mjs +227 -0
  129. package/dist/powerwall.cjs +47 -0
  130. package/dist/powerwall.d.cts +9 -0
  131. package/dist/powerwall.d.mts +9 -0
  132. package/dist/powerwall.mjs +8 -0
  133. package/dist/router/base.cjs +203 -0
  134. package/dist/router/base.d.cts +112 -0
  135. package/dist/router/base.d.mts +112 -0
  136. package/dist/router/base.mjs +200 -0
  137. package/dist/router/energysite.cjs +65 -0
  138. package/dist/router/energysite.d.cts +47 -0
  139. package/dist/router/energysite.d.mts +47 -0
  140. package/dist/router/energysite.mjs +60 -0
  141. package/dist/router.cjs +13 -0
  142. package/dist/router.d.cts +3 -1
  143. package/dist/router.d.mts +3 -1
  144. package/dist/router.mjs +3 -1
  145. package/dist/signing/crypto.cjs +28 -0
  146. package/dist/signing/crypto.mjs +26 -1
  147. package/dist/signing/energy.cjs +123 -0
  148. package/dist/signing/energy.d.cts +45 -0
  149. package/dist/signing/energy.d.mts +45 -0
  150. package/dist/signing/energy.mjs +120 -0
  151. package/dist/signing/jws.cjs +229 -0
  152. package/dist/signing/jws.d.cts +45 -0
  153. package/dist/signing/jws.d.mts +45 -0
  154. package/dist/signing/jws.mjs +211 -0
  155. package/dist/signing/keys.cjs +191 -0
  156. package/dist/signing/keys.d.cts +21 -0
  157. package/dist/signing/keys.d.mts +21 -0
  158. package/dist/signing/keys.mjs +182 -0
  159. package/dist/signing/session.cjs +104 -30
  160. package/dist/signing/session.d.cts +60 -23
  161. package/dist/signing/session.d.mts +60 -23
  162. package/dist/signing/session.mjs +105 -31
  163. package/dist/tariff.cjs +27 -0
  164. package/dist/tariff.d.cts +11 -0
  165. package/dist/tariff.d.mts +11 -0
  166. package/dist/tariff.mjs +27 -1
  167. package/dist/teslafleetapi.cjs +256 -55
  168. package/dist/teslafleetapi.d.cts +110 -14
  169. package/dist/teslafleetapi.d.mts +110 -14
  170. package/dist/teslafleetapi.mjs +258 -57
  171. package/dist/teslemetry.cjs +152 -5
  172. package/dist/teslemetry.d.cts +95 -5
  173. package/dist/teslemetry.d.mts +93 -3
  174. package/dist/teslemetry.mjs +151 -6
  175. package/dist/teslemetryenergy.cjs +287 -0
  176. package/dist/teslemetryenergy.d.cts +154 -0
  177. package/dist/teslemetryenergy.d.mts +154 -0
  178. package/dist/teslemetryenergy.mjs +282 -0
  179. package/dist/teslemetryvehicle.cjs +407 -0
  180. package/dist/teslemetryvehicle.d.cts +238 -0
  181. package/dist/teslemetryvehicle.d.mts +238 -0
  182. package/dist/teslemetryvehicle.mjs +405 -0
  183. package/dist/tessie.cjs +42 -5
  184. package/dist/tessie.d.cts +51 -5
  185. package/dist/tessie.d.mts +49 -3
  186. package/dist/tessie.mjs +42 -5
  187. package/dist/tessievehicle.cjs +514 -0
  188. package/dist/tessievehicle.d.cts +333 -0
  189. package/dist/tessievehicle.d.mts +333 -0
  190. package/dist/tessievehicle.mjs +513 -0
  191. package/dist/types/live_status.d.cts +16 -16
  192. package/dist/types/live_status.d.mts +16 -16
  193. package/dist/types/responses.d.cts +5 -1
  194. package/dist/types/responses.d.mts +5 -1
  195. package/dist/types/vehicle.d.cts +7 -1
  196. package/dist/types/vehicle.d.mts +7 -1
  197. package/dist/types.d.cts +3 -3
  198. package/dist/types.d.mts +3 -3
  199. package/dist/util.cjs +41 -0
  200. package/dist/util.d.cts +18 -0
  201. package/dist/util.d.mts +18 -0
  202. package/dist/util.mjs +40 -0
  203. package/dist/vehicle.cjs +79 -36
  204. package/dist/vehicle.d.cts +42 -26
  205. package/dist/vehicle.d.mts +42 -26
  206. package/dist/vehicle.mjs +80 -37
  207. package/dist/vehiclesigned.cjs +20 -5
  208. package/dist/vehiclesigned.d.cts +14 -5
  209. package/dist/vehiclesigned.d.mts +14 -5
  210. package/dist/vehiclesigned.mjs +20 -5
  211. package/dist/vehiclespecific.cjs +126 -15
  212. package/dist/vehiclespecific.d.cts +82 -18
  213. package/dist/vehiclespecific.d.mts +82 -18
  214. package/dist/vehiclespecific.mjs +126 -15
  215. package/package.json +56 -3
@@ -0,0 +1,287 @@
1
+ const require_const = require("./const.cjs");
2
+ const require_energy = require("./energy.cjs");
3
+ const require_energyisland = require("./energyisland.cjs");
4
+ const require_energyparsers = require("./energyparsers.cjs");
5
+ const require_energyspecific = require("./energyspecific.cjs");
6
+ const require_exceptions = require("./exceptions.cjs");
7
+ // src/teslemetryenergy.ts
8
+ /** Default overall bound on `wait_until_paired`, in milliseconds. */
9
+ const DEFAULT_PAIRING_TIMEOUT = 6e5;
10
+ /** Default delay between `wait_until_paired` polls, in milliseconds. */
11
+ const DEFAULT_PAIRING_POLL_INTERVAL = 5e3;
12
+ const EXPIRED = Symbol("expired");
13
+ /**
14
+ * Settle as `step` does, or resolve `EXPIRED` after `ms`, or reject with the
15
+ * signal's reason. JavaScript cannot cancel `step`, so one that outlives this
16
+ * is abandoned, and its late rejection stays handled here.
17
+ */
18
+ function settleWithin(step, ms, signal) {
19
+ return new Promise((resolve, reject) => {
20
+ const finish = (settle) => {
21
+ clearTimeout(timer);
22
+ signal?.removeEventListener("abort", onAbort);
23
+ settle();
24
+ };
25
+ const onAbort = () => finish(() => reject(signal?.reason));
26
+ const timer = setTimeout(() => finish(() => resolve(EXPIRED)), ms);
27
+ signal?.addEventListener("abort", onAbort, { once: true });
28
+ Promise.resolve().then(step).then((value) => finish(() => resolve(value)), (error) => finish(() => reject(error)));
29
+ });
30
+ }
31
+ /**
32
+ * Teslemetry's energy site.
33
+ *
34
+ * With a signing key (see `EnergySpecific`), every device command except the
35
+ * four pre-pairing reads is signed with that key and sent through Teslemetry's
36
+ * `device_command` route. Without a key, a command uses its Teslemetry route.
37
+ * The `set_island_mode`, `backup_events` and `config` routes sign with
38
+ * Teslemetry's own key, which must be verified on the gateway, or the route
39
+ * answers 409 `energy_site_not_paired` and sends nothing. As of 2026-10-29 the
40
+ * `dispatch_battery_power`, `resume_battery_operation` and backup-event
41
+ * schedule and cancel routes still send unsigned, so Tesla answers HTTP 400:
42
+ * keyless dispatch does not work until Teslemetry signs those routes.
43
+ */
44
+ var TeslemetryEnergySite = class extends require_energyspecific.default {
45
+ /** Send a signed `RoutableMessage` through Teslemetry's route, which takes the flat body and adds Tesla's `data` wrapper itself. */
46
+ async _device_command(routable_message, target_id, identifier_type = require_const.EnergyDeviceIdentifierType.GATEWAY_DIN) {
47
+ return this.parent.parent._request("POST", `api/1/energy_sites/${this.energy_site_id}/device_command`, null, this._device_command_body(routable_message, target_id, identifier_type));
48
+ }
49
+ /** `GET` a Teslemetry command route. */
50
+ async _get_route(route) {
51
+ return this.parent.parent._request("GET", `api/1/energy_sites/${this.energy_site_id}/command/${route}`);
52
+ }
53
+ /** `POST` to a Teslemetry command route. */
54
+ async _post_route(route, json = null) {
55
+ return this.parent.parent._request("POST", `api/1/energy_sites/${this.energy_site_id}/command/${route}`, null, json);
56
+ }
57
+ /**
58
+ * Set the island mode on the energy gateway. With a signing key this signs
59
+ * the command with that key. Without one it calls the Teslemetry route, which
60
+ * signs it with Teslemetry's key. See `EnergySpecific.set_island_mode`.
61
+ */
62
+ async set_island_mode(mode, force) {
63
+ require_energyisland.validate_island_mode(mode, force);
64
+ if (this.signing) return super.set_island_mode(mode, force);
65
+ const result = await this._post_route("set_island_mode", force == null ? { mode } : {
66
+ mode,
67
+ force
68
+ });
69
+ require_energyspecific.raise_on_island_rejection(result);
70
+ return result;
71
+ }
72
+ /** Get backup events. Without a signing key, the Teslemetry route signs with Teslemetry's key. */
73
+ async get_backup_events() {
74
+ return this.signing ? super.get_backup_events() : this._get_route("backup_events");
75
+ }
76
+ /** Get the TEG configuration. Without a signing key, the Teslemetry route signs with Teslemetry's key. */
77
+ async get_teg_config() {
78
+ return this.signing ? super.get_teg_config() : this._get_route("config");
79
+ }
80
+ /** Get energy device system information. A pre-pairing read: never signed, even with a key. */
81
+ async get_system_info() {
82
+ return this._get_route("system_info");
83
+ }
84
+ /** Get networking status, which Teslemetry returns already unwrapped. A pre-pairing read: never signed, even with a key. */
85
+ async raw_networking_status() {
86
+ return this._get_route("networking_status");
87
+ }
88
+ /** Scan for WiFi networks on the energy gateway. */
89
+ async wifi_scan() {
90
+ return this.signing ? super.wifi_scan() : this._get_route("wifi_scan");
91
+ }
92
+ /** Get the energy device certificate. */
93
+ async get_device_cert() {
94
+ return this.signing ? super.get_device_cert() : this._get_route("device_cert");
95
+ }
96
+ /** Get cellular modem information. Without a signing key, the Teslemetry route signs with Teslemetry's key. */
97
+ async get_cellular_info() {
98
+ return this.signing ? super.get_cellular_info() : this._get_route("cellular_info");
99
+ }
100
+ /** Check for a firmware update. Without a signing key, the Teslemetry route signs with Teslemetry's key. */
101
+ async check_for_update() {
102
+ return this.signing ? super.check_for_update() : this._get_route("check_for_update");
103
+ }
104
+ /** Check the urgency of any firmware update. Without a signing key, the Teslemetry route signs with Teslemetry's key. */
105
+ async check_for_update_urgency() {
106
+ return this.signing ? super.check_for_update_urgency() : this._get_route("check_for_update_urgency");
107
+ }
108
+ /** Test internet connectivity on the energy gateway. Without a signing key, the Teslemetry route signs with Teslemetry's key. */
109
+ async check_internet() {
110
+ return this.signing ? super.check_internet() : this._get_route("check_internet");
111
+ }
112
+ /**
113
+ * Update local site configuration on the energy gateway. This writes gateway
114
+ * configuration and is an undocumented energy device gRPC command.
115
+ * @param params Raw protobuf request fields.
116
+ */
117
+ async set_local_site_config(params) {
118
+ return this.signing ? super.set_local_site_config(params) : this._post_route("set_local_site_config", params ?? {});
119
+ }
120
+ /** Get the gateway's signed commands public key. A pre-pairing read: never signed, even with a key. */
121
+ async get_signed_commands_public_key() {
122
+ return this._get_route("signed_commands_public_key");
123
+ }
124
+ /**
125
+ * Schedule a manual backup event on the energy gateway.
126
+ * @param start_time ISO 8601 timestamp for when the backup event should start.
127
+ * @param duration_seconds Duration of the backup event in seconds.
128
+ * @param priority Priority level for the backup event. A string carries values beyond 2^53.
129
+ */
130
+ async schedule_backup_event(start_time, duration_seconds, priority) {
131
+ if (this.signing) return super.schedule_backup_event(start_time, duration_seconds, priority);
132
+ const scheduling_info = require_energyspecific.backupSchedulingInfo(start_time, duration_seconds, priority);
133
+ return this._post_route("schedule_backup_event", scheduling_info ? { scheduling_info } : {});
134
+ }
135
+ /** Cancel a scheduled backup event on the energy gateway. */
136
+ async cancel_backup_event() {
137
+ return this.signing ? super.cancel_backup_event() : this._post_route("cancel_backup_event", {});
138
+ }
139
+ /**
140
+ * Register an authorized client with the energy gateway. All arguments are
141
+ * optional: if omitted, the Teslemetry server fills in its own key details. A
142
+ * site with a signing key signs the request with that key when `public_key`
143
+ * is given. Without a public key the route registers Teslemetry's own key,
144
+ * which the client key cannot sign for.
145
+ * @param public_key Raw DER bytes in the encoding matching `key_type` (RSA PKCS#1 or ECC SPKI), which are base64-encoded, or an already base64-encoded string.
146
+ * @param description Human-readable description of the client.
147
+ * @param key_type The type of key being registered.
148
+ * @param authorized_client_type The authorized client type.
149
+ */
150
+ async add_authorized_client(public_key, description, key_type, authorized_client_type) {
151
+ if (this.signing && public_key != null) return super.add_authorized_client(public_key, description ?? void 0, key_type ?? void 0, authorized_client_type ?? void 0);
152
+ return this._post_route("add_authorized_client", {
153
+ public_key: public_key == null ? null : require_energyspecific.publicKeyBase64(public_key),
154
+ description,
155
+ key_type,
156
+ authorized_client_type
157
+ });
158
+ }
159
+ /** Get networking status from the gateway's Teslemetry route, including WiFi, Ethernet, and cellular details. */
160
+ async get_networking_status() {
161
+ return this._get_route("networking_status");
162
+ }
163
+ /**
164
+ * Discover the gateway's LAN IPv4 address, for pre-filling a local control
165
+ * host. See `parse_gateway_address` for the selection rule.
166
+ * @returns The address, or `null` when the reply is well-formed but no interface yields one.
167
+ * @throws InvalidResponse on a null body or an unrecognized reply.
168
+ * @throws EnergyGatewayUnreachable when Teslemetry cannot reach the gateway.
169
+ */
170
+ async find_gateway_address() {
171
+ return require_energyparsers.parse_gateway_address(await this.get_networking_status());
172
+ }
173
+ /**
174
+ * List authorized clients on the energy gateway. Teslemetry may return JSON
175
+ * `null` when no payload is available; that value is returned unchanged.
176
+ */
177
+ async list_authorized_clients() {
178
+ return this._get_route("authorized_clients");
179
+ }
180
+ /**
181
+ * List authorized clients on the energy gateway, parsed into a typed result.
182
+ * For the unparsed reply, use `list_authorized_clients`.
183
+ * @throws InvalidResponse on a null body or an unrecognized reply, rather than treating either as "no clients".
184
+ */
185
+ async find_authorized_clients() {
186
+ return require_energyparsers.parse_authorized_clients(await this.list_authorized_clients());
187
+ }
188
+ /**
189
+ * Remove an authorized client from the energy gateway. A site with a signing
190
+ * key signs the request with that key. Removal needs no physical presence
191
+ * proof, so any paired key can revoke every other key, including the owner's.
192
+ * @param public_key Raw DER bytes, which are base64-encoded, or an already base64-encoded string as `list_authorized_clients` reports it.
193
+ */
194
+ async remove_authorized_client(public_key) {
195
+ if (this.signing) return super.remove_authorized_client(public_key);
196
+ return this._post_route("remove_authorized_client", { public_key: require_energyspecific.publicKeyBase64(public_key) });
197
+ }
198
+ /**
199
+ * Request a timed battery power setpoint on the energy gateway. Without a
200
+ * signing key the Teslemetry route still sends unsigned and gets Tesla's HTTP
201
+ * 400 (2026-10-29). See `EnergySpecific.dispatch_battery_power`.
202
+ * @param power_watts Battery power in watts: positive discharges, negative charges.
203
+ * @param duration_seconds Whole seconds from 1 to 86400.
204
+ */
205
+ async dispatch_battery_power(power_watts, duration_seconds) {
206
+ if (this.signing) return super.dispatch_battery_power(power_watts, duration_seconds);
207
+ require_energyspecific.validate_dispatch_battery_power(power_watts, duration_seconds);
208
+ return this._post_route("dispatch_battery_power", {
209
+ power_watts,
210
+ duration_seconds
211
+ });
212
+ }
213
+ /**
214
+ * Release a `dispatch_battery_power` setpoint. Without a signing key the
215
+ * Teslemetry route still sends unsigned and gets Tesla's HTTP 400 (2026-10-29).
216
+ */
217
+ async resume_battery_operation() {
218
+ return this.signing ? super.resume_battery_operation() : this._post_route("resume_battery_operation");
219
+ }
220
+ /**
221
+ * Wait for a key already registered with `add_authorized_client` to finish
222
+ * pairing, polling `find_authorized_clients` until its entry is `VERIFIED`.
223
+ *
224
+ * The gateway's presence-proof window is about 9 minutes, and a breaker toggle
225
+ * confirmed a key in as little as 59 s, with no cloud auto-verify observed.
226
+ * A poll that fails counts as no signal.
227
+ * @param public_key The key as passed to `add_authorized_client`, raw DER bytes or base64.
228
+ * @param options.verify_by_use A signed local read. Once the cloud reports `VERIFIED`, one successful call confirms the key is usable. A failure means "not yet" and polling continues, because `VERIFIED` can be seen slightly ahead of local usability.
229
+ * @param options.timeout_ms Overall bound on the wait.
230
+ * @param options.poll_interval_ms Delay between polls.
231
+ * @param options.signal Aborting rejects with the signal's reason. An in-flight call is abandoned, not cancelled.
232
+ * @returns The matched entry, once paired and confirmed.
233
+ * @throws AuthorizedClientPairingTimedOut at once on `PENDING_VERIFICATION_TIMEOUT`. The registration is dead: call `add_authorized_client` again with the same key, which resets the window, then wait again.
234
+ * @throws AuthorizedClientWaitExpired when `timeout_ms` elapses first. The registration is still alive: wait again.
235
+ */
236
+ async wait_until_paired(public_key, options = {}) {
237
+ const { verify_by_use, timeout_ms = DEFAULT_PAIRING_TIMEOUT, poll_interval_ms = DEFAULT_PAIRING_POLL_INTERVAL, signal } = options;
238
+ const target = require_energyspecific.publicKeyBase64(public_key);
239
+ const deadline = performance.now() + timeout_ms;
240
+ let last_state = null;
241
+ const expired = () => new require_exceptions.AuthorizedClientWaitExpired({
242
+ public_key: target,
243
+ state: last_state
244
+ });
245
+ /** Run one step under the deadline. A failed step is `undefined`, unless the wait was aborted. */
246
+ const attempt = async (step) => {
247
+ const result = await settleWithin(step, deadline - performance.now(), signal).catch((error) => {
248
+ if (signal?.aborted) throw error;
249
+ });
250
+ if (result === EXPIRED) throw expired();
251
+ return result;
252
+ };
253
+ while (true) {
254
+ signal?.throwIfAborted();
255
+ if (performance.now() >= deadline) throw expired();
256
+ const match = (await attempt(() => this.find_authorized_clients()))?.clients.find((client) => client.public_key === target);
257
+ if (match !== void 0) {
258
+ last_state = match.state;
259
+ if (match.state === require_const.AuthorizedClientState.PENDING_VERIFICATION_TIMEOUT) throw new require_exceptions.AuthorizedClientPairingTimedOut({
260
+ public_key: target,
261
+ state: match.state
262
+ });
263
+ if (match.state === require_const.AuthorizedClientState.VERIFIED) {
264
+ if (verify_by_use === void 0) return match;
265
+ if (performance.now() >= deadline) throw expired();
266
+ if (await attempt(async () => (await verify_by_use(), true)) === true) return match;
267
+ }
268
+ }
269
+ const remaining = deadline - performance.now();
270
+ if (remaining <= 0) throw expired();
271
+ await settleWithin(() => new Promise(() => {}), Math.min(poll_interval_ms, remaining), signal);
272
+ }
273
+ }
274
+ };
275
+ /** Creates and holds Teslemetry energy sites. */
276
+ var TeslemetryEnergySites = class extends require_energy.default {
277
+ static Site = TeslemetryEnergySite;
278
+ create(energy_site_id, private_key, din) {
279
+ return super.create(energy_site_id, private_key, din);
280
+ }
281
+ };
282
+ exports.DEFAULT_PAIRING_POLL_INTERVAL = DEFAULT_PAIRING_POLL_INTERVAL;
283
+ exports.DEFAULT_PAIRING_TIMEOUT = DEFAULT_PAIRING_TIMEOUT;
284
+ exports.TeslemetryEnergySite = TeslemetryEnergySite;
285
+ exports.TeslemetryEnergySites = TeslemetryEnergySites;
286
+ exports.parse_authorized_clients = require_energyparsers.parse_authorized_clients;
287
+ exports.parse_gateway_address = require_energyparsers.parse_gateway_address;
@@ -0,0 +1,154 @@
1
+ import { AuthorizedClientKeyType, AuthorizedClientType, EnergyDeviceIdentifierType, EnergyIslandMode } from "./const.cjs";
2
+ import Energy from "./energy.cjs";
3
+ import { AuthorizedClient, AuthorizedClients, parse_authorized_clients, parse_gateway_address } from "./energyparsers.cjs";
4
+ import EnergySpecific from "./energyspecific.cjs";
5
+ import { KeyObject } from "crypto";
6
+ /** Default overall bound on `wait_until_paired`, in milliseconds. */
7
+ export declare const DEFAULT_PAIRING_TIMEOUT = 600000;
8
+ /** Default delay between `wait_until_paired` polls, in milliseconds. */
9
+ export declare const DEFAULT_PAIRING_POLL_INTERVAL = 5000;
10
+ /**
11
+ * Teslemetry's energy site.
12
+ *
13
+ * With a signing key (see `EnergySpecific`), every device command except the
14
+ * four pre-pairing reads is signed with that key and sent through Teslemetry's
15
+ * `device_command` route. Without a key, a command uses its Teslemetry route.
16
+ * The `set_island_mode`, `backup_events` and `config` routes sign with
17
+ * Teslemetry's own key, which must be verified on the gateway, or the route
18
+ * answers 409 `energy_site_not_paired` and sends nothing. As of 2026-10-29 the
19
+ * `dispatch_battery_power`, `resume_battery_operation` and backup-event
20
+ * schedule and cancel routes still send unsigned, so Tesla answers HTTP 400:
21
+ * keyless dispatch does not work until Teslemetry signs those routes.
22
+ */
23
+ export declare class TeslemetryEnergySite extends EnergySpecific {
24
+ /** Send a signed `RoutableMessage` through Teslemetry's route, which takes the flat body and adds Tesla's `data` wrapper itself. */
25
+ _device_command(routable_message: Uint8Array, target_id: string, identifier_type?: EnergyDeviceIdentifierType): Promise<Record<string, any>>;
26
+ /** `GET` a Teslemetry command route. */
27
+ protected _get_route(route: string): Promise<any>;
28
+ /** `POST` to a Teslemetry command route. */
29
+ protected _post_route(route: string, json?: Record<string, any> | null): Promise<any>;
30
+ /**
31
+ * Set the island mode on the energy gateway. With a signing key this signs
32
+ * the command with that key. Without one it calls the Teslemetry route, which
33
+ * signs it with Teslemetry's key. See `EnergySpecific.set_island_mode`.
34
+ */
35
+ set_island_mode(mode: EnergyIslandMode | number, force?: boolean | null): Promise<Record<string, any>>;
36
+ /** Get backup events. Without a signing key, the Teslemetry route signs with Teslemetry's key. */
37
+ get_backup_events(): Promise<Record<string, any>>;
38
+ /** Get the TEG configuration. Without a signing key, the Teslemetry route signs with Teslemetry's key. */
39
+ get_teg_config(): Promise<Record<string, any>>;
40
+ /** Get energy device system information. A pre-pairing read: never signed, even with a key. */
41
+ get_system_info(): Promise<Record<string, any>>;
42
+ /** Get networking status, which Teslemetry returns already unwrapped. A pre-pairing read: never signed, even with a key. */
43
+ raw_networking_status(): Promise<Record<string, any>>;
44
+ /** Scan for WiFi networks on the energy gateway. */
45
+ wifi_scan(): Promise<Record<string, any>>;
46
+ /** Get the energy device certificate. */
47
+ get_device_cert(): Promise<Record<string, any>>;
48
+ /** Get cellular modem information. Without a signing key, the Teslemetry route signs with Teslemetry's key. */
49
+ get_cellular_info(): Promise<Record<string, any>>;
50
+ /** Check for a firmware update. Without a signing key, the Teslemetry route signs with Teslemetry's key. */
51
+ check_for_update(): Promise<Record<string, any>>;
52
+ /** Check the urgency of any firmware update. Without a signing key, the Teslemetry route signs with Teslemetry's key. */
53
+ check_for_update_urgency(): Promise<Record<string, any>>;
54
+ /** Test internet connectivity on the energy gateway. Without a signing key, the Teslemetry route signs with Teslemetry's key. */
55
+ check_internet(): Promise<Record<string, any>>;
56
+ /**
57
+ * Update local site configuration on the energy gateway. This writes gateway
58
+ * configuration and is an undocumented energy device gRPC command.
59
+ * @param params Raw protobuf request fields.
60
+ */
61
+ set_local_site_config(params?: Record<string, any> | null): Promise<Record<string, any>>;
62
+ /** Get the gateway's signed commands public key. A pre-pairing read: never signed, even with a key. */
63
+ get_signed_commands_public_key(): Promise<Record<string, any>>;
64
+ /**
65
+ * Schedule a manual backup event on the energy gateway.
66
+ * @param start_time ISO 8601 timestamp for when the backup event should start.
67
+ * @param duration_seconds Duration of the backup event in seconds.
68
+ * @param priority Priority level for the backup event. A string carries values beyond 2^53.
69
+ */
70
+ schedule_backup_event(start_time?: string | null, duration_seconds?: number | null, priority?: number | string | null): Promise<Record<string, any>>;
71
+ /** Cancel a scheduled backup event on the energy gateway. */
72
+ cancel_backup_event(): Promise<Record<string, any>>;
73
+ /**
74
+ * Register an authorized client with the energy gateway. All arguments are
75
+ * optional: if omitted, the Teslemetry server fills in its own key details. A
76
+ * site with a signing key signs the request with that key when `public_key`
77
+ * is given. Without a public key the route registers Teslemetry's own key,
78
+ * which the client key cannot sign for.
79
+ * @param public_key Raw DER bytes in the encoding matching `key_type` (RSA PKCS#1 or ECC SPKI), which are base64-encoded, or an already base64-encoded string.
80
+ * @param description Human-readable description of the client.
81
+ * @param key_type The type of key being registered.
82
+ * @param authorized_client_type The authorized client type.
83
+ */
84
+ add_authorized_client(public_key?: Uint8Array | string | null, description?: string | null, key_type?: AuthorizedClientKeyType | null, authorized_client_type?: AuthorizedClientType | null): Promise<Record<string, any>>;
85
+ /** Get networking status from the gateway's Teslemetry route, including WiFi, Ethernet, and cellular details. */
86
+ get_networking_status(): Promise<Record<string, any>>;
87
+ /**
88
+ * Discover the gateway's LAN IPv4 address, for pre-filling a local control
89
+ * host. See `parse_gateway_address` for the selection rule.
90
+ * @returns The address, or `null` when the reply is well-formed but no interface yields one.
91
+ * @throws InvalidResponse on a null body or an unrecognized reply.
92
+ * @throws EnergyGatewayUnreachable when Teslemetry cannot reach the gateway.
93
+ */
94
+ find_gateway_address(): Promise<string | null>;
95
+ /**
96
+ * List authorized clients on the energy gateway. Teslemetry may return JSON
97
+ * `null` when no payload is available; that value is returned unchanged.
98
+ */
99
+ list_authorized_clients(): Promise<Record<string, any>>;
100
+ /**
101
+ * List authorized clients on the energy gateway, parsed into a typed result.
102
+ * For the unparsed reply, use `list_authorized_clients`.
103
+ * @throws InvalidResponse on a null body or an unrecognized reply, rather than treating either as "no clients".
104
+ */
105
+ find_authorized_clients(): Promise<AuthorizedClients>;
106
+ /**
107
+ * Remove an authorized client from the energy gateway. A site with a signing
108
+ * key signs the request with that key. Removal needs no physical presence
109
+ * proof, so any paired key can revoke every other key, including the owner's.
110
+ * @param public_key Raw DER bytes, which are base64-encoded, or an already base64-encoded string as `list_authorized_clients` reports it.
111
+ */
112
+ remove_authorized_client(public_key: Uint8Array | string): Promise<Record<string, any>>;
113
+ /**
114
+ * Request a timed battery power setpoint on the energy gateway. Without a
115
+ * signing key the Teslemetry route still sends unsigned and gets Tesla's HTTP
116
+ * 400 (2026-10-29). See `EnergySpecific.dispatch_battery_power`.
117
+ * @param power_watts Battery power in watts: positive discharges, negative charges.
118
+ * @param duration_seconds Whole seconds from 1 to 86400.
119
+ */
120
+ dispatch_battery_power(power_watts: number, duration_seconds: number): Promise<Record<string, any>>;
121
+ /**
122
+ * Release a `dispatch_battery_power` setpoint. Without a signing key the
123
+ * Teslemetry route still sends unsigned and gets Tesla's HTTP 400 (2026-10-29).
124
+ */
125
+ resume_battery_operation(): Promise<Record<string, any>>;
126
+ /**
127
+ * Wait for a key already registered with `add_authorized_client` to finish
128
+ * pairing, polling `find_authorized_clients` until its entry is `VERIFIED`.
129
+ *
130
+ * The gateway's presence-proof window is about 9 minutes, and a breaker toggle
131
+ * confirmed a key in as little as 59 s, with no cloud auto-verify observed.
132
+ * A poll that fails counts as no signal.
133
+ * @param public_key The key as passed to `add_authorized_client`, raw DER bytes or base64.
134
+ * @param options.verify_by_use A signed local read. Once the cloud reports `VERIFIED`, one successful call confirms the key is usable. A failure means "not yet" and polling continues, because `VERIFIED` can be seen slightly ahead of local usability.
135
+ * @param options.timeout_ms Overall bound on the wait.
136
+ * @param options.poll_interval_ms Delay between polls.
137
+ * @param options.signal Aborting rejects with the signal's reason. An in-flight call is abandoned, not cancelled.
138
+ * @returns The matched entry, once paired and confirmed.
139
+ * @throws AuthorizedClientPairingTimedOut at once on `PENDING_VERIFICATION_TIMEOUT`. The registration is dead: call `add_authorized_client` again with the same key, which resets the window, then wait again.
140
+ * @throws AuthorizedClientWaitExpired when `timeout_ms` elapses first. The registration is still alive: wait again.
141
+ */
142
+ wait_until_paired(public_key: Uint8Array | string, options?: {
143
+ verify_by_use?: () => Promise<unknown>;
144
+ timeout_ms?: number;
145
+ poll_interval_ms?: number;
146
+ signal?: AbortSignal;
147
+ }): Promise<AuthorizedClient>;
148
+ }
149
+ /** Creates and holds Teslemetry energy sites. */
150
+ export declare class TeslemetryEnergySites extends Energy {
151
+ static Site: typeof TeslemetryEnergySite;
152
+ create(energy_site_id: number, private_key?: KeyObject, din?: string): TeslemetryEnergySite;
153
+ }
154
+ export { type AuthorizedClient, type AuthorizedClients, parse_authorized_clients, parse_gateway_address };
@@ -0,0 +1,154 @@
1
+ import { AuthorizedClientKeyType, AuthorizedClientType, EnergyDeviceIdentifierType, EnergyIslandMode } from "./const.mjs";
2
+ import Energy from "./energy.mjs";
3
+ import { AuthorizedClient, AuthorizedClients, parse_authorized_clients, parse_gateway_address } from "./energyparsers.mjs";
4
+ import EnergySpecific from "./energyspecific.mjs";
5
+ import { KeyObject } from "crypto";
6
+ /** Default overall bound on `wait_until_paired`, in milliseconds. */
7
+ export declare const DEFAULT_PAIRING_TIMEOUT = 600000;
8
+ /** Default delay between `wait_until_paired` polls, in milliseconds. */
9
+ export declare const DEFAULT_PAIRING_POLL_INTERVAL = 5000;
10
+ /**
11
+ * Teslemetry's energy site.
12
+ *
13
+ * With a signing key (see `EnergySpecific`), every device command except the
14
+ * four pre-pairing reads is signed with that key and sent through Teslemetry's
15
+ * `device_command` route. Without a key, a command uses its Teslemetry route.
16
+ * The `set_island_mode`, `backup_events` and `config` routes sign with
17
+ * Teslemetry's own key, which must be verified on the gateway, or the route
18
+ * answers 409 `energy_site_not_paired` and sends nothing. As of 2026-10-29 the
19
+ * `dispatch_battery_power`, `resume_battery_operation` and backup-event
20
+ * schedule and cancel routes still send unsigned, so Tesla answers HTTP 400:
21
+ * keyless dispatch does not work until Teslemetry signs those routes.
22
+ */
23
+ export declare class TeslemetryEnergySite extends EnergySpecific {
24
+ /** Send a signed `RoutableMessage` through Teslemetry's route, which takes the flat body and adds Tesla's `data` wrapper itself. */
25
+ _device_command(routable_message: Uint8Array, target_id: string, identifier_type?: EnergyDeviceIdentifierType): Promise<Record<string, any>>;
26
+ /** `GET` a Teslemetry command route. */
27
+ protected _get_route(route: string): Promise<any>;
28
+ /** `POST` to a Teslemetry command route. */
29
+ protected _post_route(route: string, json?: Record<string, any> | null): Promise<any>;
30
+ /**
31
+ * Set the island mode on the energy gateway. With a signing key this signs
32
+ * the command with that key. Without one it calls the Teslemetry route, which
33
+ * signs it with Teslemetry's key. See `EnergySpecific.set_island_mode`.
34
+ */
35
+ set_island_mode(mode: EnergyIslandMode | number, force?: boolean | null): Promise<Record<string, any>>;
36
+ /** Get backup events. Without a signing key, the Teslemetry route signs with Teslemetry's key. */
37
+ get_backup_events(): Promise<Record<string, any>>;
38
+ /** Get the TEG configuration. Without a signing key, the Teslemetry route signs with Teslemetry's key. */
39
+ get_teg_config(): Promise<Record<string, any>>;
40
+ /** Get energy device system information. A pre-pairing read: never signed, even with a key. */
41
+ get_system_info(): Promise<Record<string, any>>;
42
+ /** Get networking status, which Teslemetry returns already unwrapped. A pre-pairing read: never signed, even with a key. */
43
+ raw_networking_status(): Promise<Record<string, any>>;
44
+ /** Scan for WiFi networks on the energy gateway. */
45
+ wifi_scan(): Promise<Record<string, any>>;
46
+ /** Get the energy device certificate. */
47
+ get_device_cert(): Promise<Record<string, any>>;
48
+ /** Get cellular modem information. Without a signing key, the Teslemetry route signs with Teslemetry's key. */
49
+ get_cellular_info(): Promise<Record<string, any>>;
50
+ /** Check for a firmware update. Without a signing key, the Teslemetry route signs with Teslemetry's key. */
51
+ check_for_update(): Promise<Record<string, any>>;
52
+ /** Check the urgency of any firmware update. Without a signing key, the Teslemetry route signs with Teslemetry's key. */
53
+ check_for_update_urgency(): Promise<Record<string, any>>;
54
+ /** Test internet connectivity on the energy gateway. Without a signing key, the Teslemetry route signs with Teslemetry's key. */
55
+ check_internet(): Promise<Record<string, any>>;
56
+ /**
57
+ * Update local site configuration on the energy gateway. This writes gateway
58
+ * configuration and is an undocumented energy device gRPC command.
59
+ * @param params Raw protobuf request fields.
60
+ */
61
+ set_local_site_config(params?: Record<string, any> | null): Promise<Record<string, any>>;
62
+ /** Get the gateway's signed commands public key. A pre-pairing read: never signed, even with a key. */
63
+ get_signed_commands_public_key(): Promise<Record<string, any>>;
64
+ /**
65
+ * Schedule a manual backup event on the energy gateway.
66
+ * @param start_time ISO 8601 timestamp for when the backup event should start.
67
+ * @param duration_seconds Duration of the backup event in seconds.
68
+ * @param priority Priority level for the backup event. A string carries values beyond 2^53.
69
+ */
70
+ schedule_backup_event(start_time?: string | null, duration_seconds?: number | null, priority?: number | string | null): Promise<Record<string, any>>;
71
+ /** Cancel a scheduled backup event on the energy gateway. */
72
+ cancel_backup_event(): Promise<Record<string, any>>;
73
+ /**
74
+ * Register an authorized client with the energy gateway. All arguments are
75
+ * optional: if omitted, the Teslemetry server fills in its own key details. A
76
+ * site with a signing key signs the request with that key when `public_key`
77
+ * is given. Without a public key the route registers Teslemetry's own key,
78
+ * which the client key cannot sign for.
79
+ * @param public_key Raw DER bytes in the encoding matching `key_type` (RSA PKCS#1 or ECC SPKI), which are base64-encoded, or an already base64-encoded string.
80
+ * @param description Human-readable description of the client.
81
+ * @param key_type The type of key being registered.
82
+ * @param authorized_client_type The authorized client type.
83
+ */
84
+ add_authorized_client(public_key?: Uint8Array | string | null, description?: string | null, key_type?: AuthorizedClientKeyType | null, authorized_client_type?: AuthorizedClientType | null): Promise<Record<string, any>>;
85
+ /** Get networking status from the gateway's Teslemetry route, including WiFi, Ethernet, and cellular details. */
86
+ get_networking_status(): Promise<Record<string, any>>;
87
+ /**
88
+ * Discover the gateway's LAN IPv4 address, for pre-filling a local control
89
+ * host. See `parse_gateway_address` for the selection rule.
90
+ * @returns The address, or `null` when the reply is well-formed but no interface yields one.
91
+ * @throws InvalidResponse on a null body or an unrecognized reply.
92
+ * @throws EnergyGatewayUnreachable when Teslemetry cannot reach the gateway.
93
+ */
94
+ find_gateway_address(): Promise<string | null>;
95
+ /**
96
+ * List authorized clients on the energy gateway. Teslemetry may return JSON
97
+ * `null` when no payload is available; that value is returned unchanged.
98
+ */
99
+ list_authorized_clients(): Promise<Record<string, any>>;
100
+ /**
101
+ * List authorized clients on the energy gateway, parsed into a typed result.
102
+ * For the unparsed reply, use `list_authorized_clients`.
103
+ * @throws InvalidResponse on a null body or an unrecognized reply, rather than treating either as "no clients".
104
+ */
105
+ find_authorized_clients(): Promise<AuthorizedClients>;
106
+ /**
107
+ * Remove an authorized client from the energy gateway. A site with a signing
108
+ * key signs the request with that key. Removal needs no physical presence
109
+ * proof, so any paired key can revoke every other key, including the owner's.
110
+ * @param public_key Raw DER bytes, which are base64-encoded, or an already base64-encoded string as `list_authorized_clients` reports it.
111
+ */
112
+ remove_authorized_client(public_key: Uint8Array | string): Promise<Record<string, any>>;
113
+ /**
114
+ * Request a timed battery power setpoint on the energy gateway. Without a
115
+ * signing key the Teslemetry route still sends unsigned and gets Tesla's HTTP
116
+ * 400 (2026-10-29). See `EnergySpecific.dispatch_battery_power`.
117
+ * @param power_watts Battery power in watts: positive discharges, negative charges.
118
+ * @param duration_seconds Whole seconds from 1 to 86400.
119
+ */
120
+ dispatch_battery_power(power_watts: number, duration_seconds: number): Promise<Record<string, any>>;
121
+ /**
122
+ * Release a `dispatch_battery_power` setpoint. Without a signing key the
123
+ * Teslemetry route still sends unsigned and gets Tesla's HTTP 400 (2026-10-29).
124
+ */
125
+ resume_battery_operation(): Promise<Record<string, any>>;
126
+ /**
127
+ * Wait for a key already registered with `add_authorized_client` to finish
128
+ * pairing, polling `find_authorized_clients` until its entry is `VERIFIED`.
129
+ *
130
+ * The gateway's presence-proof window is about 9 minutes, and a breaker toggle
131
+ * confirmed a key in as little as 59 s, with no cloud auto-verify observed.
132
+ * A poll that fails counts as no signal.
133
+ * @param public_key The key as passed to `add_authorized_client`, raw DER bytes or base64.
134
+ * @param options.verify_by_use A signed local read. Once the cloud reports `VERIFIED`, one successful call confirms the key is usable. A failure means "not yet" and polling continues, because `VERIFIED` can be seen slightly ahead of local usability.
135
+ * @param options.timeout_ms Overall bound on the wait.
136
+ * @param options.poll_interval_ms Delay between polls.
137
+ * @param options.signal Aborting rejects with the signal's reason. An in-flight call is abandoned, not cancelled.
138
+ * @returns The matched entry, once paired and confirmed.
139
+ * @throws AuthorizedClientPairingTimedOut at once on `PENDING_VERIFICATION_TIMEOUT`. The registration is dead: call `add_authorized_client` again with the same key, which resets the window, then wait again.
140
+ * @throws AuthorizedClientWaitExpired when `timeout_ms` elapses first. The registration is still alive: wait again.
141
+ */
142
+ wait_until_paired(public_key: Uint8Array | string, options?: {
143
+ verify_by_use?: () => Promise<unknown>;
144
+ timeout_ms?: number;
145
+ poll_interval_ms?: number;
146
+ signal?: AbortSignal;
147
+ }): Promise<AuthorizedClient>;
148
+ }
149
+ /** Creates and holds Teslemetry energy sites. */
150
+ export declare class TeslemetryEnergySites extends Energy {
151
+ static Site: typeof TeslemetryEnergySite;
152
+ create(energy_site_id: number, private_key?: KeyObject, din?: string): TeslemetryEnergySite;
153
+ }
154
+ export { type AuthorizedClient, type AuthorizedClients, parse_authorized_clients, parse_gateway_address };