tesla-fleet-api 0.3.0 → 0.5.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 (342) hide show
  1. package/README.md +284 -1
  2. package/dist/_virtual/_rolldown/runtime.cjs +32 -0
  3. package/dist/_virtual/_rolldown/runtime.mjs +12 -0
  4. package/dist/bluetooth/adapters/shared.cjs +38 -0
  5. package/dist/bluetooth/adapters/shared.mjs +36 -0
  6. package/dist/bluetooth/async.cjs +121 -0
  7. package/dist/bluetooth/async.d.cts +10 -0
  8. package/dist/bluetooth/async.d.mts +10 -0
  9. package/dist/bluetooth/async.mjs +116 -0
  10. package/dist/bluetooth/broadcast.cjs +153 -0
  11. package/dist/bluetooth/broadcast.d.cts +59 -0
  12. package/dist/bluetooth/broadcast.d.mts +59 -0
  13. package/dist/bluetooth/broadcast.mjs +151 -0
  14. package/dist/bluetooth/constants.cjs +99 -0
  15. package/dist/bluetooth/constants.d.cts +70 -0
  16. package/dist/bluetooth/constants.d.mts +70 -0
  17. package/dist/bluetooth/constants.mjs +72 -0
  18. package/dist/bluetooth/esphome.cjs +292 -0
  19. package/dist/bluetooth/esphome.d.cts +83 -0
  20. package/dist/bluetooth/esphome.d.mts +83 -0
  21. package/dist/bluetooth/esphome.mjs +291 -0
  22. package/dist/bluetooth/framing.cjs +125 -0
  23. package/dist/bluetooth/framing.d.cts +45 -0
  24. package/dist/bluetooth/framing.d.mts +45 -0
  25. package/dist/bluetooth/framing.mjs +122 -0
  26. package/dist/bluetooth/homey.cjs +155 -0
  27. package/dist/bluetooth/homey.d.cts +75 -0
  28. package/dist/bluetooth/homey.d.mts +75 -0
  29. package/dist/bluetooth/homey.mjs +150 -0
  30. package/dist/bluetooth/names.cjs +24 -0
  31. package/dist/bluetooth/names.d.cts +10 -0
  32. package/dist/bluetooth/names.d.mts +10 -0
  33. package/dist/bluetooth/names.mjs +20 -0
  34. package/dist/bluetooth/noble.cjs +178 -0
  35. package/dist/bluetooth/noble.d.cts +58 -0
  36. package/dist/bluetooth/noble.d.mts +58 -0
  37. package/dist/bluetooth/noble.mjs +177 -0
  38. package/dist/bluetooth/streamglue.cjs +157 -0
  39. package/dist/bluetooth/streamglue.d.cts +37 -0
  40. package/dist/bluetooth/streamglue.d.mts +37 -0
  41. package/dist/bluetooth/streamglue.mjs +154 -0
  42. package/dist/bluetooth/teslabluetooth.cjs +67 -0
  43. package/dist/bluetooth/teslabluetooth.d.cts +41 -0
  44. package/dist/bluetooth/teslabluetooth.d.mts +41 -0
  45. package/dist/bluetooth/teslabluetooth.mjs +66 -0
  46. package/dist/bluetooth/transport.cjs +10 -0
  47. package/dist/bluetooth/transport.d.cts +95 -0
  48. package/dist/bluetooth/transport.d.mts +95 -0
  49. package/dist/bluetooth/transport.mjs +10 -0
  50. package/dist/bluetooth/vehiclebluetooth.cjs +1272 -0
  51. package/dist/bluetooth/vehiclebluetooth.d.cts +495 -0
  52. package/dist/bluetooth/vehiclebluetooth.d.mts +495 -0
  53. package/dist/bluetooth/vehiclebluetooth.mjs +1270 -0
  54. package/dist/bluetooth/verify.cjs +93 -0
  55. package/dist/bluetooth/verify.d.cts +35 -0
  56. package/dist/bluetooth/verify.d.mts +35 -0
  57. package/dist/bluetooth/verify.mjs +91 -0
  58. package/dist/bluetooth.cjs +53 -0
  59. package/dist/bluetooth.d.cts +10 -0
  60. package/dist/bluetooth.d.mts +10 -0
  61. package/dist/bluetooth.mjs +9 -0
  62. package/dist/charging.cjs +53 -0
  63. package/dist/charging.d.cts +31 -0
  64. package/dist/charging.d.mts +30 -0
  65. package/dist/charging.mjs +53 -0
  66. package/dist/commands.cjs +1797 -0
  67. package/dist/commands.d.cts +881 -0
  68. package/dist/commands.d.mts +881 -0
  69. package/dist/commands.mjs +1791 -0
  70. package/dist/const.cjs +322 -0
  71. package/dist/const.d.cts +308 -0
  72. package/dist/const.d.mts +308 -0
  73. package/dist/const.mjs +282 -0
  74. package/dist/energy.cjs +142 -0
  75. package/dist/energy.d.cts +101 -0
  76. package/dist/energy.d.mts +100 -0
  77. package/dist/energy.mjs +142 -0
  78. package/dist/energyisland.cjs +38 -0
  79. package/dist/energyisland.mjs +37 -0
  80. package/dist/energyparsers.cjs +118 -0
  81. package/dist/energyparsers.d.cts +39 -0
  82. package/dist/energyparsers.d.mts +39 -0
  83. package/dist/energyparsers.mjs +116 -0
  84. package/dist/energyspecific.cjs +457 -0
  85. package/dist/energyspecific.d.cts +258 -0
  86. package/dist/energyspecific.d.mts +258 -0
  87. package/dist/energyspecific.mjs +451 -0
  88. package/dist/exceptions.cjs +1488 -0
  89. package/dist/exceptions.d.cts +1143 -0
  90. package/dist/exceptions.d.mts +1143 -0
  91. package/dist/exceptions.mjs +1325 -0
  92. package/dist/funnel.cjs +297 -0
  93. package/dist/funnel.d.cts +118 -0
  94. package/dist/funnel.d.mts +118 -0
  95. package/dist/funnel.mjs +292 -0
  96. package/dist/index.cjs +287 -0
  97. package/dist/index.d.cts +28 -0
  98. package/dist/index.d.mts +28 -0
  99. package/dist/index.mjs +27 -0
  100. package/dist/log.cjs +75 -0
  101. package/dist/log.d.cts +4 -0
  102. package/dist/log.d.mts +4 -0
  103. package/dist/log.mjs +71 -0
  104. package/dist/oauth.cjs +143 -0
  105. package/dist/oauth.d.cts +69 -0
  106. package/dist/oauth.d.mts +69 -0
  107. package/dist/oauth.mjs +143 -0
  108. package/dist/partner.cjs +32 -0
  109. package/dist/partner.d.cts +24 -0
  110. package/dist/partner.d.mts +23 -0
  111. package/dist/partner.mjs +32 -0
  112. package/dist/powerwall/client.cjs +818 -0
  113. package/dist/powerwall/client.d.cts +297 -0
  114. package/dist/powerwall/client.d.mts +297 -0
  115. package/dist/powerwall/client.mjs +807 -0
  116. package/dist/powerwall/components.cjs +188 -0
  117. package/dist/powerwall/components.d.cts +45 -0
  118. package/dist/powerwall/components.d.mts +45 -0
  119. package/dist/powerwall/components.mjs +182 -0
  120. package/dist/powerwall/energysite.cjs +216 -0
  121. package/dist/powerwall/energysite.d.cts +104 -0
  122. package/dist/powerwall/energysite.d.mts +104 -0
  123. package/dist/powerwall/energysite.mjs +214 -0
  124. package/dist/powerwall/exceptions.cjs +59 -0
  125. package/dist/powerwall/exceptions.d.cts +38 -0
  126. package/dist/powerwall/exceptions.d.mts +38 -0
  127. package/dist/powerwall/exceptions.mjs +51 -0
  128. package/dist/powerwall/gateway.cjs +102 -0
  129. package/dist/powerwall/gateway.d.cts +57 -0
  130. package/dist/powerwall/gateway.d.mts +57 -0
  131. package/dist/powerwall/gateway.mjs +101 -0
  132. package/dist/powerwall/merge.cjs +163 -0
  133. package/dist/powerwall/merge.d.cts +63 -0
  134. package/dist/powerwall/merge.d.mts +63 -0
  135. package/dist/powerwall/merge.mjs +159 -0
  136. package/dist/powerwall/models.d.cts +95 -0
  137. package/dist/powerwall/models.d.mts +95 -0
  138. package/dist/powerwall/queries.cjs +17 -0
  139. package/dist/powerwall/queries.mjs +10 -0
  140. package/dist/powerwall/transport.cjs +232 -0
  141. package/dist/powerwall/transport.mjs +227 -0
  142. package/dist/powerwall.cjs +47 -0
  143. package/dist/powerwall.d.cts +9 -0
  144. package/dist/powerwall.d.mts +9 -0
  145. package/dist/powerwall.mjs +8 -0
  146. package/dist/router/base.cjs +203 -0
  147. package/dist/router/base.d.cts +112 -0
  148. package/dist/router/base.d.mts +112 -0
  149. package/dist/router/base.mjs +200 -0
  150. package/dist/router/energysite.cjs +65 -0
  151. package/dist/router/energysite.d.cts +47 -0
  152. package/dist/router/energysite.d.mts +47 -0
  153. package/dist/router/energysite.mjs +60 -0
  154. package/dist/router.cjs +13 -0
  155. package/dist/router.d.cts +3 -0
  156. package/dist/router.d.mts +3 -0
  157. package/dist/router.mjs +3 -0
  158. package/dist/signing/crypto.cjs +59 -0
  159. package/dist/signing/crypto.mjs +52 -0
  160. package/dist/signing/energy.cjs +123 -0
  161. package/dist/signing/energy.d.cts +45 -0
  162. package/dist/signing/energy.d.mts +45 -0
  163. package/dist/signing/energy.mjs +120 -0
  164. package/dist/signing/jws.cjs +229 -0
  165. package/dist/signing/jws.d.cts +45 -0
  166. package/dist/signing/jws.d.mts +45 -0
  167. package/dist/signing/jws.mjs +211 -0
  168. package/dist/signing/keys.cjs +191 -0
  169. package/dist/signing/keys.d.cts +21 -0
  170. package/dist/signing/keys.d.mts +21 -0
  171. package/dist/signing/keys.mjs +182 -0
  172. package/dist/signing/session.cjs +186 -0
  173. package/dist/signing/session.d.cts +106 -0
  174. package/dist/signing/session.d.mts +106 -0
  175. package/dist/signing/session.mjs +184 -0
  176. package/dist/tariff.cjs +319 -0
  177. package/dist/tariff.d.cts +40 -0
  178. package/dist/tariff.d.mts +40 -0
  179. package/dist/tariff.mjs +317 -0
  180. package/dist/teslafleetapi.cjs +326 -0
  181. package/dist/teslafleetapi.d.cts +160 -0
  182. package/dist/teslafleetapi.d.mts +160 -0
  183. package/dist/teslafleetapi.mjs +326 -0
  184. package/dist/teslemetry.cjs +183 -0
  185. package/dist/teslemetry.d.cts +113 -0
  186. package/dist/teslemetry.d.mts +113 -0
  187. package/dist/teslemetry.mjs +181 -0
  188. package/dist/teslemetryenergy.cjs +287 -0
  189. package/dist/teslemetryenergy.d.cts +154 -0
  190. package/dist/teslemetryenergy.d.mts +154 -0
  191. package/dist/teslemetryenergy.mjs +282 -0
  192. package/dist/teslemetryvehicle.cjs +407 -0
  193. package/dist/teslemetryvehicle.d.cts +238 -0
  194. package/dist/teslemetryvehicle.d.mts +238 -0
  195. package/dist/teslemetryvehicle.mjs +405 -0
  196. package/dist/tessie.cjs +71 -0
  197. package/dist/tessie.d.cts +69 -0
  198. package/dist/tessie.d.mts +69 -0
  199. package/dist/tessie.mjs +71 -0
  200. package/dist/tessievehicle.cjs +514 -0
  201. package/dist/tessievehicle.d.cts +333 -0
  202. package/dist/tessievehicle.d.mts +333 -0
  203. package/dist/tessievehicle.mjs +513 -0
  204. package/dist/types/commands.d.cts +28 -0
  205. package/dist/types/commands.d.mts +28 -0
  206. package/dist/types/live_status.d.cts +30 -0
  207. package/dist/types/live_status.d.mts +30 -0
  208. package/dist/types/products.d.cts +58 -0
  209. package/dist/types/products.d.mts +58 -0
  210. package/dist/types/responses.d.cts +13 -0
  211. package/dist/types/responses.d.mts +13 -0
  212. package/dist/types/site_info.d.cts +154 -0
  213. package/dist/types/site_info.d.mts +154 -0
  214. package/dist/types/vehicle.d.cts +33 -0
  215. package/dist/types/vehicle.d.mts +33 -0
  216. package/dist/types/vehicle_data.d.cts +278 -0
  217. package/dist/types/vehicle_data.d.mts +278 -0
  218. package/dist/types.cjs +0 -0
  219. package/dist/types.d.cts +9 -0
  220. package/dist/types.d.mts +9 -0
  221. package/dist/types.mjs +1 -0
  222. package/dist/user.cjs +28 -0
  223. package/dist/user.d.cts +17 -0
  224. package/dist/user.d.mts +16 -0
  225. package/dist/user.mjs +28 -0
  226. package/dist/util.cjs +41 -0
  227. package/dist/util.d.cts +18 -0
  228. package/dist/util.d.mts +18 -0
  229. package/dist/util.mjs +40 -0
  230. package/dist/vehicle.cjs +847 -0
  231. package/dist/vehicle.d.cts +566 -0
  232. package/dist/vehicle.d.mts +565 -0
  233. package/dist/vehicle.mjs +847 -0
  234. package/dist/vehiclesigned.cjs +35 -0
  235. package/dist/vehiclesigned.d.cts +23 -0
  236. package/dist/vehiclesigned.d.mts +22 -0
  237. package/dist/vehiclesigned.mjs +35 -0
  238. package/dist/vehiclespecific.cjs +715 -0
  239. package/dist/vehiclespecific.d.cts +497 -0
  240. package/dist/vehiclespecific.d.mts +496 -0
  241. package/dist/vehiclespecific.mjs +715 -0
  242. package/package.json +178 -38
  243. package/dist/charging.d.ts +0 -30
  244. package/dist/charging.js +0 -51
  245. package/dist/charging.js.map +0 -1
  246. package/dist/commands.d.ts +0 -352
  247. package/dist/commands.js +0 -875
  248. package/dist/commands.js.map +0 -1
  249. package/dist/energy.d.ts +0 -94
  250. package/dist/energy.js +0 -125
  251. package/dist/energy.js.map +0 -1
  252. package/dist/energyspecific.d.ts +0 -77
  253. package/dist/energyspecific.js +0 -97
  254. package/dist/energyspecific.js.map +0 -1
  255. package/dist/helpers.d.ts +0 -2
  256. package/dist/helpers.js +0 -10
  257. package/dist/helpers.js.map +0 -1
  258. package/dist/index.d.ts +0 -15
  259. package/dist/index.js +0 -15
  260. package/dist/index.js.map +0 -1
  261. package/dist/partner.d.ts +0 -23
  262. package/dist/partner.js +0 -31
  263. package/dist/partner.js.map +0 -1
  264. package/dist/signing/crypto.d.ts +0 -10
  265. package/dist/signing/crypto.js +0 -26
  266. package/dist/signing/crypto.js.map +0 -1
  267. package/dist/signing/errors.d.ts +0 -29
  268. package/dist/signing/errors.js +0 -40
  269. package/dist/signing/errors.js.map +0 -1
  270. package/dist/signing/session.d.ts +0 -69
  271. package/dist/signing/session.js +0 -102
  272. package/dist/signing/session.js.map +0 -1
  273. package/dist/tariff.d.ts +0 -29
  274. package/dist/tariff.js +0 -302
  275. package/dist/tariff.js.map +0 -1
  276. package/dist/teslafleetapi.d.ts +0 -58
  277. package/dist/teslafleetapi.js +0 -120
  278. package/dist/teslafleetapi.js.map +0 -1
  279. package/dist/teslemetry.d.ts +0 -29
  280. package/dist/teslemetry.js +0 -39
  281. package/dist/teslemetry.js.map +0 -1
  282. package/dist/tessie.d.ts +0 -23
  283. package/dist/tessie.js +0 -28
  284. package/dist/tessie.js.map +0 -1
  285. package/dist/types/commands.d.ts +0 -44
  286. package/dist/types/commands.js +0 -11
  287. package/dist/types/commands.js.map +0 -1
  288. package/dist/types/live_status.d.ts +0 -26
  289. package/dist/types/live_status.js +0 -2
  290. package/dist/types/live_status.js.map +0 -1
  291. package/dist/types/products.d.ts +0 -54
  292. package/dist/types/products.js +0 -2
  293. package/dist/types/products.js.map +0 -1
  294. package/dist/types/responses.d.ts +0 -5
  295. package/dist/types/responses.js +0 -2
  296. package/dist/types/responses.js.map +0 -1
  297. package/dist/types/site_info.d.ts +0 -150
  298. package/dist/types/site_info.js +0 -2
  299. package/dist/types/site_info.js.map +0 -1
  300. package/dist/types/vehicle.d.ts +0 -23
  301. package/dist/types/vehicle.js +0 -10
  302. package/dist/types/vehicle.js.map +0 -1
  303. package/dist/types/vehicle_data.d.ts +0 -274
  304. package/dist/types/vehicle_data.js +0 -2
  305. package/dist/types/vehicle_data.js.map +0 -1
  306. package/dist/user.d.ts +0 -16
  307. package/dist/user.js +0 -26
  308. package/dist/user.js.map +0 -1
  309. package/dist/vehicle.d.ts +0 -548
  310. package/dist/vehicle.js +0 -774
  311. package/dist/vehicle.js.map +0 -1
  312. package/dist/vehiclesigned.d.ts +0 -13
  313. package/dist/vehiclesigned.js +0 -19
  314. package/dist/vehiclesigned.js.map +0 -1
  315. package/dist/vehiclespecific.d.ts +0 -432
  316. package/dist/vehiclespecific.js +0 -601
  317. package/dist/vehiclespecific.js.map +0 -1
  318. package/src/charging.ts +0 -66
  319. package/src/commands.ts +0 -1134
  320. package/src/energy.ts +0 -217
  321. package/src/energyspecific.ts +0 -116
  322. package/src/helpers.ts +0 -11
  323. package/src/index.ts +0 -21
  324. package/src/partner.ts +0 -37
  325. package/src/signing/crypto.ts +0 -29
  326. package/src/signing/errors.ts +0 -50
  327. package/src/signing/session.ts +0 -132
  328. package/src/tariff.ts +0 -375
  329. package/src/teslafleetapi.ts +0 -182
  330. package/src/teslemetry.ts +0 -54
  331. package/src/tessie.ts +0 -42
  332. package/src/types/commands.ts +0 -62
  333. package/src/types/live_status.ts +0 -27
  334. package/src/types/products.ts +0 -61
  335. package/src/types/responses.ts +0 -1
  336. package/src/types/site_info.ts +0 -159
  337. package/src/types/vehicle.ts +0 -33
  338. package/src/types/vehicle_data.ts +0 -286
  339. package/src/user.ts +0 -35
  340. package/src/vehicle.ts +0 -886
  341. package/src/vehiclesigned.ts +0 -20
  342. package/src/vehiclespecific.ts +0 -818
