@teslemetry/api 0.6.12 → 0.6.13

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.
package/dist/index.cjs CHANGED
@@ -3060,19 +3060,20 @@ var TeslemetryVehicleStream = class extends events.EventEmitter {
3060
3060
  this._fieldUpdateBatch = null;
3061
3061
  try {
3062
3062
  const data = await this.patchConfig(batch.fields);
3063
- if (data?.updated_vehicles) {
3064
- this.logger.info(`Updated ${Object.keys(batch.fields).length} streaming fields for ${this.vin}`);
3065
- this.fields = {
3066
- ...this.fields,
3067
- ...batch.fields
3068
- };
3069
- batch.deferred.resolve();
3063
+ if (data?.updated_vehicles === void 0) throw new Error(`Error updating streaming config for ${this.vin}`);
3064
+ this.fields = {
3065
+ ...this.fields,
3066
+ ...batch.fields
3067
+ };
3068
+ if (data.updated_vehicles === 0) {
3069
+ this.logger.debug(`No update required for ${this.vin}`);
3070
+ batch.deferred.resolve(false);
3070
3071
  } else {
3071
- const error = /* @__PURE__ */ new Error(`Error updating streaming config for ${this.vin}`);
3072
- this.logger.error(error.message, data);
3073
- batch.deferred.reject(error);
3072
+ this.logger.info(`Updated ${Object.keys(batch.fields).length} streaming fields for ${this.vin}`);
3073
+ batch.deferred.resolve(true);
3074
3074
  }
3075
3075
  } catch (error) {
3076
+ this.logger.error(error.message);
3076
3077
  batch.deferred.reject(error);
3077
3078
  }
3078
3079
  }
@@ -3098,12 +3099,12 @@ var TeslemetryVehicleStream = class extends events.EventEmitter {
3098
3099
  * Add a field to the vehicles streaming configuration
3099
3100
  * @param field Vehicle Signal
3100
3101
  * @param interval
3101
- * @returns Promise that resolves when the field is added
3102
+ * @returns Promise that resolves to whether the field configuration changed
3102
3103
  */
3103
3104
  addField(field, interval) {
3104
3105
  if (this.fields && this.fields[field] && (interval === void 0 || this.fields[field].interval_seconds === interval)) {
3105
3106
  this.logger.debug(`Streaming field ${field} already enabled @ ${this.fields[field]?.interval_seconds || "default"}s`);
3106
- return Promise.resolve();
3107
+ return Promise.resolve(false);
3107
3108
  }
3108
3109
  const value = interval !== void 0 ? { interval_seconds: interval } : null;
3109
3110
  return this.updateFields({ [field]: value });
@@ -3647,7 +3648,7 @@ var TeslemetryEnergyApi = class extends events.EventEmitter {
3647
3648
  * Returns the charging history of a wall connector.
3648
3649
  * @param start_date Start date for the telemetry data (string, Date, or undefined - defaults to start of today)
3649
3650
  * @param end_date End date for the telemetry data (string, Date, or undefined - defaults to end of today)
3650
- * @param time_zone Optional timezone for the data
3651
+ * @param time_zone IANA timezone for the data (e.g., 'America/Los_Angeles') - defaults to local timezone
3651
3652
  * @return Promise to an object with response containing charging history data from wall connectors
3652
3653
  */
3653
3654
  async getTelemetryHistory(start_date, end_date, time_zone) {
@@ -3655,7 +3656,7 @@ var TeslemetryEnergyApi = class extends events.EventEmitter {
3655
3656
  query: {
3656
3657
  kind: "charge",
3657
3658
  ...processDateRange(start_date ?? getStartOfToday(), end_date ?? getEndOfToday()),
3658
- time_zone
3659
+ time_zone: time_zone ?? Intl.DateTimeFormat().resolvedOptions().timeZone
3659
3660
  },
3660
3661
  path: { id: this.siteId },
3661
3662
  client: this.root.client
@@ -5261,7 +5262,7 @@ const consoleLogger = {
5261
5262
 
5262
5263
  //#endregion
5263
5264
  //#region package.json
5264
- var version = "0.6.12";
5265
+ var version = "0.6.13";
5265
5266
 
5266
5267
  //#endregion
5267
5268
  //#region src/Teslemetry.ts
package/dist/index.d.cts CHANGED
@@ -3794,7 +3794,12 @@ type PatchApiConfigByVinData = {
3794
3794
  */
3795
3795
  vin: string;
3796
3796
  };
3797
- query?: never;
3797
+ query?: {
3798
+ /**
3799
+ * Use minimum values instead of defaults. 'true' applies minimums to new fields only, 'force' overrides all fields with minimum values.
3800
+ */
3801
+ min?: 'true' | 'force';
3802
+ };
3798
3803
  url: '/api/config/{vin}';
3799
3804
  };
3800
3805
  type PostApiConfigByVinData = {
@@ -5618,7 +5623,12 @@ type PostApiConfigByVinData = {
5618
5623
  */
5619
5624
  vin: string;
5620
5625
  };
5621
- query?: never;
5626
+ query?: {
5627
+ /**
5628
+ * Use minimum values instead of defaults. 'true' applies minimums to new fields only, 'force' overrides all fields with minimum values.
5629
+ */
5630
+ min?: 'true' | 'force';
5631
+ };
5622
5632
  url: '/api/config/{vin}';
5623
5633
  };
5624
5634
  type GetApi1VehiclesByVinVehicleDataResponses = {
@@ -8037,32 +8047,107 @@ type GetApi1EnergySitesByIdLiveStatusResponses = {
8037
8047
  */
8038
8048
  200: {
8039
8049
  response: {
8050
+ /**
8051
+ * Power currently being generated by solar panels in watts. Always zero or positive.
8052
+ */
8040
8053
  solar_power?: number;
8054
+ /**
8055
+ * Powerwall battery state of charge as a percentage (0-100).
8056
+ */
8041
8057
  percentage_charged?: number;
8058
+ /**
8059
+ * Power flowing to/from the Powerwall battery in watts. Positive = discharging (powering home/grid), negative = charging.
8060
+ */
8042
8061
  battery_power?: number;
8062
+ /**
8063
+ * Total power consumption of the home in watts. Always zero or positive.
8064
+ */
8043
8065
  load_power?: number;
8066
+ /**
8067
+ * Current status of the utility grid connection.
8068
+ */
8044
8069
  grid_status?: 'Active' | 'Inactive' | 'Unknown';
8070
+ /**
8071
+ * Power flowing to/from the utility grid in watts. Positive = importing (buying from grid), negative = exporting (selling to grid).
8072
+ */
8045
8073
  grid_power?: number;
8074
+ /**
8075
+ * Power from a backup generator in watts, if present. Always zero or positive.
8076
+ */
8046
8077
  generator_power?: number;
8078
+ /**
8079
+ * Array of Tesla Wall Connectors at the energy site.
8080
+ */
8047
8081
  wall_connectors?: Array<{
8082
+ /**
8083
+ * Device Identification Number, a unique identifier for the Wall Connector.
8084
+ */
8048
8085
  din: string;
8086
+ /**
8087
+ * Vehicle Identification Number of the connected vehicle, if any.
8088
+ */
8049
8089
  vin?: string;
8090
+ /**
8091
+ * Operational state: 1 = charging, 2 = not plugged in, 3 = plugged in (not charging), 4 = plugged in (paused).
8092
+ */
8050
8093
  wall_connector_state: number;
8094
+ /**
8095
+ * Fault condition code. 0 indicates no fault.
8096
+ */
8051
8097
  wall_connector_fault_state?: number;
8098
+ /**
8099
+ * Power being delivered to the vehicle in watts.
8100
+ */
8052
8101
  wall_connector_power: number;
8102
+ /**
8103
+ * Open Charge Point Protocol status code.
8104
+ */
8053
8105
  ocpp_status?: number;
8106
+ /**
8107
+ * Powershare (vehicle-to-home) session state code.
8108
+ */
8054
8109
  powershare_session_state?: number;
8055
8110
  }>;
8111
+ /**
8112
+ * Whether the site is islanded (operating independently from the grid). off_grid_intentional = user-initiated (e.g., Go Off-Grid test), off_grid_unintentional = grid outage.
8113
+ */
8056
8114
  island_status?: 'on_grid' | 'island_status_unknown' | 'off_grid_intentional' | 'off_grid_unintentional';
8115
+ /**
8116
+ * Whether Storm Watch is currently active, charging the battery to 100% in preparation for a potential outage.
8117
+ */
8057
8118
  storm_mode_active?: boolean;
8119
+ /**
8120
+ * ISO 8601 timestamp when this data was captured.
8121
+ */
8058
8122
  timestamp: string;
8123
+ /**
8124
+ * Active Storm Watch events with timing and storm type information.
8125
+ */
8059
8126
  storm_mode_states?: Array<{
8127
+ /**
8128
+ * Unique identifier for the storm watch event.
8129
+ */
8060
8130
  watch_event_id: string;
8131
+ /**
8132
+ * ISO 8601 timestamp when the storm watch begins.
8133
+ */
8061
8134
  start_time: string;
8135
+ /**
8136
+ * ISO 8601 timestamp when the storm watch ends.
8137
+ */
8062
8138
  end_time: string;
8139
+ /**
8140
+ * Type of storm (e.g., winter storm, hurricane, thunderstorm).
8141
+ */
8063
8142
  storm_type: string;
8143
+ /**
8144
+ * Whether the user has opted out of this storm watch event.
8145
+ */
8064
8146
  opted_out?: boolean;
8065
8147
  }>;
8148
+ /**
8149
+ * Whether the battery breaker is open, meaning the Powerwall is electrically disconnected from the system.
8150
+ */
8066
8151
  battery_breaker_open?: boolean;
8067
8152
  };
8068
8153
  };
@@ -8074,44 +8159,158 @@ type GetApi1EnergySitesByIdSiteInfoResponses = {
8074
8159
  */
8075
8160
  200: {
8076
8161
  response: {
8162
+ /**
8163
+ * Unique identifier for the energy site.
8164
+ */
8077
8165
  id: string;
8166
+ /**
8167
+ * User-defined name for the energy site.
8168
+ */
8078
8169
  site_name?: string;
8170
+ /**
8171
+ * Minimum battery level (0-80% or 100%) to reserve for backup power during grid outages.
8172
+ */
8079
8173
  backup_reserve_percent?: number;
8174
+ /**
8175
+ * Operating mode: 'autonomous' (time-based control), 'self_consumption' (self-powered), or 'backup' (backup only).
8176
+ */
8080
8177
  default_real_mode?: string;
8178
+ /**
8179
+ * Date when the energy system was installed, in ISO 8601 format.
8180
+ */
8081
8181
  installation_date: string;
8182
+ /**
8183
+ * User-configurable settings for the energy site.
8184
+ */
8082
8185
  user_settings: {
8186
+ /**
8187
+ * Whether the Go Off-Grid test banner is shown in the app.
8188
+ */
8083
8189
  go_off_grid_test_banner_enabled: null | boolean;
8190
+ /**
8191
+ * Whether Storm Watch is enabled to automatically charge battery before severe weather.
8192
+ */
8084
8193
  storm_mode_enabled: null | boolean;
8194
+ /**
8195
+ * Whether the user has completed Powerwall onboarding setup.
8196
+ */
8085
8197
  powerwall_onboarding_settings_set: null | boolean;
8198
+ /**
8199
+ * Whether the user has expressed interest in Tesla Electric utility service.
8200
+ */
8086
8201
  powerwall_tesla_electric_interested_in: null | boolean;
8202
+ /**
8203
+ * Whether the Virtual Power Plant tour/introduction is enabled.
8204
+ */
8087
8205
  vpp_tour_enabled: null | boolean;
8206
+ /**
8207
+ * Whether vehicle charging is allowed when the site is off-grid (islanded).
8208
+ */
8088
8209
  off_grid_vehicle_charging_enabled: null | boolean;
8089
8210
  };
8211
+ /**
8212
+ * Hardware components and feature capabilities of the energy site.
8213
+ */
8090
8214
  components: {
8215
+ /**
8216
+ * Whether solar panels are installed at the site.
8217
+ */
8091
8218
  solar: boolean;
8219
+ /**
8220
+ * Type of solar installation (e.g., 'pv_panel', 'roof').
8221
+ */
8092
8222
  solar_type?: string;
8223
+ /**
8224
+ * Whether a Powerwall battery is installed at the site.
8225
+ */
8093
8226
  battery: boolean;
8227
+ /**
8228
+ * Whether the site has a grid connection.
8229
+ */
8094
8230
  grid: boolean;
8231
+ /**
8232
+ * Whether backup power functionality is available.
8233
+ */
8095
8234
  backup: boolean;
8235
+ /**
8236
+ * Type of Tesla gateway device (e.g., 'teg' for Tesla Energy Gateway).
8237
+ */
8096
8238
  gateway: string;
8239
+ /**
8240
+ * Whether a load meter is installed to measure home consumption.
8241
+ */
8097
8242
  load_meter: boolean;
8243
+ /**
8244
+ * Whether the system supports Time-of-Use rate optimization.
8245
+ */
8098
8246
  tou_capable: boolean;
8247
+ /**
8248
+ * Whether Storm Watch functionality is available.
8249
+ */
8099
8250
  storm_mode_capable: boolean;
8251
+ /**
8252
+ * Whether the system supports reserving battery capacity for vehicle charging during off-grid operation.
8253
+ */
8100
8254
  off_grid_vehicle_charging_reserve_supported: boolean;
8255
+ /**
8256
+ * Whether vehicle charging performance metrics are available in the app.
8257
+ */
8101
8258
  vehicle_charging_performance_view_enabled: boolean;
8259
+ /**
8260
+ * Whether solar offset metrics for vehicle charging are available in the app.
8261
+ */
8102
8262
  vehicle_charging_solar_offset_view_enabled: boolean;
8263
+ /**
8264
+ * Whether solar offset metrics for battery charging are available in the app.
8265
+ */
8103
8266
  battery_solar_offset_view_enabled: boolean;
8267
+ /**
8268
+ * Whether solar value calculations are enabled.
8269
+ */
8104
8270
  solar_value_enabled?: boolean;
8271
+ /**
8272
+ * Header text displayed for energy value in the app.
8273
+ */
8105
8274
  energy_value_header?: string;
8275
+ /**
8276
+ * Subheader text displayed for energy value in the app.
8277
+ */
8106
8278
  energy_value_subheader?: string;
8279
+ /**
8280
+ * Whether the system can self-schedule for grid services events.
8281
+ */
8107
8282
  energy_service_self_scheduling_enabled: boolean;
8283
+ /**
8284
+ * Whether to display the battery state of energy graph in the app.
8285
+ */
8108
8286
  show_battery_soe_graph?: boolean;
8287
+ /**
8288
+ * Whether to show grid import and battery source cards in the app.
8289
+ */
8109
8290
  show_grid_import_battery_source_cards?: boolean;
8291
+ /**
8292
+ * Whether the user can manually trigger off-grid (island) mode.
8293
+ */
8110
8294
  set_islanding_mode_enabled?: boolean;
8295
+ /**
8296
+ * Whether WiFi commissioning is enabled for the gateway.
8297
+ */
8111
8298
  wifi_commissioning_enabled?: boolean;
8299
+ /**
8300
+ * Whether backup time remaining estimates are available.
8301
+ */
8112
8302
  backup_time_remaining_enabled?: boolean;
8303
+ /**
8304
+ * Type of battery installed (e.g., 'ac_powerwall' for Powerwall 2/+, 'dc_powerwall' for Powerwall 3).
8305
+ */
8113
8306
  battery_type?: string;
8307
+ /**
8308
+ * Whether the system settings can be modified via the API.
8309
+ */
8114
8310
  configurable?: boolean;
8311
+ /**
8312
+ * Whether the site is enrolled in grid services (Virtual Power Plant).
8313
+ */
8115
8314
  grid_services_enabled?: boolean;
8116
8315
  gateways?: Array<{
8117
8316
  device_id: string;
@@ -10599,7 +10798,7 @@ declare class TeslemetryEnergyApi extends EventEmitter {
10599
10798
  * Returns the charging history of a wall connector.
10600
10799
  * @param start_date Start date for the telemetry data (string, Date, or undefined - defaults to start of today)
10601
10800
  * @param end_date End date for the telemetry data (string, Date, or undefined - defaults to end of today)
10602
- * @param time_zone Optional timezone for the data
10801
+ * @param time_zone IANA timezone for the data (e.g., 'America/Los_Angeles') - defaults to local timezone
10603
10802
  * @return Promise to an object with response containing charging history data from wall connectors
10604
10803
  */
10605
10804
  getTelemetryHistory(start_date?: DateInput, end_date?: DateInput, time_zone?: string): Promise<{
@@ -14279,7 +14478,7 @@ declare class TeslemetryVehicleStream extends EventEmitter {
14279
14478
  * Returns a promise that resolves when the debounced update completes.
14280
14479
  * Multiple calls within the debounce window share the same promise.
14281
14480
  */
14282
- updateFields(fields: FieldsRequest): Promise<void>;
14481
+ updateFields(fields: FieldsRequest): Promise<boolean>;
14283
14482
  /** Flush pending field updates to the API */
14284
14483
  private _flushFieldUpdate;
14285
14484
  /** Modify the field configuration of the vehicle */
@@ -14298,9 +14497,9 @@ declare class TeslemetryVehicleStream extends EventEmitter {
14298
14497
  * Add a field to the vehicles streaming configuration
14299
14498
  * @param field Vehicle Signal
14300
14499
  * @param interval
14301
- * @returns Promise that resolves when the field is added
14500
+ * @returns Promise that resolves to whether the field configuration changed
14302
14501
  */
14303
- addField(field: Signals, interval?: number): Promise<void>;
14502
+ addField(field: Signals, interval?: number): Promise<boolean>;
14304
14503
  /**
14305
14504
  * Helper to enable and listen for specific field signals
14306
14505
  * @param field Vehicle field to listen for
package/dist/index.d.mts CHANGED
@@ -3794,7 +3794,12 @@ type PatchApiConfigByVinData = {
3794
3794
  */
3795
3795
  vin: string;
3796
3796
  };
3797
- query?: never;
3797
+ query?: {
3798
+ /**
3799
+ * Use minimum values instead of defaults. 'true' applies minimums to new fields only, 'force' overrides all fields with minimum values.
3800
+ */
3801
+ min?: 'true' | 'force';
3802
+ };
3798
3803
  url: '/api/config/{vin}';
3799
3804
  };
3800
3805
  type PostApiConfigByVinData = {
@@ -5618,7 +5623,12 @@ type PostApiConfigByVinData = {
5618
5623
  */
5619
5624
  vin: string;
5620
5625
  };
5621
- query?: never;
5626
+ query?: {
5627
+ /**
5628
+ * Use minimum values instead of defaults. 'true' applies minimums to new fields only, 'force' overrides all fields with minimum values.
5629
+ */
5630
+ min?: 'true' | 'force';
5631
+ };
5622
5632
  url: '/api/config/{vin}';
5623
5633
  };
5624
5634
  type GetApi1VehiclesByVinVehicleDataResponses = {
@@ -8037,32 +8047,107 @@ type GetApi1EnergySitesByIdLiveStatusResponses = {
8037
8047
  */
8038
8048
  200: {
8039
8049
  response: {
8050
+ /**
8051
+ * Power currently being generated by solar panels in watts. Always zero or positive.
8052
+ */
8040
8053
  solar_power?: number;
8054
+ /**
8055
+ * Powerwall battery state of charge as a percentage (0-100).
8056
+ */
8041
8057
  percentage_charged?: number;
8058
+ /**
8059
+ * Power flowing to/from the Powerwall battery in watts. Positive = discharging (powering home/grid), negative = charging.
8060
+ */
8042
8061
  battery_power?: number;
8062
+ /**
8063
+ * Total power consumption of the home in watts. Always zero or positive.
8064
+ */
8043
8065
  load_power?: number;
8066
+ /**
8067
+ * Current status of the utility grid connection.
8068
+ */
8044
8069
  grid_status?: 'Active' | 'Inactive' | 'Unknown';
8070
+ /**
8071
+ * Power flowing to/from the utility grid in watts. Positive = importing (buying from grid), negative = exporting (selling to grid).
8072
+ */
8045
8073
  grid_power?: number;
8074
+ /**
8075
+ * Power from a backup generator in watts, if present. Always zero or positive.
8076
+ */
8046
8077
  generator_power?: number;
8078
+ /**
8079
+ * Array of Tesla Wall Connectors at the energy site.
8080
+ */
8047
8081
  wall_connectors?: Array<{
8082
+ /**
8083
+ * Device Identification Number, a unique identifier for the Wall Connector.
8084
+ */
8048
8085
  din: string;
8086
+ /**
8087
+ * Vehicle Identification Number of the connected vehicle, if any.
8088
+ */
8049
8089
  vin?: string;
8090
+ /**
8091
+ * Operational state: 1 = charging, 2 = not plugged in, 3 = plugged in (not charging), 4 = plugged in (paused).
8092
+ */
8050
8093
  wall_connector_state: number;
8094
+ /**
8095
+ * Fault condition code. 0 indicates no fault.
8096
+ */
8051
8097
  wall_connector_fault_state?: number;
8098
+ /**
8099
+ * Power being delivered to the vehicle in watts.
8100
+ */
8052
8101
  wall_connector_power: number;
8102
+ /**
8103
+ * Open Charge Point Protocol status code.
8104
+ */
8053
8105
  ocpp_status?: number;
8106
+ /**
8107
+ * Powershare (vehicle-to-home) session state code.
8108
+ */
8054
8109
  powershare_session_state?: number;
8055
8110
  }>;
8111
+ /**
8112
+ * Whether the site is islanded (operating independently from the grid). off_grid_intentional = user-initiated (e.g., Go Off-Grid test), off_grid_unintentional = grid outage.
8113
+ */
8056
8114
  island_status?: 'on_grid' | 'island_status_unknown' | 'off_grid_intentional' | 'off_grid_unintentional';
8115
+ /**
8116
+ * Whether Storm Watch is currently active, charging the battery to 100% in preparation for a potential outage.
8117
+ */
8057
8118
  storm_mode_active?: boolean;
8119
+ /**
8120
+ * ISO 8601 timestamp when this data was captured.
8121
+ */
8058
8122
  timestamp: string;
8123
+ /**
8124
+ * Active Storm Watch events with timing and storm type information.
8125
+ */
8059
8126
  storm_mode_states?: Array<{
8127
+ /**
8128
+ * Unique identifier for the storm watch event.
8129
+ */
8060
8130
  watch_event_id: string;
8131
+ /**
8132
+ * ISO 8601 timestamp when the storm watch begins.
8133
+ */
8061
8134
  start_time: string;
8135
+ /**
8136
+ * ISO 8601 timestamp when the storm watch ends.
8137
+ */
8062
8138
  end_time: string;
8139
+ /**
8140
+ * Type of storm (e.g., winter storm, hurricane, thunderstorm).
8141
+ */
8063
8142
  storm_type: string;
8143
+ /**
8144
+ * Whether the user has opted out of this storm watch event.
8145
+ */
8064
8146
  opted_out?: boolean;
8065
8147
  }>;
8148
+ /**
8149
+ * Whether the battery breaker is open, meaning the Powerwall is electrically disconnected from the system.
8150
+ */
8066
8151
  battery_breaker_open?: boolean;
8067
8152
  };
8068
8153
  };
@@ -8074,44 +8159,158 @@ type GetApi1EnergySitesByIdSiteInfoResponses = {
8074
8159
  */
8075
8160
  200: {
8076
8161
  response: {
8162
+ /**
8163
+ * Unique identifier for the energy site.
8164
+ */
8077
8165
  id: string;
8166
+ /**
8167
+ * User-defined name for the energy site.
8168
+ */
8078
8169
  site_name?: string;
8170
+ /**
8171
+ * Minimum battery level (0-80% or 100%) to reserve for backup power during grid outages.
8172
+ */
8079
8173
  backup_reserve_percent?: number;
8174
+ /**
8175
+ * Operating mode: 'autonomous' (time-based control), 'self_consumption' (self-powered), or 'backup' (backup only).
8176
+ */
8080
8177
  default_real_mode?: string;
8178
+ /**
8179
+ * Date when the energy system was installed, in ISO 8601 format.
8180
+ */
8081
8181
  installation_date: string;
8182
+ /**
8183
+ * User-configurable settings for the energy site.
8184
+ */
8082
8185
  user_settings: {
8186
+ /**
8187
+ * Whether the Go Off-Grid test banner is shown in the app.
8188
+ */
8083
8189
  go_off_grid_test_banner_enabled: null | boolean;
8190
+ /**
8191
+ * Whether Storm Watch is enabled to automatically charge battery before severe weather.
8192
+ */
8084
8193
  storm_mode_enabled: null | boolean;
8194
+ /**
8195
+ * Whether the user has completed Powerwall onboarding setup.
8196
+ */
8085
8197
  powerwall_onboarding_settings_set: null | boolean;
8198
+ /**
8199
+ * Whether the user has expressed interest in Tesla Electric utility service.
8200
+ */
8086
8201
  powerwall_tesla_electric_interested_in: null | boolean;
8202
+ /**
8203
+ * Whether the Virtual Power Plant tour/introduction is enabled.
8204
+ */
8087
8205
  vpp_tour_enabled: null | boolean;
8206
+ /**
8207
+ * Whether vehicle charging is allowed when the site is off-grid (islanded).
8208
+ */
8088
8209
  off_grid_vehicle_charging_enabled: null | boolean;
8089
8210
  };
8211
+ /**
8212
+ * Hardware components and feature capabilities of the energy site.
8213
+ */
8090
8214
  components: {
8215
+ /**
8216
+ * Whether solar panels are installed at the site.
8217
+ */
8091
8218
  solar: boolean;
8219
+ /**
8220
+ * Type of solar installation (e.g., 'pv_panel', 'roof').
8221
+ */
8092
8222
  solar_type?: string;
8223
+ /**
8224
+ * Whether a Powerwall battery is installed at the site.
8225
+ */
8093
8226
  battery: boolean;
8227
+ /**
8228
+ * Whether the site has a grid connection.
8229
+ */
8094
8230
  grid: boolean;
8231
+ /**
8232
+ * Whether backup power functionality is available.
8233
+ */
8095
8234
  backup: boolean;
8235
+ /**
8236
+ * Type of Tesla gateway device (e.g., 'teg' for Tesla Energy Gateway).
8237
+ */
8096
8238
  gateway: string;
8239
+ /**
8240
+ * Whether a load meter is installed to measure home consumption.
8241
+ */
8097
8242
  load_meter: boolean;
8243
+ /**
8244
+ * Whether the system supports Time-of-Use rate optimization.
8245
+ */
8098
8246
  tou_capable: boolean;
8247
+ /**
8248
+ * Whether Storm Watch functionality is available.
8249
+ */
8099
8250
  storm_mode_capable: boolean;
8251
+ /**
8252
+ * Whether the system supports reserving battery capacity for vehicle charging during off-grid operation.
8253
+ */
8100
8254
  off_grid_vehicle_charging_reserve_supported: boolean;
8255
+ /**
8256
+ * Whether vehicle charging performance metrics are available in the app.
8257
+ */
8101
8258
  vehicle_charging_performance_view_enabled: boolean;
8259
+ /**
8260
+ * Whether solar offset metrics for vehicle charging are available in the app.
8261
+ */
8102
8262
  vehicle_charging_solar_offset_view_enabled: boolean;
8263
+ /**
8264
+ * Whether solar offset metrics for battery charging are available in the app.
8265
+ */
8103
8266
  battery_solar_offset_view_enabled: boolean;
8267
+ /**
8268
+ * Whether solar value calculations are enabled.
8269
+ */
8104
8270
  solar_value_enabled?: boolean;
8271
+ /**
8272
+ * Header text displayed for energy value in the app.
8273
+ */
8105
8274
  energy_value_header?: string;
8275
+ /**
8276
+ * Subheader text displayed for energy value in the app.
8277
+ */
8106
8278
  energy_value_subheader?: string;
8279
+ /**
8280
+ * Whether the system can self-schedule for grid services events.
8281
+ */
8107
8282
  energy_service_self_scheduling_enabled: boolean;
8283
+ /**
8284
+ * Whether to display the battery state of energy graph in the app.
8285
+ */
8108
8286
  show_battery_soe_graph?: boolean;
8287
+ /**
8288
+ * Whether to show grid import and battery source cards in the app.
8289
+ */
8109
8290
  show_grid_import_battery_source_cards?: boolean;
8291
+ /**
8292
+ * Whether the user can manually trigger off-grid (island) mode.
8293
+ */
8110
8294
  set_islanding_mode_enabled?: boolean;
8295
+ /**
8296
+ * Whether WiFi commissioning is enabled for the gateway.
8297
+ */
8111
8298
  wifi_commissioning_enabled?: boolean;
8299
+ /**
8300
+ * Whether backup time remaining estimates are available.
8301
+ */
8112
8302
  backup_time_remaining_enabled?: boolean;
8303
+ /**
8304
+ * Type of battery installed (e.g., 'ac_powerwall' for Powerwall 2/+, 'dc_powerwall' for Powerwall 3).
8305
+ */
8113
8306
  battery_type?: string;
8307
+ /**
8308
+ * Whether the system settings can be modified via the API.
8309
+ */
8114
8310
  configurable?: boolean;
8311
+ /**
8312
+ * Whether the site is enrolled in grid services (Virtual Power Plant).
8313
+ */
8115
8314
  grid_services_enabled?: boolean;
8116
8315
  gateways?: Array<{
8117
8316
  device_id: string;
@@ -10599,7 +10798,7 @@ declare class TeslemetryEnergyApi extends EventEmitter {
10599
10798
  * Returns the charging history of a wall connector.
10600
10799
  * @param start_date Start date for the telemetry data (string, Date, or undefined - defaults to start of today)
10601
10800
  * @param end_date End date for the telemetry data (string, Date, or undefined - defaults to end of today)
10602
- * @param time_zone Optional timezone for the data
10801
+ * @param time_zone IANA timezone for the data (e.g., 'America/Los_Angeles') - defaults to local timezone
10603
10802
  * @return Promise to an object with response containing charging history data from wall connectors
10604
10803
  */
10605
10804
  getTelemetryHistory(start_date?: DateInput, end_date?: DateInput, time_zone?: string): Promise<{
@@ -14279,7 +14478,7 @@ declare class TeslemetryVehicleStream extends EventEmitter {
14279
14478
  * Returns a promise that resolves when the debounced update completes.
14280
14479
  * Multiple calls within the debounce window share the same promise.
14281
14480
  */
14282
- updateFields(fields: FieldsRequest): Promise<void>;
14481
+ updateFields(fields: FieldsRequest): Promise<boolean>;
14283
14482
  /** Flush pending field updates to the API */
14284
14483
  private _flushFieldUpdate;
14285
14484
  /** Modify the field configuration of the vehicle */
@@ -14298,9 +14497,9 @@ declare class TeslemetryVehicleStream extends EventEmitter {
14298
14497
  * Add a field to the vehicles streaming configuration
14299
14498
  * @param field Vehicle Signal
14300
14499
  * @param interval
14301
- * @returns Promise that resolves when the field is added
14500
+ * @returns Promise that resolves to whether the field configuration changed
14302
14501
  */
14303
- addField(field: Signals, interval?: number): Promise<void>;
14502
+ addField(field: Signals, interval?: number): Promise<boolean>;
14304
14503
  /**
14305
14504
  * Helper to enable and listen for specific field signals
14306
14505
  * @param field Vehicle field to listen for
package/dist/index.mjs CHANGED
@@ -3060,19 +3060,20 @@ var TeslemetryVehicleStream = class extends EventEmitter {
3060
3060
  this._fieldUpdateBatch = null;
3061
3061
  try {
3062
3062
  const data = await this.patchConfig(batch.fields);
3063
- if (data?.updated_vehicles) {
3064
- this.logger.info(`Updated ${Object.keys(batch.fields).length} streaming fields for ${this.vin}`);
3065
- this.fields = {
3066
- ...this.fields,
3067
- ...batch.fields
3068
- };
3069
- batch.deferred.resolve();
3063
+ if (data?.updated_vehicles === void 0) throw new Error(`Error updating streaming config for ${this.vin}`);
3064
+ this.fields = {
3065
+ ...this.fields,
3066
+ ...batch.fields
3067
+ };
3068
+ if (data.updated_vehicles === 0) {
3069
+ this.logger.debug(`No update required for ${this.vin}`);
3070
+ batch.deferred.resolve(false);
3070
3071
  } else {
3071
- const error = /* @__PURE__ */ new Error(`Error updating streaming config for ${this.vin}`);
3072
- this.logger.error(error.message, data);
3073
- batch.deferred.reject(error);
3072
+ this.logger.info(`Updated ${Object.keys(batch.fields).length} streaming fields for ${this.vin}`);
3073
+ batch.deferred.resolve(true);
3074
3074
  }
3075
3075
  } catch (error) {
3076
+ this.logger.error(error.message);
3076
3077
  batch.deferred.reject(error);
3077
3078
  }
3078
3079
  }
@@ -3098,12 +3099,12 @@ var TeslemetryVehicleStream = class extends EventEmitter {
3098
3099
  * Add a field to the vehicles streaming configuration
3099
3100
  * @param field Vehicle Signal
3100
3101
  * @param interval
3101
- * @returns Promise that resolves when the field is added
3102
+ * @returns Promise that resolves to whether the field configuration changed
3102
3103
  */
3103
3104
  addField(field, interval) {
3104
3105
  if (this.fields && this.fields[field] && (interval === void 0 || this.fields[field].interval_seconds === interval)) {
3105
3106
  this.logger.debug(`Streaming field ${field} already enabled @ ${this.fields[field]?.interval_seconds || "default"}s`);
3106
- return Promise.resolve();
3107
+ return Promise.resolve(false);
3107
3108
  }
3108
3109
  const value = interval !== void 0 ? { interval_seconds: interval } : null;
3109
3110
  return this.updateFields({ [field]: value });
@@ -3647,7 +3648,7 @@ var TeslemetryEnergyApi = class extends EventEmitter {
3647
3648
  * Returns the charging history of a wall connector.
3648
3649
  * @param start_date Start date for the telemetry data (string, Date, or undefined - defaults to start of today)
3649
3650
  * @param end_date End date for the telemetry data (string, Date, or undefined - defaults to end of today)
3650
- * @param time_zone Optional timezone for the data
3651
+ * @param time_zone IANA timezone for the data (e.g., 'America/Los_Angeles') - defaults to local timezone
3651
3652
  * @return Promise to an object with response containing charging history data from wall connectors
3652
3653
  */
3653
3654
  async getTelemetryHistory(start_date, end_date, time_zone) {
@@ -3655,7 +3656,7 @@ var TeslemetryEnergyApi = class extends EventEmitter {
3655
3656
  query: {
3656
3657
  kind: "charge",
3657
3658
  ...processDateRange(start_date ?? getStartOfToday(), end_date ?? getEndOfToday()),
3658
- time_zone
3659
+ time_zone: time_zone ?? Intl.DateTimeFormat().resolvedOptions().timeZone
3659
3660
  },
3660
3661
  path: { id: this.siteId },
3661
3662
  client: this.root.client
@@ -5261,7 +5262,7 @@ const consoleLogger = {
5261
5262
 
5262
5263
  //#endregion
5263
5264
  //#region package.json
5264
- var version = "0.6.12";
5265
+ var version = "0.6.13";
5265
5266
 
5266
5267
  //#endregion
5267
5268
  //#region src/Teslemetry.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teslemetry/api",
3
- "version": "0.6.12",
3
+ "version": "0.6.13",
4
4
  "description": "API client for Teslemetry",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",