tesla-fleet-api 0.3.0 → 0.4.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 (192) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +22 -0
  2. package/dist/_virtual/_rolldown/runtime.mjs +12 -0
  3. package/dist/charging.cjs +53 -0
  4. package/dist/charging.d.cts +31 -0
  5. package/dist/charging.d.mts +30 -0
  6. package/dist/charging.mjs +53 -0
  7. package/dist/commands.cjs +802 -0
  8. package/dist/commands.d.cts +350 -0
  9. package/dist/commands.d.mts +349 -0
  10. package/dist/commands.mjs +800 -0
  11. package/dist/const.cjs +300 -0
  12. package/dist/const.d.cts +287 -0
  13. package/dist/const.d.mts +287 -0
  14. package/dist/const.mjs +263 -0
  15. package/dist/energy.cjs +137 -0
  16. package/dist/energy.d.cts +95 -0
  17. package/{src/energy.ts → dist/energy.d.mts} +17 -140
  18. package/dist/energy.mjs +137 -0
  19. package/dist/energyspecific.cjs +99 -0
  20. package/dist/energyspecific.d.cts +78 -0
  21. package/dist/energyspecific.d.mts +77 -0
  22. package/dist/energyspecific.mjs +99 -0
  23. package/dist/exceptions.cjs +1487 -0
  24. package/dist/exceptions.d.cts +1142 -0
  25. package/dist/exceptions.d.mts +1142 -0
  26. package/dist/exceptions.mjs +1324 -0
  27. package/dist/index.cjs +226 -0
  28. package/dist/index.d.cts +14 -0
  29. package/dist/index.d.mts +14 -0
  30. package/dist/index.mjs +14 -0
  31. package/dist/partner.cjs +32 -0
  32. package/dist/partner.d.cts +24 -0
  33. package/dist/partner.d.mts +23 -0
  34. package/dist/partner.mjs +32 -0
  35. package/dist/router.cjs +0 -0
  36. package/dist/router.d.cts +1 -0
  37. package/dist/router.d.mts +1 -0
  38. package/dist/router.mjs +1 -0
  39. package/dist/signing/crypto.cjs +31 -0
  40. package/dist/signing/crypto.mjs +27 -0
  41. package/dist/signing/session.cjs +112 -0
  42. package/dist/signing/session.d.cts +69 -0
  43. package/dist/signing/session.d.mts +69 -0
  44. package/dist/signing/session.mjs +110 -0
  45. package/dist/tariff.cjs +292 -0
  46. package/dist/{tariff.d.ts → tariff.d.cts} +17 -17
  47. package/dist/tariff.d.mts +29 -0
  48. package/dist/tariff.mjs +291 -0
  49. package/dist/teslafleetapi.cjs +125 -0
  50. package/dist/teslafleetapi.d.cts +64 -0
  51. package/dist/teslafleetapi.d.mts +64 -0
  52. package/dist/teslafleetapi.mjs +125 -0
  53. package/dist/teslemetry.cjs +36 -0
  54. package/dist/teslemetry.d.cts +23 -0
  55. package/dist/teslemetry.d.mts +23 -0
  56. package/dist/teslemetry.mjs +36 -0
  57. package/dist/tessie.cjs +34 -0
  58. package/dist/tessie.d.cts +23 -0
  59. package/dist/tessie.d.mts +23 -0
  60. package/dist/tessie.mjs +34 -0
  61. package/dist/types/commands.d.cts +28 -0
  62. package/dist/types/commands.d.mts +28 -0
  63. package/dist/types/live_status.d.cts +30 -0
  64. package/dist/types/live_status.d.mts +30 -0
  65. package/dist/types/products.d.cts +58 -0
  66. package/dist/types/products.d.mts +58 -0
  67. package/dist/types/responses.d.cts +9 -0
  68. package/dist/types/responses.d.mts +9 -0
  69. package/dist/types/site_info.d.cts +154 -0
  70. package/dist/types/site_info.d.mts +154 -0
  71. package/dist/types/vehicle.d.cts +27 -0
  72. package/dist/types/vehicle.d.mts +27 -0
  73. package/dist/types/vehicle_data.d.cts +278 -0
  74. package/dist/types/vehicle_data.d.mts +278 -0
  75. package/dist/types.cjs +0 -0
  76. package/dist/types.d.cts +9 -0
  77. package/dist/types.d.mts +9 -0
  78. package/dist/types.mjs +1 -0
  79. package/dist/user.cjs +28 -0
  80. package/dist/user.d.cts +17 -0
  81. package/dist/user.d.mts +16 -0
  82. package/dist/user.mjs +28 -0
  83. package/dist/vehicle.cjs +804 -0
  84. package/dist/vehicle.d.cts +550 -0
  85. package/dist/vehicle.d.mts +549 -0
  86. package/dist/vehicle.mjs +804 -0
  87. package/dist/vehiclesigned.cjs +20 -0
  88. package/dist/vehiclesigned.d.cts +14 -0
  89. package/dist/{vehiclesigned.d.ts → vehiclesigned.d.mts} +3 -3
  90. package/dist/vehiclesigned.mjs +20 -0
  91. package/dist/vehiclespecific.cjs +604 -0
  92. package/dist/vehiclespecific.d.cts +433 -0
  93. package/dist/vehiclespecific.d.mts +432 -0
  94. package/dist/vehiclespecific.mjs +604 -0
  95. package/package.json +108 -35
  96. package/dist/charging.d.ts +0 -30
  97. package/dist/charging.js +0 -51
  98. package/dist/charging.js.map +0 -1
  99. package/dist/commands.d.ts +0 -352
  100. package/dist/commands.js +0 -875
  101. package/dist/commands.js.map +0 -1
  102. package/dist/energy.d.ts +0 -94
  103. package/dist/energy.js +0 -125
  104. package/dist/energy.js.map +0 -1
  105. package/dist/energyspecific.d.ts +0 -77
  106. package/dist/energyspecific.js +0 -97
  107. package/dist/energyspecific.js.map +0 -1
  108. package/dist/helpers.d.ts +0 -2
  109. package/dist/helpers.js +0 -10
  110. package/dist/helpers.js.map +0 -1
  111. package/dist/index.d.ts +0 -15
  112. package/dist/index.js +0 -15
  113. package/dist/index.js.map +0 -1
  114. package/dist/partner.d.ts +0 -23
  115. package/dist/partner.js +0 -31
  116. package/dist/partner.js.map +0 -1
  117. package/dist/signing/crypto.d.ts +0 -10
  118. package/dist/signing/crypto.js +0 -26
  119. package/dist/signing/crypto.js.map +0 -1
  120. package/dist/signing/errors.d.ts +0 -29
  121. package/dist/signing/errors.js +0 -40
  122. package/dist/signing/errors.js.map +0 -1
  123. package/dist/signing/session.d.ts +0 -69
  124. package/dist/signing/session.js +0 -102
  125. package/dist/signing/session.js.map +0 -1
  126. package/dist/tariff.js +0 -302
  127. package/dist/tariff.js.map +0 -1
  128. package/dist/teslafleetapi.d.ts +0 -58
  129. package/dist/teslafleetapi.js +0 -120
  130. package/dist/teslafleetapi.js.map +0 -1
  131. package/dist/teslemetry.d.ts +0 -29
  132. package/dist/teslemetry.js +0 -39
  133. package/dist/teslemetry.js.map +0 -1
  134. package/dist/tessie.d.ts +0 -23
  135. package/dist/tessie.js +0 -28
  136. package/dist/tessie.js.map +0 -1
  137. package/dist/types/commands.d.ts +0 -44
  138. package/dist/types/commands.js +0 -11
  139. package/dist/types/commands.js.map +0 -1
  140. package/dist/types/live_status.d.ts +0 -26
  141. package/dist/types/live_status.js +0 -2
  142. package/dist/types/live_status.js.map +0 -1
  143. package/dist/types/products.d.ts +0 -54
  144. package/dist/types/products.js +0 -2
  145. package/dist/types/products.js.map +0 -1
  146. package/dist/types/responses.d.ts +0 -5
  147. package/dist/types/responses.js +0 -2
  148. package/dist/types/responses.js.map +0 -1
  149. package/dist/types/site_info.d.ts +0 -150
  150. package/dist/types/site_info.js +0 -2
  151. package/dist/types/site_info.js.map +0 -1
  152. package/dist/types/vehicle.d.ts +0 -23
  153. package/dist/types/vehicle.js +0 -10
  154. package/dist/types/vehicle.js.map +0 -1
  155. package/dist/types/vehicle_data.d.ts +0 -274
  156. package/dist/types/vehicle_data.js +0 -2
  157. package/dist/types/vehicle_data.js.map +0 -1
  158. package/dist/user.d.ts +0 -16
  159. package/dist/user.js +0 -26
  160. package/dist/user.js.map +0 -1
  161. package/dist/vehicle.d.ts +0 -548
  162. package/dist/vehicle.js +0 -774
  163. package/dist/vehicle.js.map +0 -1
  164. package/dist/vehiclesigned.js +0 -19
  165. package/dist/vehiclesigned.js.map +0 -1
  166. package/dist/vehiclespecific.d.ts +0 -432
  167. package/dist/vehiclespecific.js +0 -601
  168. package/dist/vehiclespecific.js.map +0 -1
  169. package/src/charging.ts +0 -66
  170. package/src/commands.ts +0 -1134
  171. package/src/energyspecific.ts +0 -116
  172. package/src/helpers.ts +0 -11
  173. package/src/index.ts +0 -21
  174. package/src/partner.ts +0 -37
  175. package/src/signing/crypto.ts +0 -29
  176. package/src/signing/errors.ts +0 -50
  177. package/src/signing/session.ts +0 -132
  178. package/src/tariff.ts +0 -375
  179. package/src/teslafleetapi.ts +0 -182
  180. package/src/teslemetry.ts +0 -54
  181. package/src/tessie.ts +0 -42
  182. package/src/types/commands.ts +0 -62
  183. package/src/types/live_status.ts +0 -27
  184. package/src/types/products.ts +0 -61
  185. package/src/types/responses.ts +0 -1
  186. package/src/types/site_info.ts +0 -159
  187. package/src/types/vehicle.ts +0 -33
  188. package/src/types/vehicle_data.ts +0 -286
  189. package/src/user.ts +0 -35
  190. package/src/vehicle.ts +0 -886
  191. package/src/vehiclesigned.ts +0 -20
  192. package/src/vehiclespecific.ts +0 -818
