wall connector

This commit is contained in:
Alex Janka 2024-05-25 09:32:40 +10:00
parent ef26ce4697
commit 490a50e24c

View file

@ -39,6 +39,7 @@ pub enum Product {
Vehicle(Box<VehicleData>),
Solar(Box<SolarData>),
Powerwall(Box<PowerwallData>),
WallConnector,
}
fn deserialize_product<'de, D>(deserializer: D) -> Result<Product, D::Error>
@ -56,6 +57,8 @@ where
} else if v.get("battery_type").is_some() {
let powerwall_data = PowerwallData::deserialize(v).map_err(serde::de::Error::custom)?;
Ok(Product::Powerwall(Box::new(powerwall_data)))
} else if v.get("resource_type").is_some() {
Ok(Product::WallConnector)
} else {
Err(serde::de::Error::custom(
"No valid key found to determine the product type",