@@ -0,0 +1,232 @@
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
+ const require_energy = require("../signing/energy.cjs");
3
+ const require_exceptions = require("./exceptions.cjs");
4
+ let node_crypto = require("node:crypto");
5
+ node_crypto = require_runtime.__toESM(node_crypto, 1);
6
+ let _teslemetry_tesla_protocol_energy_device_signed_message = require("@teslemetry/tesla-protocol/energy_device/signed_message");
7
+ let node_https = require("node:https");
8
+ node_https = require_runtime.__toESM(node_https, 1);
9
+ let node_util = require("node:util");
10
+ let node_zlib = require("node:zlib");
11
+ node_zlib = require_runtime.__toESM(node_zlib, 1);
12
+ // src/powerwall/transport.ts
13
+ /** A signed LAN message must reach the gateway within this window. */
14
+ const SIGNATURE_TTL_SECONDS = 12;
15
+ const DEFAULT_TIMEOUT_MS = 5e3;
16
+ const gunzip = (0, node_util.promisify)(node_zlib.default.gunzip);
17
+ const utf8 = new TextDecoder("utf-8", { fatal: true });
18
+ function isAuthStatus(status) {
19
+ return status === 401 || status === 403;
20
+ }
21
+ function isRateLimitStatus(status) {
22
+ return status === 429 || status === 503;
23
+ }
24
+ /**
25
+ * Firmware 25.42.2 and later can gzip any body, with or without a header, and
26
+ * `node:https` decompresses nothing. A valid `RoutableMessage` cannot start with
27
+ * the magic bytes, so they decide. A failed gunzip keeps the raw bytes.
28
+ */
29
+ async function decompress(body) {
30
+ if (body.length > 2 && body[0] === 31 && body[1] === 139) return gunzip(body).catch(() => body);
31
+ return body;
32
+ }
33
+ function loadPrivateKey(pem) {
34
+ let key;
35
+ try {
36
+ key = node_crypto.default.createPrivateKey(pem);
37
+ } catch (error) {
38
+ throw new require_exceptions.PowerwallAuthenticationError("Invalid RSA private key PEM", { cause: error });
39
+ }
40
+ if (key.asymmetricKeyType !== "rsa") throw new require_exceptions.PowerwallAuthenticationError(`v1r requires an RSA private key, got ${key.asymmetricKeyType}`);
41
+ return key;
42
+ }
43
+ /** A v1r reply with no inner message. Only `remove_authorized_client` and a cancel accept one. */
44
+ var PowerwallEmptyReplyError = class extends require_exceptions.PowerwallProtocolError {};
45
+ /** The gateway's wire protocol, with no knowledge of what each message means. */
46
+ var V1rTransport = class {
47
+ #host;
48
+ #timeoutMs;
49
+ #password;
50
+ #signer;
51
+ #agent;
52
+ #token = null;
53
+ #login = null;
54
+ /** @throws PowerwallAuthenticationError for a bad PEM or a key that is not RSA. */
55
+ constructor(options) {
56
+ this.#host = options.host;
57
+ this.#timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
58
+ this.#password = options.legacyGateway ? options.password : options.password.slice(-5);
59
+ this.#signer = new require_energy.EnergyDeviceSigner(loadPrivateKey(options.rsaPrivateKeyPem), SIGNATURE_TTL_SECONDS);
60
+ this.#agent = new node_https.default.Agent({
61
+ keepAlive: true,
62
+ rejectUnauthorized: false,
63
+ ALPNProtocols: ["http/1.1"]
64
+ });
65
+ }
66
+ get host() {
67
+ return this.#host;
68
+ }
69
+ get has_token() {
70
+ return this.#token !== null;
71
+ }
72
+ /** Destroy the idle sockets. A later request opens a new one. */
73
+ close() {
74
+ this.#agent.destroy();
75
+ }
76
+ /**
77
+ * Get a new bearer token. Concurrent callers share one request.
78
+ * @throws PowerwallAuthenticationError on 401 or 403, which means a wrong password.
79
+ * @throws PowerwallRateLimitError on 429 or 503.
80
+ * @throws PowerwallProtocolError on any other status, or a reply with no token.
81
+ * @throws PowerwallConnectionError on a transport failure or timeout.
82
+ */
83
+ login() {
84
+ this.#login ??= this.#requestToken().finally(() => {
85
+ this.#login = null;
86
+ });
87
+ return this.#login;
88
+ }
89
+ /**
90
+ * Fetch the gateway DIN with the bearer token.
91
+ * @throws PowerwallProtocolError when the reply is empty or not UTF-8.
92
+ */
93
+ async fetch_din() {
94
+ const body = await this.#authedGet("/tedapi/din");
95
+ let din;
96
+ try {
97
+ din = utf8.decode(body).trim();
98
+ } catch (error) {
99
+ throw new require_exceptions.PowerwallProtocolError("DIN response is not UTF-8", { cause: error });
100
+ }
101
+ if (!din) throw new require_exceptions.PowerwallProtocolError("Empty DIN from gateway");
102
+ return din;
103
+ }
104
+ /**
105
+ * GET a JSON REST endpoint with the bearer token, logging in again once on 401 or 403.
106
+ * @throws PowerwallProtocolError when the body is not JSON.
107
+ */
108
+ async api_get(path) {
109
+ const body = await this.#authedGet(path);
110
+ try {
111
+ return JSON.parse(body.toString("utf8"));
112
+ } catch (error) {
113
+ throw new require_exceptions.PowerwallProtocolError(`GET ${path} did not return JSON`, { cause: error });
114
+ }
115
+ }
116
+ /**
117
+ * POST a signed `RoutableMessage`, once, and return the inner `MessageEnvelope` bytes.
118
+ *
119
+ * There is no retry at any level: the same bytes execute again if they arrive
120
+ * before `expires_at`.
121
+ * @param envelope The serialized `MessageEnvelope`.
122
+ * @param din The gateway DIN.
123
+ * @param signing `now` and `messageUuid` exist for test vectors.
124
+ * @throws PowerwallAuthenticationError on 401 or 403, an unknown key fault, or the "authorization not verified" placeholder.
125
+ * @throws PowerwallRateLimitError on 429 or 503.
126
+ * @throws PowerwallFaultError on any other fault.
127
+ * @throws PowerwallEmptyReplyError on a reply with no inner message.
128
+ * @throws PowerwallProtocolError on any other status, or a malformed reply.
129
+ * @throws PowerwallConnectionError on a transport failure or timeout.
130
+ */
131
+ async post_v1r(envelope, din, signing) {
132
+ const payload = await this.#signer.sign(envelope, din, signing);
133
+ const { status, body } = await this.#request("v1r POST", "/tedapi/v1r", {
134
+ method: "POST",
135
+ headers: { "Content-Type": "application/octet-stream" },
136
+ body: payload
137
+ });
138
+ if (isAuthStatus(status)) throw new require_exceptions.PowerwallAuthenticationError(`v1r POST rejected with ${status}`);
139
+ if (isRateLimitStatus(status)) throw new require_exceptions.PowerwallRateLimitError(`Rate-limited by gateway on v1r POST (status ${status})`);
140
+ if (status !== 200) throw new require_exceptions.PowerwallProtocolError(`v1r POST returned ${status}`);
141
+ let response;
142
+ try {
143
+ response = _teslemetry_tesla_protocol_energy_device_signed_message.RoutableMessage.decode(body);
144
+ } catch (error) {
145
+ throw new require_exceptions.PowerwallProtocolError("Malformed RoutableMessage", { cause: error });
146
+ }
147
+ const fault = response.signedMessageStatus?.messageFault ?? _teslemetry_tesla_protocol_energy_device_signed_message.MessageFaultE.MESSAGEFAULT_ERROR_NONE;
148
+ if (fault === _teslemetry_tesla_protocol_energy_device_signed_message.MessageFaultE.MESSAGEFAULT_ERROR_UNKNOWN_KEY_ID) throw new require_exceptions.PowerwallAuthenticationError(`RSA key not registered with this Powerwall (fault: ${(0, _teslemetry_tesla_protocol_energy_device_signed_message.messageFaultEToJSON)(fault)})`);
149
+ if (fault !== _teslemetry_tesla_protocol_energy_device_signed_message.MessageFaultE.MESSAGEFAULT_ERROR_NONE) {
150
+ const name = (0, _teslemetry_tesla_protocol_energy_device_signed_message.messageFaultEToJSON)(fault);
151
+ throw new require_exceptions.PowerwallFaultError(name === "UNRECOGNIZED" ? `UNRECOGNIZED_FAULT_${fault}` : name);
152
+ }
153
+ const inner = response.protobufMessageAsBytes;
154
+ if (inner && /authorization not verified/i.test(Buffer.from(inner).toString("latin1"))) throw new require_exceptions.PowerwallAuthenticationError("v1r: client authorization not verified: the RSA key is not paired");
155
+ if (!inner?.length) throw new PowerwallEmptyReplyError("RoutableMessage response is empty");
156
+ return inner;
157
+ }
158
+ async #requestToken() {
159
+ const { status, body } = await this.#request("Login", "/api/login/Basic", {
160
+ method: "POST",
161
+ headers: { "Content-Type": "application/json" },
162
+ body: Buffer.from(JSON.stringify({
163
+ username: "customer",
164
+ password: this.#password,
165
+ email: "customer@customer.domain",
166
+ clientInfo: { timezone: "America/Chicago" }
167
+ }))
168
+ });
169
+ if (isAuthStatus(status)) throw new require_exceptions.PowerwallAuthenticationError(`Login rejected (${status}): check the gateway password`);
170
+ if (isRateLimitStatus(status)) throw new require_exceptions.PowerwallRateLimitError(`Rate-limited by gateway on login (status ${status})`);
171
+ if (status !== 200) throw new require_exceptions.PowerwallProtocolError(`Login failed (${status}): ${body.toString("utf8").slice(0, 200)}`);
172
+ let data;
173
+ try {
174
+ data = JSON.parse(body.toString("utf8"));
175
+ } catch {
176
+ data = null;
177
+ }
178
+ const token = data?.token;
179
+ if (typeof token !== "string" || !token) throw new require_exceptions.PowerwallProtocolError("Login response missing 'token'");
180
+ this.#token = token;
181
+ return token;
182
+ }
183
+ async #authedGet(path) {
184
+ let token = this.#token ?? await this.login();
185
+ for (let attempt = 0; attempt < 2; attempt++) {
186
+ const { status, body } = await this.#request(`GET ${path}`, path, {
187
+ method: "GET",
188
+ headers: { Authorization: `Bearer ${token}` }
189
+ });
190
+ if (status === 200) return body;
191
+ if (isRateLimitStatus(status)) throw new require_exceptions.PowerwallRateLimitError(`Rate-limited by gateway on GET ${path} (status ${status})`);
192
+ if (!isAuthStatus(status)) throw new require_exceptions.PowerwallProtocolError(`GET ${path} returned ${status}`);
193
+ if (attempt === 0) {
194
+ this.#token = null;
195
+ token = await this.login();
196
+ }
197
+ }
198
+ throw new require_exceptions.PowerwallAuthenticationError(`GET ${path} unauthorized after token refresh`);
199
+ }
200
+ /** Send one request and read the whole body. Every failure here is a `PowerwallConnectionError`. */
201
+ async #request(label, path, init) {
202
+ const signal = AbortSignal.timeout(this.#timeoutMs);
203
+ try {
204
+ const response = await new Promise((resolve, reject) => {
205
+ const request = node_https.default.request(new URL(`https://${this.#host}${path}`), {
206
+ method: init.method,
207
+ agent: this.#agent,
208
+ signal,
209
+ headers: {
210
+ ...init.headers,
211
+ "Accept-Encoding": "gzip",
212
+ ...init.body ? { "Content-Length": String(init.body.length) } : {}
213
+ }
214
+ }, resolve);
215
+ request.on("error", reject);
216
+ request.end(init.body);
217
+ });
218
+ const chunks = [];
219
+ for await (const chunk of response) chunks.push(chunk);
220
+ return {
221
+ status: response.statusCode ?? 0,
222
+ body: await decompress(Buffer.concat(chunks))
223
+ };
224
+ } catch (error) {
225
+ if (error instanceof require_exceptions.PowerwallError) throw error;
226
+ const detail = signal.aborted ? "timed out" : `transport error: ${error.message}`;
227
+ throw new require_exceptions.PowerwallConnectionError(`${label} ${detail}`, { cause: error });
228
+ }
229
+ }
230
+ };
231
+ exports.PowerwallEmptyReplyError = PowerwallEmptyReplyError;
232
+ exports.V1rTransport = V1rTransport;
@@ -0,0 +1,227 @@
1
+ import { EnergyDeviceSigner } from "../signing/energy.mjs";
2
+ import { PowerwallAuthenticationError, PowerwallConnectionError, PowerwallError, PowerwallFaultError, PowerwallProtocolError, PowerwallRateLimitError } from "./exceptions.mjs";
3
+ import crypto from "node:crypto";
4
+ import { MessageFaultE, RoutableMessage, messageFaultEToJSON } from "@teslemetry/tesla-protocol/energy_device/signed_message";
5
+ import https from "node:https";
6
+ import { promisify } from "node:util";
7
+ import zlib from "node:zlib";
8
+ // src/powerwall/transport.ts
9
+ /** A signed LAN message must reach the gateway within this window. */
10
+ const SIGNATURE_TTL_SECONDS = 12;
11
+ const DEFAULT_TIMEOUT_MS = 5e3;
12
+ const gunzip = promisify(zlib.gunzip);
13
+ const utf8 = new TextDecoder("utf-8", { fatal: true });
14
+ function isAuthStatus(status) {
15
+ return status === 401 || status === 403;
16
+ }
17
+ function isRateLimitStatus(status) {
18
+ return status === 429 || status === 503;
19
+ }
20
+ /**
21
+ * Firmware 25.42.2 and later can gzip any body, with or without a header, and
22
+ * `node:https` decompresses nothing. A valid `RoutableMessage` cannot start with
23
+ * the magic bytes, so they decide. A failed gunzip keeps the raw bytes.
24
+ */
25
+ async function decompress(body) {
26
+ if (body.length > 2 && body[0] === 31 && body[1] === 139) return gunzip(body).catch(() => body);
27
+ return body;
28
+ }
29
+ function loadPrivateKey(pem) {
30
+ let key;
31
+ try {
32
+ key = crypto.createPrivateKey(pem);
33
+ } catch (error) {
34
+ throw new PowerwallAuthenticationError("Invalid RSA private key PEM", { cause: error });
35
+ }
36
+ if (key.asymmetricKeyType !== "rsa") throw new PowerwallAuthenticationError(`v1r requires an RSA private key, got ${key.asymmetricKeyType}`);
37
+ return key;
38
+ }
39
+ /** A v1r reply with no inner message. Only `remove_authorized_client` and a cancel accept one. */
40
+ var PowerwallEmptyReplyError = class extends PowerwallProtocolError {};
41
+ /** The gateway's wire protocol, with no knowledge of what each message means. */
42
+ var V1rTransport = class {
43
+ #host;
44
+ #timeoutMs;
45
+ #password;
46
+ #signer;
47
+ #agent;
48
+ #token = null;
49
+ #login = null;
50
+ /** @throws PowerwallAuthenticationError for a bad PEM or a key that is not RSA. */
51
+ constructor(options) {
52
+ this.#host = options.host;
53
+ this.#timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
54
+ this.#password = options.legacyGateway ? options.password : options.password.slice(-5);
55
+ this.#signer = new EnergyDeviceSigner(loadPrivateKey(options.rsaPrivateKeyPem), SIGNATURE_TTL_SECONDS);
56
+ this.#agent = new https.Agent({
57
+ keepAlive: true,
58
+ rejectUnauthorized: false,
59
+ ALPNProtocols: ["http/1.1"]
60
+ });
61
+ }
62
+ get host() {
63
+ return this.#host;
64
+ }
65
+ get has_token() {
66
+ return this.#token !== null;
67
+ }
68
+ /** Destroy the idle sockets. A later request opens a new one. */
69
+ close() {
70
+ this.#agent.destroy();
71
+ }
72
+ /**
73
+ * Get a new bearer token. Concurrent callers share one request.
74
+ * @throws PowerwallAuthenticationError on 401 or 403, which means a wrong password.
75
+ * @throws PowerwallRateLimitError on 429 or 503.
76
+ * @throws PowerwallProtocolError on any other status, or a reply with no token.
77
+ * @throws PowerwallConnectionError on a transport failure or timeout.
78
+ */
79
+ login() {
80
+ this.#login ??= this.#requestToken().finally(() => {
81
+ this.#login = null;
82
+ });
83
+ return this.#login;
84
+ }
85
+ /**
86
+ * Fetch the gateway DIN with the bearer token.
87
+ * @throws PowerwallProtocolError when the reply is empty or not UTF-8.
88
+ */
89
+ async fetch_din() {
90
+ const body = await this.#authedGet("/tedapi/din");
91
+ let din;
92
+ try {
93
+ din = utf8.decode(body).trim();
94
+ } catch (error) {
95
+ throw new PowerwallProtocolError("DIN response is not UTF-8", { cause: error });
96
+ }
97
+ if (!din) throw new PowerwallProtocolError("Empty DIN from gateway");
98
+ return din;
99
+ }
100
+ /**
101
+ * GET a JSON REST endpoint with the bearer token, logging in again once on 401 or 403.
102
+ * @throws PowerwallProtocolError when the body is not JSON.
103
+ */
104
+ async api_get(path) {
105
+ const body = await this.#authedGet(path);
106
+ try {
107
+ return JSON.parse(body.toString("utf8"));
108
+ } catch (error) {
109
+ throw new PowerwallProtocolError(`GET ${path} did not return JSON`, { cause: error });
110
+ }
111
+ }
112
+ /**
113
+ * POST a signed `RoutableMessage`, once, and return the inner `MessageEnvelope` bytes.
114
+ *
115
+ * There is no retry at any level: the same bytes execute again if they arrive
116
+ * before `expires_at`.
117
+ * @param envelope The serialized `MessageEnvelope`.
118
+ * @param din The gateway DIN.
119
+ * @param signing `now` and `messageUuid` exist for test vectors.
120
+ * @throws PowerwallAuthenticationError on 401 or 403, an unknown key fault, or the "authorization not verified" placeholder.
121
+ * @throws PowerwallRateLimitError on 429 or 503.
122
+ * @throws PowerwallFaultError on any other fault.
123
+ * @throws PowerwallEmptyReplyError on a reply with no inner message.
124
+ * @throws PowerwallProtocolError on any other status, or a malformed reply.
125
+ * @throws PowerwallConnectionError on a transport failure or timeout.
126
+ */
127
+ async post_v1r(envelope, din, signing) {
128
+ const payload = await this.#signer.sign(envelope, din, signing);
129
+ const { status, body } = await this.#request("v1r POST", "/tedapi/v1r", {
130
+ method: "POST",
131
+ headers: { "Content-Type": "application/octet-stream" },
132
+ body: payload
133
+ });
134
+ if (isAuthStatus(status)) throw new PowerwallAuthenticationError(`v1r POST rejected with ${status}`);
135
+ if (isRateLimitStatus(status)) throw new PowerwallRateLimitError(`Rate-limited by gateway on v1r POST (status ${status})`);
136
+ if (status !== 200) throw new PowerwallProtocolError(`v1r POST returned ${status}`);
137
+ let response;
138
+ try {
139
+ response = RoutableMessage.decode(body);
140
+ } catch (error) {
141
+ throw new PowerwallProtocolError("Malformed RoutableMessage", { cause: error });
142
+ }
143
+ const fault = response.signedMessageStatus?.messageFault ?? MessageFaultE.MESSAGEFAULT_ERROR_NONE;
144
+ if (fault === MessageFaultE.MESSAGEFAULT_ERROR_UNKNOWN_KEY_ID) throw new PowerwallAuthenticationError(`RSA key not registered with this Powerwall (fault: ${messageFaultEToJSON(fault)})`);
145
+ if (fault !== MessageFaultE.MESSAGEFAULT_ERROR_NONE) {
146
+ const name = messageFaultEToJSON(fault);
147
+ throw new PowerwallFaultError(name === "UNRECOGNIZED" ? `UNRECOGNIZED_FAULT_${fault}` : name);
148
+ }
149
+ const inner = response.protobufMessageAsBytes;
150
+ if (inner && /authorization not verified/i.test(Buffer.from(inner).toString("latin1"))) throw new PowerwallAuthenticationError("v1r: client authorization not verified: the RSA key is not paired");
151
+ if (!inner?.length) throw new PowerwallEmptyReplyError("RoutableMessage response is empty");
152
+ return inner;
153
+ }
154
+ async #requestToken() {
155
+ const { status, body } = await this.#request("Login", "/api/login/Basic", {
156
+ method: "POST",
157
+ headers: { "Content-Type": "application/json" },
158
+ body: Buffer.from(JSON.stringify({
159
+ username: "customer",
160
+ password: this.#password,
161
+ email: "customer@customer.domain",
162
+ clientInfo: { timezone: "America/Chicago" }
163
+ }))
164
+ });
165
+ if (isAuthStatus(status)) throw new PowerwallAuthenticationError(`Login rejected (${status}): check the gateway password`);
166
+ if (isRateLimitStatus(status)) throw new PowerwallRateLimitError(`Rate-limited by gateway on login (status ${status})`);
167
+ if (status !== 200) throw new PowerwallProtocolError(`Login failed (${status}): ${body.toString("utf8").slice(0, 200)}`);
168
+ let data;
169
+ try {
170
+ data = JSON.parse(body.toString("utf8"));
171
+ } catch {
172
+ data = null;
173
+ }
174
+ const token = data?.token;
175
+ if (typeof token !== "string" || !token) throw new PowerwallProtocolError("Login response missing 'token'");
176
+ this.#token = token;
177
+ return token;
178
+ }
179
+ async #authedGet(path) {
180
+ let token = this.#token ?? await this.login();
181
+ for (let attempt = 0; attempt < 2; attempt++) {
182
+ const { status, body } = await this.#request(`GET ${path}`, path, {
183
+ method: "GET",
184
+ headers: { Authorization: `Bearer ${token}` }
185
+ });
186
+ if (status === 200) return body;
187
+ if (isRateLimitStatus(status)) throw new PowerwallRateLimitError(`Rate-limited by gateway on GET ${path} (status ${status})`);
188
+ if (!isAuthStatus(status)) throw new PowerwallProtocolError(`GET ${path} returned ${status}`);
189
+ if (attempt === 0) {
190
+ this.#token = null;
191
+ token = await this.login();
192
+ }
193
+ }
194
+ throw new PowerwallAuthenticationError(`GET ${path} unauthorized after token refresh`);
195
+ }
196
+ /** Send one request and read the whole body. Every failure here is a `PowerwallConnectionError`. */
197
+ async #request(label, path, init) {
198
+ const signal = AbortSignal.timeout(this.#timeoutMs);
199
+ try {
200
+ const response = await new Promise((resolve, reject) => {
201
+ const request = https.request(new URL(`https://${this.#host}${path}`), {
202
+ method: init.method,
203
+ agent: this.#agent,
204
+ signal,
205
+ headers: {
206
+ ...init.headers,
207
+ "Accept-Encoding": "gzip",
208
+ ...init.body ? { "Content-Length": String(init.body.length) } : {}
209
+ }
210
+ }, resolve);
211
+ request.on("error", reject);
212
+ request.end(init.body);
213
+ });
214
+ const chunks = [];
215
+ for await (const chunk of response) chunks.push(chunk);
216
+ return {
217
+ status: response.statusCode ?? 0,
218
+ body: await decompress(Buffer.concat(chunks))
219
+ };
220
+ } catch (error) {
221
+ if (error instanceof PowerwallError) throw error;
222
+ const detail = signal.aborted ? "timed out" : `transport error: ${error.message}`;
223
+ throw new PowerwallConnectionError(`${label} ${detail}`, { cause: error });
224
+ }
225
+ }
226
+ };
227
+ export { PowerwallEmptyReplyError, V1rTransport };
@@ -0,0 +1,47 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_energyparsers = require("./energyparsers.cjs");
3
+ const require_client = require("./powerwall/client.cjs");
4
+ const require_components = require("./powerwall/components.cjs");
5
+ const require_energysite = require("./powerwall/energysite.cjs");
6
+ const require_exceptions = require("./powerwall/exceptions.cjs");
7
+ const require_gateway = require("./powerwall/gateway.cjs");
8
+ const require_merge = require("./powerwall/merge.cjs");
9
+ exports.DEFAULT_GATEWAY_HOST = require_client.DEFAULT_GATEWAY_HOST;
10
+ exports.ENERGY_CONFIG_INTERVAL_MS = require_merge.ENERGY_CONFIG_INTERVAL_MS;
11
+ exports.ENERGY_LIVE_INTERVAL_MS = require_merge.ENERGY_LIVE_INTERVAL_MS;
12
+ exports.ENERGY_LIVE_LOCAL_MAX_BACKOFF_MS = require_merge.ENERGY_LIVE_LOCAL_MAX_BACKOFF_MS;
13
+ exports.GRID_EXPORT_RULES = require_client.GRID_EXPORT_RULES;
14
+ exports.ISLAND_MODE_OFF_GRID = require_energysite.ISLAND_MODE_OFF_GRID;
15
+ exports.ISLAND_MODE_ON_GRID = require_energysite.ISLAND_MODE_ON_GRID;
16
+ exports.LiveStatusMerge = require_merge.LiveStatusMerge;
17
+ exports.OPERATION_MODES = require_client.OPERATION_MODES;
18
+ exports.PowerwallAuthenticationError = require_exceptions.PowerwallAuthenticationError;
19
+ exports.PowerwallClient = require_client.PowerwallClient;
20
+ exports.PowerwallCommandError = require_exceptions.PowerwallCommandError;
21
+ exports.PowerwallConnectionError = require_exceptions.PowerwallConnectionError;
22
+ exports.PowerwallEnergySite = require_energysite.PowerwallEnergySite;
23
+ exports.PowerwallError = require_exceptions.PowerwallError;
24
+ exports.PowerwallFaultError = require_exceptions.PowerwallFaultError;
25
+ exports.PowerwallKeyRejectedError = require_exceptions.PowerwallKeyRejectedError;
26
+ exports.PowerwallNotSupportedError = require_exceptions.PowerwallNotSupportedError;
27
+ exports.PowerwallProtocolError = require_exceptions.PowerwallProtocolError;
28
+ exports.PowerwallRateLimitError = require_exceptions.PowerwallRateLimitError;
29
+ exports.SiteInfoMerge = require_merge.SiteInfoMerge;
30
+ exports.backup_time_remaining = require_client.backup_time_remaining;
31
+ exports.battery_level = require_client.battery_level;
32
+ exports.battery_level_raw = require_client.battery_level_raw;
33
+ exports.battery_units = require_components.battery_units;
34
+ exports.component = require_components.component;
35
+ exports.component_float = require_components.component_float;
36
+ exports.component_part_number = require_components.component_part_number;
37
+ exports.component_serial = require_components.component_serial;
38
+ exports.component_signal = require_components.component_signal;
39
+ exports.connect_gateway = require_gateway.connect_gateway;
40
+ exports.current_power = require_client.current_power;
41
+ exports.parse_authorized_clients = require_energyparsers.parse_authorized_clients;
42
+ exports.pv_string_current = require_components.pv_string_current;
43
+ exports.raw_to_scaled_reserve = require_client.raw_to_scaled_reserve;
44
+ exports.raw_to_scaled_soc = require_client.raw_to_scaled_soc;
45
+ exports.scaled_to_raw_reserve = require_client.scaled_to_raw_reserve;
46
+ exports.scaled_to_raw_soc = require_client.scaled_to_raw_soc;
47
+ exports.verify_local_gateway = require_gateway.verify_local_gateway;
@@ -0,0 +1,9 @@
1
+ import { AuthorizedClient, AuthorizedClients, parse_authorized_clients } from "./energyparsers.cjs";
2
+ import { DEFAULT_GATEWAY_HOST, GRID_EXPORT_RULES, OPERATION_MODES, PowerwallClient, PowerwallClientOptions, backup_time_remaining, battery_level, battery_level_raw, current_power, raw_to_scaled_reserve, raw_to_scaled_soc, scaled_to_raw_reserve, scaled_to_raw_soc } from "./powerwall/client.cjs";
3
+ import { BatteryRole, BatteryUnit, SignalValue, battery_units, component, component_float, component_part_number, component_serial, component_signal, pv_string_current } from "./powerwall/components.cjs";
4
+ import { CommandResult, ISLAND_MODE_OFF_GRID, ISLAND_MODE_ON_GRID, LocalConfig, PowerwallEnergySite } from "./powerwall/energysite.cjs";
5
+ import { PowerwallAuthenticationError, PowerwallCommandError, PowerwallConnectionError, PowerwallError, PowerwallFaultError, PowerwallKeyRejectedError, PowerwallNotSupportedError, PowerwallProtocolError, PowerwallRateLimitError } from "./powerwall/exceptions.cjs";
6
+ import { ConnectGatewayOptions, ConnectGatewayResult, GatewayOutcome, connect_gateway, verify_local_gateway } from "./powerwall/gateway.cjs";
7
+ import { ENERGY_CONFIG_INTERVAL_MS, ENERGY_LIVE_INTERVAL_MS, ENERGY_LIVE_LOCAL_MAX_BACKOFF_MS, LiveStatusMerge, MergeOptions, SiteInfoMerge } from "./powerwall/merge.cjs";
8
+ import { AuthorizedClientRecord, AuthorizedClientsPayload, BackupEvent, BackupEventsPayload, BatteryCalibrationDelayStatus, ComponentsPayload, ConfigPayload, ControllableDeviceProgram, ControllableDeviceProgramsPayload, ControllerPayload, EnumName, FirmwareDetails, ManualBackupInfo, PowerLocation, ProgramBoundary, StatusPayload } from "./powerwall/models.cjs";
9
+ export { type AuthorizedClient, type AuthorizedClientRecord, type AuthorizedClients, type AuthorizedClientsPayload, type BackupEvent, type BackupEventsPayload, type BatteryCalibrationDelayStatus, type BatteryRole, type BatteryUnit, type CommandResult, type ComponentsPayload, type ConfigPayload, type ConnectGatewayOptions, type ConnectGatewayResult, type ControllableDeviceProgram, type ControllableDeviceProgramsPayload, type ControllerPayload, DEFAULT_GATEWAY_HOST, ENERGY_CONFIG_INTERVAL_MS, ENERGY_LIVE_INTERVAL_MS, ENERGY_LIVE_LOCAL_MAX_BACKOFF_MS, type EnumName, type FirmwareDetails, GRID_EXPORT_RULES, type GatewayOutcome, ISLAND_MODE_OFF_GRID, ISLAND_MODE_ON_GRID, LiveStatusMerge, type LocalConfig, type ManualBackupInfo, type MergeOptions, OPERATION_MODES, type PowerLocation, PowerwallAuthenticationError, PowerwallClient, type PowerwallClientOptions, PowerwallCommandError, PowerwallConnectionError, PowerwallEnergySite, PowerwallError, PowerwallFaultError, PowerwallKeyRejectedError, PowerwallNotSupportedError, PowerwallProtocolError, PowerwallRateLimitError, type ProgramBoundary, type SignalValue, SiteInfoMerge, type StatusPayload, backup_time_remaining, battery_level, battery_level_raw, battery_units, component, component_float, component_part_number, component_serial, component_signal, connect_gateway, current_power, parse_authorized_clients, pv_string_current, raw_to_scaled_reserve, raw_to_scaled_soc, scaled_to_raw_reserve, scaled_to_raw_soc, verify_local_gateway };
@@ -0,0 +1,9 @@
1
+ import { AuthorizedClient, AuthorizedClients, parse_authorized_clients } from "./energyparsers.mjs";
2
+ import { DEFAULT_GATEWAY_HOST, GRID_EXPORT_RULES, OPERATION_MODES, PowerwallClient, PowerwallClientOptions, backup_time_remaining, battery_level, battery_level_raw, current_power, raw_to_scaled_reserve, raw_to_scaled_soc, scaled_to_raw_reserve, scaled_to_raw_soc } from "./powerwall/client.mjs";
3
+ import { BatteryRole, BatteryUnit, SignalValue, battery_units, component, component_float, component_part_number, component_serial, component_signal, pv_string_current } from "./powerwall/components.mjs";
4
+ import { CommandResult, ISLAND_MODE_OFF_GRID, ISLAND_MODE_ON_GRID, LocalConfig, PowerwallEnergySite } from "./powerwall/energysite.mjs";
5
+ import { PowerwallAuthenticationError, PowerwallCommandError, PowerwallConnectionError, PowerwallError, PowerwallFaultError, PowerwallKeyRejectedError, PowerwallNotSupportedError, PowerwallProtocolError, PowerwallRateLimitError } from "./powerwall/exceptions.mjs";
6
+ import { ConnectGatewayOptions, ConnectGatewayResult, GatewayOutcome, connect_gateway, verify_local_gateway } from "./powerwall/gateway.mjs";
7
+ import { ENERGY_CONFIG_INTERVAL_MS, ENERGY_LIVE_INTERVAL_MS, ENERGY_LIVE_LOCAL_MAX_BACKOFF_MS, LiveStatusMerge, MergeOptions, SiteInfoMerge } from "./powerwall/merge.mjs";
8
+ import { AuthorizedClientRecord, AuthorizedClientsPayload, BackupEvent, BackupEventsPayload, BatteryCalibrationDelayStatus, ComponentsPayload, ConfigPayload, ControllableDeviceProgram, ControllableDeviceProgramsPayload, ControllerPayload, EnumName, FirmwareDetails, ManualBackupInfo, PowerLocation, ProgramBoundary, StatusPayload } from "./powerwall/models.mjs";
9
+ export { type AuthorizedClient, type AuthorizedClientRecord, type AuthorizedClients, type AuthorizedClientsPayload, type BackupEvent, type BackupEventsPayload, type BatteryCalibrationDelayStatus, type BatteryRole, type BatteryUnit, type CommandResult, type ComponentsPayload, type ConfigPayload, type ConnectGatewayOptions, type ConnectGatewayResult, type ControllableDeviceProgram, type ControllableDeviceProgramsPayload, type ControllerPayload, DEFAULT_GATEWAY_HOST, ENERGY_CONFIG_INTERVAL_MS, ENERGY_LIVE_INTERVAL_MS, ENERGY_LIVE_LOCAL_MAX_BACKOFF_MS, type EnumName, type FirmwareDetails, GRID_EXPORT_RULES, type GatewayOutcome, ISLAND_MODE_OFF_GRID, ISLAND_MODE_ON_GRID, LiveStatusMerge, type LocalConfig, type ManualBackupInfo, type MergeOptions, OPERATION_MODES, type PowerLocation, PowerwallAuthenticationError, PowerwallClient, type PowerwallClientOptions, PowerwallCommandError, PowerwallConnectionError, PowerwallEnergySite, PowerwallError, PowerwallFaultError, PowerwallKeyRejectedError, PowerwallNotSupportedError, PowerwallProtocolError, PowerwallRateLimitError, type ProgramBoundary, type SignalValue, SiteInfoMerge, type StatusPayload, backup_time_remaining, battery_level, battery_level_raw, battery_units, component, component_float, component_part_number, component_serial, component_signal, connect_gateway, current_power, parse_authorized_clients, pv_string_current, raw_to_scaled_reserve, raw_to_scaled_soc, scaled_to_raw_reserve, scaled_to_raw_soc, verify_local_gateway };
@@ -0,0 +1,8 @@
1
+ import { parse_authorized_clients } from "./energyparsers.mjs";
2
+ import { DEFAULT_GATEWAY_HOST, GRID_EXPORT_RULES, OPERATION_MODES, PowerwallClient, backup_time_remaining, battery_level, battery_level_raw, current_power, raw_to_scaled_reserve, raw_to_scaled_soc, scaled_to_raw_reserve, scaled_to_raw_soc } from "./powerwall/client.mjs";
3
+ import { battery_units, component, component_float, component_part_number, component_serial, component_signal, pv_string_current } from "./powerwall/components.mjs";
4
+ import { ISLAND_MODE_OFF_GRID, ISLAND_MODE_ON_GRID, PowerwallEnergySite } from "./powerwall/energysite.mjs";
5
+ import { PowerwallAuthenticationError, PowerwallCommandError, PowerwallConnectionError, PowerwallError, PowerwallFaultError, PowerwallKeyRejectedError, PowerwallNotSupportedError, PowerwallProtocolError, PowerwallRateLimitError } from "./powerwall/exceptions.mjs";
6
+ import { connect_gateway, verify_local_gateway } from "./powerwall/gateway.mjs";
7
+ import { ENERGY_CONFIG_INTERVAL_MS, ENERGY_LIVE_INTERVAL_MS, ENERGY_LIVE_LOCAL_MAX_BACKOFF_MS, LiveStatusMerge, SiteInfoMerge } from "./powerwall/merge.mjs";
8
+ export { DEFAULT_GATEWAY_HOST, ENERGY_CONFIG_INTERVAL_MS, ENERGY_LIVE_INTERVAL_MS, ENERGY_LIVE_LOCAL_MAX_BACKOFF_MS, GRID_EXPORT_RULES, ISLAND_MODE_OFF_GRID, ISLAND_MODE_ON_GRID, LiveStatusMerge, OPERATION_MODES, PowerwallAuthenticationError, PowerwallClient, PowerwallCommandError, PowerwallConnectionError, PowerwallEnergySite, PowerwallError, PowerwallFaultError, PowerwallKeyRejectedError, PowerwallNotSupportedError, PowerwallProtocolError, PowerwallRateLimitError, SiteInfoMerge, backup_time_remaining, battery_level, battery_level_raw, battery_units, component, component_float, component_part_number, component_serial, component_signal, connect_gateway, current_power, parse_authorized_clients, pv_string_current, raw_to_scaled_reserve, raw_to_scaled_soc, scaled_to_raw_reserve, scaled_to_raw_soc, verify_local_gateway };