@@ -0,0 +1,95 @@
1
+ import EnergySpecific from "./energyspecific.cjs";
2
+ import TeslaFleetApi from "./teslafleetapi.cjs";
3
+ import { LiveStatusResponse } from "./types/live_status.cjs";
4
+ import { SiteInfoResponse } from "./types/site_info.cjs";
5
+ declare class Energy {
6
+ parent: TeslaFleetApi;
7
+ constructor(parent: TeslaFleetApi);
8
+ /**
9
+ * Create an Energy class for a specific site.
10
+ * @param energy_site_id ID field of an energy site from /api/1/products endpoint.
11
+ * @returns `EnergySpecific` class
12
+ */
13
+ specific(energy_site_id: number): EnergySpecific;
14
+ /**
15
+ * Adjust the site's backup reserve.
16
+ * @param energy_site_id ID field of an energy site from /api/1/products endpoint.ID field of an energy site from /api/1/products endpoint.
17
+ * @param backup_reserve_percent The desired backup reserve percent.
18
+ * @returns
19
+ */
20
+ backup(energy_site_id: number, backup_reserve_percent: number): Promise<Record<string, any>>;
21
+ /**
22
+ * Returns the backup (off-grid) event history of the site in duration of seconds.
23
+ * @param energy_site_id ID field of an energy site from /api/1/products endpoint.
24
+ * @param kind The kind of history to be requested. 'backup', 'charge', 'energy' are all supported.
25
+ * @param start_date Start date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
26
+ * @param end_date End date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
27
+ * @param period Period of the window to retrieve backup events. This can be day, week, month, year, lifetime and should align with the window requested.
28
+ * @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
29
+ * @returns
30
+ */
31
+ backup_history(energy_site_id: number, kind: string, start_date: string, end_date: string, period: string, time_zone: string): Promise<Record<string, any>>;
32
+ /**
33
+ * Returns the charging history of a wall connector.
34
+ * @param energy_site_id ID field of an energy site from /api/1/products endpoint.
35
+ * @param kind The kind of history to be requested. 'backup', 'charge', 'energy' are all supported.
36
+ * @param start_date Start date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
37
+ * @param end_date End date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
38
+ * @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
39
+ * @returns
40
+ */
41
+ charge_history(energy_site_id: number, kind: string, start_date: string, end_date: string, time_zone: string): Promise<Record<string, any>>;
42
+ /**
43
+ * Returns the energy measurements of the site, aggregated to the requested period.
44
+ * @param energy_site_id ID field of an energy site from /api/1/products endpoint.
45
+ * @param kind The kind of history to be requested. 'backup', 'charge', 'energy' are all supported.
46
+ * @param start_dateStart date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
47
+ * @param end_date End date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
48
+ * @param period Period of the window to retrieve backup events. This can be day, week, month, year, lifetime and should align with the window requested.
49
+ * @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
50
+ * @returns
51
+ */
52
+ energy_history(energy_site_id: number, kind: string, start_date: string, end_date: string, period: string, time_zone: string): Promise<Record<string, any>>;
53
+ /**
54
+ * Allow/disallow charging from the grid and exporting energy to the grid.
55
+ * @param energy_site_id
56
+ * @param disallow_charge_from_grid_with_solar_installed The desired behavior towards importing from the grid. Charging from the grid is disabled when set to true and enabled when set to false.
57
+ * @param customer_preferred_export_rule The desired behavior for grid exporting. The available options are battery_ok, pv_only, and never.
58
+ * @returns
59
+ */
60
+ grid_import_export(energy_site_id: number, disallow_charge_from_grid_with_solar_installed?: boolean | null, customer_preferred_export_rule?: string | null): Promise<Record<string, any>>;
61
+ /**
62
+ * Returns the live status of the site (power, state of energy, grid status, storm mode).
63
+ * @param energy_site_id
64
+ * @returns
65
+ */
66
+ live_status(energy_site_id: number): Promise<LiveStatusResponse>;
67
+ /**
68
+ * Adjust the site's off-grid vehicle charging backup reserve.
69
+ * @param energy_site_id ID field of an energy site from /api/1/products endpoint.
70
+ * @param off_grid_vehicle_charging_reserve_percent The desired off grid vehicle charging reserve percent.
71
+ * @returns
72
+ */
73
+ off_grid_vehicle_charging_reserve(energy_site_id: number, off_grid_vehicle_charging_reserve_percent: number): Promise<Record<string, any>>;
74
+ /**
75
+ * Set the site's mode.
76
+ * @param energy_site_id ID field of an energy site from /api/1/products endpoint.
77
+ * @param default_real_mode The desired operation mode. Use autonomous for time-based control and self_consumption for self-powered mode.
78
+ * @returns
79
+ */
80
+ operation(energy_site_id: number, default_real_mode: string): Promise<Record<string, any>>;
81
+ /**
82
+ * Returns information about the site. Things like assets (has solar, etc), settings (backup reserve, etc), and features (storm_mode_capable, etc).
83
+ * @param energy_site_id ID field of an energy site from /api/1/products endpoint.
84
+ * @returns
85
+ */
86
+ site_info(energy_site_id: number): Promise<SiteInfoResponse>;
87
+ /**
88
+ * Update storm watch participation.
89
+ * @param energy_site_id ID field of an energy site from /api/1/products endpoint.
90
+ * @param enabled The storm mode participation value to set.
91
+ * @returns
92
+ */
93
+ storm_mode(energy_site_id: number, enabled: boolean): Promise<Record<string, any>>;
94
+ }
95
+ export = Energy;
@@ -1,43 +1,23 @@
1
- import EnergySpecific from "./energyspecific.js";
2
- import TeslaFleetApi from "./teslafleetapi.js";
3
- import { LiveStatusResponse } from "./types/live_status.js";
4
- import { SiteInfoResponse } from "./types/site_info.js";
5
-
6
- // Energy Class
1
+ import EnergySpecific from "./energyspecific.mjs";
2
+ import TeslaFleetApi from "./teslafleetapi.mjs";
3
+ import { LiveStatusResponse } from "./types/live_status.mjs";
4
+ import { SiteInfoResponse } from "./types/site_info.mjs";
7
5
  export default class Energy {
8
6
  parent: TeslaFleetApi;
9
-
10
- constructor(parent: TeslaFleetApi) {
11
- this.parent = parent;
12
- }
13
-
7
+ constructor(parent: TeslaFleetApi);
14
8
  /**
15
9
  * Create an Energy class for a specific site.
16
10
  * @param energy_site_id ID field of an energy site from /api/1/products endpoint.
17
11
  * @returns `EnergySpecific` class
18
12
  */
19
- specific(energy_site_id: number): EnergySpecific {
20
- return new EnergySpecific(this, energy_site_id);
21
- }
22
-
13
+ specific(energy_site_id: number): EnergySpecific;
23
14
  /**
24
15
  * Adjust the site's backup reserve.
25
16
  * @param energy_site_id ID field of an energy site from /api/1/products endpoint.ID field of an energy site from /api/1/products endpoint.
26
17
  * @param backup_reserve_percent The desired backup reserve percent.
27
18
  * @returns
28
19
  */
29
- async backup(
30
- energy_site_id: number,
31
- backup_reserve_percent: number,
32
- ): Promise<Record<string, any>> {
33
- return this.parent._request(
34
- "POST",
35
- `api/1/energy_sites/${energy_site_id}/backup`,
36
- null,
37
- { backup_reserve_percent },
38
- );
39
- }
40
-
20
+ backup(energy_site_id: number, backup_reserve_percent: number): Promise<Record<string, any>>;
41
21
  /**
42
22
  * Returns the backup (off-grid) event history of the site in duration of seconds.
43
23
  * @param energy_site_id ID field of an energy site from /api/1/products endpoint.
@@ -48,22 +28,7 @@ export default class Energy {
48
28
  * @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
49
29
  * @returns
50
30
  */
51
- async backup_history(
52
- energy_site_id: number,
53
- kind: string,
54
- start_date: string,
55
- end_date: string,
56
- period: string,
57
- time_zone: string,
58
- ): Promise<Record<string, any>> {
59
- return this.parent._request(
60
- "GET",
61
- `api/1/energy_sites/${energy_site_id}/calendar_history`,
62
- null,
63
- { kind, start_date, end_date, period, time_zone },
64
- );
65
- }
66
-
31
+ backup_history(energy_site_id: number, kind: string, start_date: string, end_date: string, period: string, time_zone: string): Promise<Record<string, any>>;
67
32
  /**
68
33
  * Returns the charging history of a wall connector.
69
34
  * @param energy_site_id ID field of an energy site from /api/1/products endpoint.
@@ -73,21 +38,7 @@ export default class Energy {
73
38
  * @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
74
39
  * @returns
75
40
  */
76
- async charge_history(
77
- energy_site_id: number,
78
- kind: string,
79
- start_date: string,
80
- end_date: string,
81
- time_zone: string,
82
- ): Promise<Record<string, any>> {
83
- return this.parent._request(
84
- "GET",
85
- `api/1/energy_sites/${energy_site_id}/telemetry_history`,
86
- null,
87
- { kind, start_date, end_date, time_zone },
88
- );
89
- }
90
-
41
+ charge_history(energy_site_id: number, kind: string, start_date: string, end_date: string, time_zone: string): Promise<Record<string, any>>;
91
42
  /**
92
43
  * Returns the energy measurements of the site, aggregated to the requested period.
93
44
  * @param energy_site_id ID field of an energy site from /api/1/products endpoint.
@@ -98,22 +49,7 @@ export default class Energy {
98
49
  * @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
99
50
  * @returns
100
51
  */
101
- async energy_history(
102
- energy_site_id: number,
103
- kind: string,
104
- start_date: string,
105
- end_date: string,
106
- period: string,
107
- time_zone: string,
108
- ): Promise<Record<string, any>> {
109
- return this.parent._request(
110
- "GET",
111
- `api/1/energy_sites/${energy_site_id}/calendar_history`,
112
- null,
113
- { kind, start_date, end_date, period, time_zone },
114
- );
115
- }
116
-
52
+ energy_history(energy_site_id: number, kind: string, start_date: string, end_date: string, period: string, time_zone: string): Promise<Record<string, any>>;
117
53
  /**
118
54
  * Allow/disallow charging from the grid and exporting energy to the grid.
119
55
  * @param energy_site_id
@@ -121,97 +57,38 @@ export default class Energy {
121
57
  * @param customer_preferred_export_rule The desired behavior for grid exporting. The available options are battery_ok, pv_only, and never.
122
58
  * @returns
123
59
  */
124
- async grid_import_export(
125
- energy_site_id: number,
126
- disallow_charge_from_grid_with_solar_installed: boolean | null = null,
127
- customer_preferred_export_rule: string | null = null,
128
- ): Promise<Record<string, any>> {
129
- return this.parent._request(
130
- "POST",
131
- `api/1/energy_sites/${energy_site_id}/grid_import_export`,
132
- null,
133
- {
134
- disallow_charge_from_grid_with_solar_installed,
135
- customer_preferred_export_rule,
136
- },
137
- );
138
- }
139
-
60
+ grid_import_export(energy_site_id: number, disallow_charge_from_grid_with_solar_installed?: boolean | null, customer_preferred_export_rule?: string | null): Promise<Record<string, any>>;
140
61
  /**
141
62
  * Returns the live status of the site (power, state of energy, grid status, storm mode).
142
63
  * @param energy_site_id
143
64
  * @returns
144
65
  */
145
- async live_status(energy_site_id: number): Promise<LiveStatusResponse> {
146
- return this.parent
147
- ._request("GET", `api/1/energy_sites/${energy_site_id}/live_status`)
148
- .then(({ response }) => response);
149
- }
150
-
66
+ live_status(energy_site_id: number): Promise<LiveStatusResponse>;
151
67
  /**
152
68
  * Adjust the site's off-grid vehicle charging backup reserve.
153
69
  * @param energy_site_id ID field of an energy site from /api/1/products endpoint.
154
70
  * @param off_grid_vehicle_charging_reserve_percent The desired off grid vehicle charging reserve percent.
155
71
  * @returns
156
72
  */
157
- async off_grid_vehicle_charging_reserve(
158
- energy_site_id: number,
159
- off_grid_vehicle_charging_reserve_percent: number,
160
- ): Promise<Record<string, any>> {
161
- return this.parent._request(
162
- "POST",
163
- `api/1/energy_sites/${energy_site_id}/off_grid_vehicle_charging_reserve`,
164
- null,
165
- {
166
- off_grid_vehicle_charging_reserve_percent,
167
- },
168
- );
169
- }
170
-
73
+ off_grid_vehicle_charging_reserve(energy_site_id: number, off_grid_vehicle_charging_reserve_percent: number): Promise<Record<string, any>>;
171
74
  /**
172
75
  * Set the site's mode.
173
76
  * @param energy_site_id ID field of an energy site from /api/1/products endpoint.
174
77
  * @param default_real_mode The desired operation mode. Use autonomous for time-based control and self_consumption for self-powered mode.
175
78
  * @returns
176
79
  */
177
- async operation(
178
- energy_site_id: number,
179
- default_real_mode: string,
180
- ): Promise<Record<string, any>> {
181
- return this.parent._request(
182
- "POST",
183
- `api/1/energy_sites/${energy_site_id}/operation`,
184
- null,
185
- { default_real_mode },
186
- );
187
- }
188
-
80
+ operation(energy_site_id: number, default_real_mode: string): Promise<Record<string, any>>;
189
81
  /**
190
82
  * Returns information about the site. Things like assets (has solar, etc), settings (backup reserve, etc), and features (storm_mode_capable, etc).
191
83
  * @param energy_site_id ID field of an energy site from /api/1/products endpoint.
192
84
  * @returns
193
85
  */
194
- async site_info(energy_site_id: number): Promise<SiteInfoResponse> {
195
- return this.parent
196
- ._request("GET", `api/1/energy_sites/${energy_site_id}/site_info`)
197
- .then(({ response }) => response);
198
- }
199
-
86
+ site_info(energy_site_id: number): Promise<SiteInfoResponse>;
200
87
  /**
201
88
  * Update storm watch participation.
202
89
  * @param energy_site_id ID field of an energy site from /api/1/products endpoint.
203
90
  * @param enabled The storm mode participation value to set.
204
91
  * @returns
205
92
  */
206
- async storm_mode(
207
- energy_site_id: number,
208
- enabled: boolean,
209
- ): Promise<Record<string, any>> {
210
- return this.parent._request(
211
- "POST",
212
- `api/1/energy_sites/${energy_site_id}/storm_mode`,
213
- null,
214
- { enabled },
215
- );
216
- }
217
- }
93
+ storm_mode(energy_site_id: number, enabled: boolean): Promise<Record<string, any>>;
94
+ }
@@ -0,0 +1,137 @@
1
+ import EnergySpecific from "./energyspecific.mjs";
2
+ // src/energy.ts
3
+ var Energy = class {
4
+ parent;
5
+ constructor(parent) {
6
+ this.parent = parent;
7
+ }
8
+ /**
9
+ * Create an Energy class for a specific site.
10
+ * @param energy_site_id ID field of an energy site from /api/1/products endpoint.
11
+ * @returns `EnergySpecific` class
12
+ */
13
+ specific(energy_site_id) {
14
+ return new EnergySpecific(this, energy_site_id);
15
+ }
16
+ /**
17
+ * Adjust the site's backup reserve.
18
+ * @param energy_site_id ID field of an energy site from /api/1/products endpoint.ID field of an energy site from /api/1/products endpoint.
19
+ * @param backup_reserve_percent The desired backup reserve percent.
20
+ * @returns
21
+ */
22
+ async backup(energy_site_id, backup_reserve_percent) {
23
+ return this.parent._request("POST", `api/1/energy_sites/${energy_site_id}/backup`, null, { backup_reserve_percent });
24
+ }
25
+ /**
26
+ * Returns the backup (off-grid) event history of the site in duration of seconds.
27
+ * @param energy_site_id ID field of an energy site from /api/1/products endpoint.
28
+ * @param kind The kind of history to be requested. 'backup', 'charge', 'energy' are all supported.
29
+ * @param start_date Start date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
30
+ * @param end_date End date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
31
+ * @param period Period of the window to retrieve backup events. This can be day, week, month, year, lifetime and should align with the window requested.
32
+ * @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
33
+ * @returns
34
+ */
35
+ async backup_history(energy_site_id, kind, start_date, end_date, period, time_zone) {
36
+ return this.parent._request("GET", `api/1/energy_sites/${energy_site_id}/calendar_history`, {
37
+ kind,
38
+ start_date,
39
+ end_date,
40
+ period,
41
+ time_zone
42
+ });
43
+ }
44
+ /**
45
+ * Returns the charging history of a wall connector.
46
+ * @param energy_site_id ID field of an energy site from /api/1/products endpoint.
47
+ * @param kind The kind of history to be requested. 'backup', 'charge', 'energy' are all supported.
48
+ * @param start_date Start date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
49
+ * @param end_date End date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
50
+ * @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
51
+ * @returns
52
+ */
53
+ async charge_history(energy_site_id, kind, start_date, end_date, time_zone) {
54
+ return this.parent._request("GET", `api/1/energy_sites/${energy_site_id}/telemetry_history`, {
55
+ kind,
56
+ start_date,
57
+ end_date,
58
+ time_zone
59
+ });
60
+ }
61
+ /**
62
+ * Returns the energy measurements of the site, aggregated to the requested period.
63
+ * @param energy_site_id ID field of an energy site from /api/1/products endpoint.
64
+ * @param kind The kind of history to be requested. 'backup', 'charge', 'energy' are all supported.
65
+ * @param start_dateStart date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
66
+ * @param end_date End date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
67
+ * @param period Period of the window to retrieve backup events. This can be day, week, month, year, lifetime and should align with the window requested.
68
+ * @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
69
+ * @returns
70
+ */
71
+ async energy_history(energy_site_id, kind, start_date, end_date, period, time_zone) {
72
+ return this.parent._request("GET", `api/1/energy_sites/${energy_site_id}/calendar_history`, {
73
+ kind,
74
+ start_date,
75
+ end_date,
76
+ period,
77
+ time_zone
78
+ });
79
+ }
80
+ /**
81
+ * Allow/disallow charging from the grid and exporting energy to the grid.
82
+ * @param energy_site_id
83
+ * @param disallow_charge_from_grid_with_solar_installed The desired behavior towards importing from the grid. Charging from the grid is disabled when set to true and enabled when set to false.
84
+ * @param customer_preferred_export_rule The desired behavior for grid exporting. The available options are battery_ok, pv_only, and never.
85
+ * @returns
86
+ */
87
+ async grid_import_export(energy_site_id, disallow_charge_from_grid_with_solar_installed = null, customer_preferred_export_rule = null) {
88
+ return this.parent._request("POST", `api/1/energy_sites/${energy_site_id}/grid_import_export`, null, {
89
+ disallow_charge_from_grid_with_solar_installed,
90
+ customer_preferred_export_rule
91
+ });
92
+ }
93
+ /**
94
+ * Returns the live status of the site (power, state of energy, grid status, storm mode).
95
+ * @param energy_site_id
96
+ * @returns
97
+ */
98
+ async live_status(energy_site_id) {
99
+ return this.parent._request("GET", `api/1/energy_sites/${energy_site_id}/live_status`).then(({ response }) => response);
100
+ }
101
+ /**
102
+ * Adjust the site's off-grid vehicle charging backup reserve.
103
+ * @param energy_site_id ID field of an energy site from /api/1/products endpoint.
104
+ * @param off_grid_vehicle_charging_reserve_percent The desired off grid vehicle charging reserve percent.
105
+ * @returns
106
+ */
107
+ async off_grid_vehicle_charging_reserve(energy_site_id, off_grid_vehicle_charging_reserve_percent) {
108
+ return this.parent._request("POST", `api/1/energy_sites/${energy_site_id}/off_grid_vehicle_charging_reserve`, null, { off_grid_vehicle_charging_reserve_percent });
109
+ }
110
+ /**
111
+ * Set the site's mode.
112
+ * @param energy_site_id ID field of an energy site from /api/1/products endpoint.
113
+ * @param default_real_mode The desired operation mode. Use autonomous for time-based control and self_consumption for self-powered mode.
114
+ * @returns
115
+ */
116
+ async operation(energy_site_id, default_real_mode) {
117
+ return this.parent._request("POST", `api/1/energy_sites/${energy_site_id}/operation`, null, { default_real_mode });
118
+ }
119
+ /**
120
+ * Returns information about the site. Things like assets (has solar, etc), settings (backup reserve, etc), and features (storm_mode_capable, etc).
121
+ * @param energy_site_id ID field of an energy site from /api/1/products endpoint.
122
+ * @returns
123
+ */
124
+ async site_info(energy_site_id) {
125
+ return this.parent._request("GET", `api/1/energy_sites/${energy_site_id}/site_info`).then(({ response }) => response);
126
+ }
127
+ /**
128
+ * Update storm watch participation.
129
+ * @param energy_site_id ID field of an energy site from /api/1/products endpoint.
130
+ * @param enabled The storm mode participation value to set.
131
+ * @returns
132
+ */
133
+ async storm_mode(energy_site_id, enabled) {
134
+ return this.parent._request("POST", `api/1/energy_sites/${energy_site_id}/storm_mode`, null, { enabled });
135
+ }
136
+ };
137
+ export { Energy as default };
@@ -0,0 +1,99 @@
1
+ // src/energyspecific.ts
2
+ var EnergySpecific = class {
3
+ parent;
4
+ energy_site_id;
5
+ constructor(parent, energy_site_id) {
6
+ this.parent = parent;
7
+ this.energy_site_id = energy_site_id;
8
+ }
9
+ /**
10
+ * Adjust the site's backup reserve.
11
+ * @param backup_reserve_percent The desired backup reserve percent.
12
+ * @returns
13
+ */
14
+ async backup(backup_reserve_percent) {
15
+ return this.parent.backup(this.energy_site_id, backup_reserve_percent);
16
+ }
17
+ /**
18
+ * Returns the backup (off-grid) event history of the site in duration of seconds.
19
+ * @param kind The kind of history to be requested. 'backup', 'charge', 'energy' are all supported.
20
+ * @param start_date Start date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
21
+ * @param end_date End date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
22
+ * @param period Period of the window to retrieve backup events. This can be day, week, month, year, lifetime and should align with the window requested.
23
+ * @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
24
+ * @returns
25
+ */
26
+ async backup_history(kind, start_date, end_date, period, time_zone) {
27
+ return this.parent.backup_history(this.energy_site_id, kind, start_date, end_date, period, time_zone);
28
+ }
29
+ /**
30
+ * Returns the charging history of a wall connector.
31
+ * @param kind The kind of history to be requested. 'backup', 'charge', 'energy' are all supported.
32
+ * @param start_date Start date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
33
+ * @param end_date End date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
34
+ * @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
35
+ * @returns
36
+ */
37
+ async charge_history(kind, start_date, end_date, time_zone) {
38
+ return this.parent.charge_history(this.energy_site_id, kind, start_date, end_date, time_zone);
39
+ }
40
+ /**
41
+ * Returns the energy history of the site in duration of seconds.
42
+ * @param kind The kind of history to be requested. 'backup', 'charge', 'energy' are all supported.
43
+ * @param start_date Start date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
44
+ * @param end_date End date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
45
+ * @param period Period of the window to retrieve backup events. This can be day, week, month, year, lifetime and should align with the window requested.
46
+ * @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
47
+ * @returns
48
+ */
49
+ async energy_history(kind, start_date, end_date, period, time_zone) {
50
+ return this.parent.energy_history(this.energy_site_id, kind, start_date, end_date, period, time_zone);
51
+ }
52
+ /**
53
+ * Allow/disallow charging from the grid and exporting energy to the grid.
54
+ * @param disallow_charge_from_grid_with_solar_installed The desired behavior towards importing from the grid. Charging from the grid is disabled when set to true and enabled when set to false.
55
+ * @param customer_preferred_export_rule The desired behavior for grid exporting. The available options are battery_ok, pv_only, and never.
56
+ * @returns
57
+ */
58
+ async grid_import_export(disallow_charge_from_grid_with_solar_installed = null, customer_preferred_export_rule = null) {
59
+ return this.parent.grid_import_export(this.energy_site_id, disallow_charge_from_grid_with_solar_installed, customer_preferred_export_rule);
60
+ }
61
+ /**
62
+ * Returns the live status of the site.
63
+ * @returns
64
+ */
65
+ async live_status() {
66
+ return this.parent.live_status(this.energy_site_id);
67
+ }
68
+ /**
69
+ * Adjust the site's off-grid vehicle charging backup reserve.
70
+ * @param off_grid_vehicle_charging_reserve_percent The desired off grid vehicle charging reserve percent.
71
+ * @returns
72
+ */
73
+ async off_grid_vehicle_charging_reserve(off_grid_vehicle_charging_reserve_percent) {
74
+ return this.parent.off_grid_vehicle_charging_reserve(this.energy_site_id, off_grid_vehicle_charging_reserve_percent);
75
+ }
76
+ /**
77
+ * Set the site's mode.
78
+ * @param default_real_mode
79
+ * @returns
80
+ */
81
+ async operation(default_real_mode) {
82
+ return this.parent.operation(this.energy_site_id, default_real_mode);
83
+ }
84
+ /**
85
+ * Returns information about the site. Things like assets (has solar, etc), settings (backup reserve, etc), and features (storm_mode_capable, etc).
86
+ */
87
+ async site_info() {
88
+ return this.parent.site_info(this.energy_site_id);
89
+ }
90
+ /**
91
+ * Update storm watch participation.
92
+ * @param enabled The storm mode participation value to set.
93
+ * @returns
94
+ */
95
+ async storm_mode(enabled) {
96
+ return this.parent.storm_mode(this.energy_site_id, enabled);
97
+ }
98
+ };
99
+ exports.default = EnergySpecific;
@@ -0,0 +1,78 @@
1
+ import Energy from "./energy.cjs";
2
+ import { LiveStatusResponse } from "./types/live_status.cjs";
3
+ import { SiteInfoResponse } from "./types/site_info.cjs";
4
+ declare class EnergySpecific {
5
+ parent: Energy;
6
+ energy_site_id: number;
7
+ constructor(parent: Energy, energy_site_id: number);
8
+ /**
9
+ * Adjust the site's backup reserve.
10
+ * @param backup_reserve_percent The desired backup reserve percent.
11
+ * @returns
12
+ */
13
+ backup(backup_reserve_percent: number): Promise<Record<string, any>>;
14
+ /**
15
+ * Returns the backup (off-grid) event history of the site in duration of seconds.
16
+ * @param kind The kind of history to be requested. 'backup', 'charge', 'energy' are all supported.
17
+ * @param start_date Start date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
18
+ * @param end_date End date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
19
+ * @param period Period of the window to retrieve backup events. This can be day, week, month, year, lifetime and should align with the window requested.
20
+ * @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
21
+ * @returns
22
+ */
23
+ backup_history(kind: string, start_date: string, end_date: string, period: string, time_zone: string): Promise<Record<string, any>>;
24
+ /**
25
+ * Returns the charging history of a wall connector.
26
+ * @param kind The kind of history to be requested. 'backup', 'charge', 'energy' are all supported.
27
+ * @param start_date Start date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
28
+ * @param end_date End date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
29
+ * @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
30
+ * @returns
31
+ */
32
+ charge_history(kind: string, start_date: string, end_date: string, time_zone: string): Promise<Record<string, any>>;
33
+ /**
34
+ * Returns the energy history of the site in duration of seconds.
35
+ * @param kind The kind of history to be requested. 'backup', 'charge', 'energy' are all supported.
36
+ * @param start_date Start date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
37
+ * @param end_date End date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
38
+ * @param period Period of the window to retrieve backup events. This can be day, week, month, year, lifetime and should align with the window requested.
39
+ * @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
40
+ * @returns
41
+ */
42
+ energy_history(kind: string, start_date: string, end_date: string, period: string, time_zone: string): Promise<Record<string, any>>;
43
+ /**
44
+ * Allow/disallow charging from the grid and exporting energy to the grid.
45
+ * @param disallow_charge_from_grid_with_solar_installed The desired behavior towards importing from the grid. Charging from the grid is disabled when set to true and enabled when set to false.
46
+ * @param customer_preferred_export_rule The desired behavior for grid exporting. The available options are battery_ok, pv_only, and never.
47
+ * @returns
48
+ */
49
+ grid_import_export(disallow_charge_from_grid_with_solar_installed?: boolean | null, customer_preferred_export_rule?: string | null): Promise<Record<string, any>>;
50
+ /**
51
+ * Returns the live status of the site.
52
+ * @returns
53
+ */
54
+ live_status(): Promise<LiveStatusResponse>;
55
+ /**
56
+ * Adjust the site's off-grid vehicle charging backup reserve.
57
+ * @param off_grid_vehicle_charging_reserve_percent The desired off grid vehicle charging reserve percent.
58
+ * @returns
59
+ */
60
+ off_grid_vehicle_charging_reserve(off_grid_vehicle_charging_reserve_percent: number): Promise<Record<string, any>>;
61
+ /**
62
+ * Set the site's mode.
63
+ * @param default_real_mode
64
+ * @returns
65
+ */
66
+ operation(default_real_mode: string): Promise<Record<string, any>>;
67
+ /**
68
+ * Returns information about the site. Things like assets (has solar, etc), settings (backup reserve, etc), and features (storm_mode_capable, etc).
69
+ */
70
+ site_info(): Promise<SiteInfoResponse>;
71
+ /**
72
+ * Update storm watch participation.
73
+ * @param enabled The storm mode participation value to set.
74
+ * @returns
75
+ */
76
+ storm_mode(enabled: boolean): Promise<Record<string, any>>;
77
+ }
78
+ export = EnergySpecific;