1use serde::{Deserialize, Serialize};
2use std::fmt;
3
4#[derive(Debug, Serialize, Deserialize, PartialEq)]
9pub struct HassConfig {
10 pub latitude: f32,
11 pub longitude: f32,
12 pub elevation: u32,
13 pub unit_system: UnitSystem,
14 pub location_name: String,
15 pub time_zone: String,
16 pub components: Vec<String>,
17 pub config_dir: String,
18 pub whitelist_external_dirs: Vec<String>,
19 pub version: String,
20 pub config_source: String,
21 pub safe_mode: bool,
22 pub external_url: Option<String>,
23 pub internal_url: Option<String>,
24}
25
26#[derive(Debug, Serialize, Deserialize, PartialEq)]
28pub struct UnitSystem {
29 pub length: String,
30 pub mass: String,
31 pub pressure: String,
32 pub temperature: String,
33 pub volume: String,
34}
35
36impl fmt::Display for HassConfig {
37 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
38 write!(f, "HassConfig {{\n")?;
39 write!(f, " latitude: {},\n", self.latitude)?;
40 write!(f, " longitude: {},\n", self.longitude)?;
41 write!(f, " elevation: {},\n", self.elevation)?;
42 write!(f, " unit_system: {:?},\n", self.unit_system)?;
43 write!(f, " location_name: {},\n", self.location_name)?;
44 write!(f, " time_zone: {},\n", self.time_zone)?;
45 write!(f, " components: {:?},\n", self.components)?;
46 write!(f, " config_dir: {},\n", self.config_dir)?;
47 write!(
48 f,
49 " whitelist_external_dirs: {:?},\n",
50 self.whitelist_external_dirs
51 )?;
52 write!(f, " version: {},\n", self.version)?;
53 write!(f, " config_source: {},\n", self.config_source)?;
54 write!(f, " safe_mode: {},\n", self.safe_mode)?;
55 write!(f, " external_url: {:?},\n", self.external_url)?;
56 write!(f, " internal_url: {:?},\n", self.internal_url)?;
57 write!(f, "}}")?;
58 Ok(())
59 }
60}
61
62impl fmt::Display for UnitSystem {
63 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
64 write!(f, "UnitSystem {{\n")?;
65 write!(f, " length: {},\n", self.length)?;
66 write!(f, " mass: {},\n", self.mass)?;
67 write!(f, " pressure: {},\n", self.pressure)?;
68 write!(f, " temperature: {},\n", self.temperature)?;
69 write!(f, " volume: {},\n", self.volume)?;
70 write!(f, "}}")?;
71 Ok(())
72 }
73}