enphase_local/
inventory.rs1use crate::timestamp_string;
8use chrono::{DateTime, Utc};
9use serde::{Deserialize, Serialize};
10use serde_repr::{Deserialize_repr, Serialize_repr};
11
12#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
14pub struct Inventory(pub Vec<InventoryGroup>);
15
16#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
18pub struct InventoryGroup {
19 #[serde(rename = "type")]
20 pub type_: DeviceType,
21 pub devices: Vec<Device>,
22}
23
24#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
25#[serde(rename_all = "UPPERCASE")]
26pub enum DeviceType {
27 Pcu,
29 Acb,
31 Nsrb,
33 Esub,
35}
36
37#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
39pub struct Device {
40 pub part_num: String,
42 #[serde(with = "timestamp_string")]
44 pub installed: DateTime<Utc>,
45 pub serial_num: String,
47 pub device_status: Vec<DeviceStatus>,
49 #[serde(with = "timestamp_string")]
51 pub last_rpt_date: DateTime<Utc>,
52 pub admin_state: AdminState,
54 pub dev_type: u8,
56 #[serde(with = "timestamp_string")]
58 pub created_date: DateTime<Utc>,
59 #[serde(with = "timestamp_string")]
61 pub img_load_date: DateTime<Utc>,
62 pub img_pnum_running: String,
64 pub ptpn: String,
65 pub chaneid: u64,
67 pub device_control: Vec<DeviceControl>,
68 pub producing: bool,
70 pub communicating: bool,
72 pub provisioned: bool,
74 pub operating: bool,
76 pub phase: String,
77}
78
79#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
81pub enum DeviceStatus {
82 #[serde(rename = "envoy.global.ok")]
83 Ok,
84 #[serde(rename = "envoy.cond_flags.pcu_chan.dcvoltagetoolow")]
85 DcVoltageTooLow,
86 #[serde(rename = "envoy.cond_flags.pcu_ctrl.dc-pwr-low")]
87 DcPowerLow,
88 #[serde(rename = "envoy.cond_flags.obs_strs.failure")]
89 Failure,
90}
91
92#[derive(Clone, Copy, Debug, Deserialize_repr, Eq, PartialEq, Serialize_repr)]
94#[repr(u8)]
95pub enum AdminState {
96 Discovered = 1,
97 Verified = 2,
98 Deleted = 3,
99}
100
101#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
102pub struct DeviceControl {
103 pub gficlearset: bool,
105}