fix: powerwall api new fields
This commit is contained in:
parent
491d9a58a8
commit
85e3728a1d
15
CHANGELOG.md
15
CHANGELOG.md
|
@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [0.1.12] - 2023-01-20
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- PowerwallData new fields:
|
||||||
|
- powerwall_onboarding_settings_set
|
||||||
|
- storm_mode_enabled
|
||||||
|
- features
|
||||||
|
- warp_site_number
|
||||||
|
- go_off_grid_test_banner_enabled
|
||||||
|
- powerwall_tesla_electric_interested_in
|
||||||
|
- vpp_tour_enabled
|
||||||
|
- Components market_type is now Option<String>
|
||||||
|
- LiveWallConnector wall_connector_power is now f32
|
||||||
|
|
||||||
## [0.1.11] - 2023-11-11
|
## [0.1.11] - 2023-11-11
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
@ -69,7 +69,7 @@ pub struct LiveWallConnector {
|
||||||
/// 2: not plugged in
|
/// 2: not plugged in
|
||||||
/// 4: plugged in (not charging)
|
/// 4: plugged in (not charging)
|
||||||
pub wall_connector_state: i64,
|
pub wall_connector_state: i64,
|
||||||
pub wall_connector_power: i64,
|
pub wall_connector_power: f32,
|
||||||
pub wall_connector_fault_state: i64,
|
pub wall_connector_fault_state: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,7 +311,7 @@ mod tests {
|
||||||
vin: Some("1234".to_string()),
|
vin: Some("1234".to_string()),
|
||||||
din: "5432".to_string(),
|
din: "5432".to_string(),
|
||||||
wall_connector_state: 4,
|
wall_connector_state: 4,
|
||||||
wall_connector_power: 0,
|
wall_connector_power: 0.,
|
||||||
wall_connector_fault_state: 2,
|
wall_connector_fault_state: 2,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -336,7 +336,7 @@ mod tests {
|
||||||
vin: None,
|
vin: None,
|
||||||
din: "1234".to_string(),
|
din: "1234".to_string(),
|
||||||
wall_connector_state: 2,
|
wall_connector_state: 2,
|
||||||
wall_connector_power: 0,
|
wall_connector_power: 0.,
|
||||||
wall_connector_fault_state: 2,
|
wall_connector_fault_state: 2,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -69,6 +69,19 @@ pub struct PowerwallData {
|
||||||
pub sync_grid_alert_enabled: bool,
|
pub sync_grid_alert_enabled: bool,
|
||||||
pub breaker_alert_enabled: bool,
|
pub breaker_alert_enabled: bool,
|
||||||
pub components: Components,
|
pub components: Components,
|
||||||
|
// New fields as of 2024-01-20
|
||||||
|
pub powerwall_onboarding_settings_set: bool,
|
||||||
|
pub storm_mode_enabled: bool,
|
||||||
|
pub features: PowerwallFeatures,
|
||||||
|
pub warp_site_number: String,
|
||||||
|
pub go_off_grid_test_banner_enabled: Option<bool>,
|
||||||
|
pub powerwall_tesla_electric_interested_in: Option<bool>,
|
||||||
|
pub vpp_tour_enabled: Option<bool>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
|
pub struct PowerwallFeatures {
|
||||||
|
pub rate_plan_manager_no_pricing_constraint: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
|
@ -79,7 +92,7 @@ pub struct Components {
|
||||||
pub solar_type: Option<String>,
|
pub solar_type: Option<String>,
|
||||||
pub grid: bool,
|
pub grid: bool,
|
||||||
pub load_meter: bool,
|
pub load_meter: bool,
|
||||||
pub market_type: String,
|
pub market_type: Option<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub wall_connectors: Vec<WallConnector>,
|
pub wall_connectors: Vec<WallConnector>,
|
||||||
}
|
}
|
||||||
|
@ -88,60 +101,9 @@ pub struct Components {
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::energy_sites::{CalendarHistoryValues, HistoryKind, HistoryPeriod};
|
use crate::energy_sites::{CalendarHistoryValues, HistoryKind, HistoryPeriod};
|
||||||
use crate::ApiValues;
|
use crate::{ApiValues, PrintResponses, RequestData};
|
||||||
use chrono::DateTime;
|
use chrono::DateTime;
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn energy_match_powerwall() {
|
|
||||||
let json = r#"
|
|
||||||
{
|
|
||||||
"energy_site_id": 1032748243,
|
|
||||||
"resource_type": "battery",
|
|
||||||
"site_name": "1 Railway Pde",
|
|
||||||
"id": "ABC2010-1234",
|
|
||||||
"gateway_id": "3287423824-QWE",
|
|
||||||
"asset_site_id": "123ecd-123ecd-12345-12345",
|
|
||||||
"energy_left": 4394.000000000001,
|
|
||||||
"total_pack_energy": 13494,
|
|
||||||
"percentage_charged": 32.562620423892106,
|
|
||||||
"battery_type": "ac_powerwall",
|
|
||||||
"backup_capable": true,
|
|
||||||
"battery_power": -280,
|
|
||||||
"sync_grid_alert_enabled": true,
|
|
||||||
"breaker_alert_enabled": false,
|
|
||||||
"components": {
|
|
||||||
"battery": true,
|
|
||||||
"battery_type": "ac_powerwall",
|
|
||||||
"solar": true,
|
|
||||||
"solar_type": "pv_panel",
|
|
||||||
"grid": true,
|
|
||||||
"load_meter": true,
|
|
||||||
"market_type": "residential"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"#;
|
|
||||||
|
|
||||||
if let Product::Powerwall(data) = serde_json::from_str(json).unwrap() {
|
|
||||||
assert_eq!(data.battery_type, "ac_powerwall");
|
|
||||||
assert!(data.backup_capable);
|
|
||||||
assert_eq!(data.battery_power, -280);
|
|
||||||
assert!(data.sync_grid_alert_enabled);
|
|
||||||
assert!(!data.breaker_alert_enabled);
|
|
||||||
assert!(data.components.battery);
|
|
||||||
assert_eq!(
|
|
||||||
data.components.battery_type,
|
|
||||||
Some("ac_powerwall".to_string())
|
|
||||||
);
|
|
||||||
assert!(data.components.solar);
|
|
||||||
assert_eq!(data.components.solar_type, Some("pv_panel".to_string()));
|
|
||||||
assert!(data.components.grid);
|
|
||||||
assert!(data.components.load_meter);
|
|
||||||
assert_eq!(data.components.market_type, "residential");
|
|
||||||
} else {
|
|
||||||
panic!("Expected PowerwallData");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn energy_match_vehicle() {
|
fn energy_match_vehicle() {
|
||||||
let json = r#"
|
let json = r#"
|
||||||
|
@ -269,4 +231,12 @@ mod tests {
|
||||||
"https://base.com/e/123/history?period=month&kind=energy&start_date=2020-01-01T00:00:00Z&end_date=2020-01-31T23:59:59Z"
|
"https://base.com/e/123/history?period=month&kind=energy&start_date=2020-01-01T00:00:00Z&end_date=2020-01-31T23:59:59Z"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn json_products_gak_2024_01_20() {
|
||||||
|
let s = include_str!("../testdata/products_gak_2024_01_20.json");
|
||||||
|
let request_data = RequestData::Get { url: "" };
|
||||||
|
OwnerApi::parse_json::<Vec<Product>>(&request_data, s.to_string(), PrintResponses::Pretty)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
118
testdata/products_gak_2024_01_20.json
vendored
Normal file
118
testdata/products_gak_2024_01_20.json
vendored
Normal file
|
@ -0,0 +1,118 @@
|
||||||
|
{
|
||||||
|
"count": 2,
|
||||||
|
"response": [
|
||||||
|
{
|
||||||
|
"access_type": "OWNER",
|
||||||
|
"api_version": 71,
|
||||||
|
"backseat_token": null,
|
||||||
|
"backseat_token_updated_at": null,
|
||||||
|
"ble_autopair_enrolled": false,
|
||||||
|
"cached_data": "",
|
||||||
|
"calendar_enabled": true,
|
||||||
|
"color": null,
|
||||||
|
"command_signing": "required",
|
||||||
|
"display_name": "Kool Beans",
|
||||||
|
"granular_access": {
|
||||||
|
"hide_private": false
|
||||||
|
},
|
||||||
|
"id": 1,
|
||||||
|
"id_s": "1",
|
||||||
|
"in_service": false,
|
||||||
|
"option_codes": null,
|
||||||
|
"release_notes_supported": true,
|
||||||
|
"state": "online",
|
||||||
|
"tokens": [
|
||||||
|
],
|
||||||
|
"user_id": 2,
|
||||||
|
"vehicle_config": {
|
||||||
|
"aux_park_lamps": "Eu",
|
||||||
|
"badge_version": 0,
|
||||||
|
"can_accept_navigation_requests": true,
|
||||||
|
"can_actuate_trunks": true,
|
||||||
|
"car_special_type": "base",
|
||||||
|
"car_type": "model3",
|
||||||
|
"charge_port_type": "CCS",
|
||||||
|
"cop_user_set_temp_supported": false,
|
||||||
|
"dashcam_clip_save_supported": true,
|
||||||
|
"default_charge_to_max": false,
|
||||||
|
"driver_assist": "TeslaAP3",
|
||||||
|
"ece_restrictions": false,
|
||||||
|
"efficiency_package": "M32021",
|
||||||
|
"eu_vehicle": true,
|
||||||
|
"exterior_color": "MidnightSilver",
|
||||||
|
"exterior_trim": "Black",
|
||||||
|
"exterior_trim_override": "",
|
||||||
|
"has_air_suspension": false,
|
||||||
|
"has_ludicrous_mode": false,
|
||||||
|
"has_seat_cooling": false,
|
||||||
|
"headlamp_type": "Global",
|
||||||
|
"interior_trim_type": "Black2",
|
||||||
|
"key_version": 2,
|
||||||
|
"motorized_charge_port": true,
|
||||||
|
"paint_color_override": "24,24,27,0.9,0.3",
|
||||||
|
"performance_package": "Base",
|
||||||
|
"plg": true,
|
||||||
|
"pws": false,
|
||||||
|
"rear_drive_unit": "PM216MOSFET",
|
||||||
|
"rear_seat_heaters": 1,
|
||||||
|
"rear_seat_type": 0,
|
||||||
|
"rhd": true,
|
||||||
|
"roof_color": "RoofColorGlass",
|
||||||
|
"seat_type": null,
|
||||||
|
"spoiler_type": "None",
|
||||||
|
"sun_roof_installed": null,
|
||||||
|
"supports_qr_pairing": false,
|
||||||
|
"third_row_seats": "None",
|
||||||
|
"timestamp": 1705717676876,
|
||||||
|
"trim_badging": "74d",
|
||||||
|
"use_range_badging": true,
|
||||||
|
"utc_offset": 36000,
|
||||||
|
"webcam_selfie_supported": true,
|
||||||
|
"webcam_supported": true,
|
||||||
|
"wheel_type": "StilettoRefresh19"
|
||||||
|
},
|
||||||
|
"vehicle_id": 1,
|
||||||
|
"vin": "LR"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"asset_site_id": "",
|
||||||
|
"backup_capable": true,
|
||||||
|
"battery_power": 3520,
|
||||||
|
"battery_type": "ac_powerwall",
|
||||||
|
"breaker_alert_enabled": true,
|
||||||
|
"components": {
|
||||||
|
"battery": true,
|
||||||
|
"battery_type": "ac_powerwall",
|
||||||
|
"grid": true,
|
||||||
|
"load_meter": true,
|
||||||
|
"solar": true,
|
||||||
|
"solar_type": "pv_panel",
|
||||||
|
"wall_connectors": [
|
||||||
|
{
|
||||||
|
"device_id": "",
|
||||||
|
"din": "",
|
||||||
|
"is_active": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"energy_left": 13136.26315789474,
|
||||||
|
"energy_site_id": 247079748146,
|
||||||
|
"features": {
|
||||||
|
"rate_plan_manager_no_pricing_constraint": true
|
||||||
|
},
|
||||||
|
"gateway_id": "a",
|
||||||
|
"go_off_grid_test_banner_enabled": null,
|
||||||
|
"id": "1234",
|
||||||
|
"percentage_charged": 31.52375310862408,
|
||||||
|
"powerwall_onboarding_settings_set": true,
|
||||||
|
"powerwall_tesla_electric_interested_in": null,
|
||||||
|
"resource_type": "battery",
|
||||||
|
"site_name": "",
|
||||||
|
"storm_mode_enabled": true,
|
||||||
|
"sync_grid_alert_enabled": true,
|
||||||
|
"total_pack_energy": 41671,
|
||||||
|
"vpp_tour_enabled": null,
|
||||||
|
"warp_site_number": "STE00"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in a new issue