zigbee2mqtt_types_vendor_vimar/
lib.rs

1use serde::Deserialize;
2use serde::de::Unexpected;
3use serde::de;
4use serde::Deserializer;
5use zigbee2mqtt_types_base_types::LastSeen;
6/// vimar:02973.B [zigbee2mqtt link](https://www.zigbee2mqtt.io/devices/02973.B.html)
7///
8/// 
9#[cfg_attr(feature = "debug", derive(Debug))]
10#[cfg_attr(feature = "clone", derive(Clone))]
11#[derive(Deserialize)]
12pub struct Zigbee02973Fb {
13    ///Link quality (signal strength)
14    pub linkquality: f64,
15    ///Current temperature measured on the device
16    pub local_temperature: f64,
17    ///Temperature setpoint
18    pub occupied_cooling_setpoint: f64,
19    ///Temperature setpoint
20    pub occupied_heating_setpoint: f64,
21    ///Mode of this device
22    pub system_mode: Zigbee02973FbSystemmode,
23    /// Optional last_seen type, set as a global zigbee2mqtt setting
24    pub last_seen: Option<LastSeen>,
25    /// Optional elapsed type
26    pub elapsed: Option<u64>,
27}/// vimar:03981 [zigbee2mqtt link](https://www.zigbee2mqtt.io/devices/03981.html)
28///
29/// 
30#[cfg_attr(feature = "debug", derive(Debug))]
31#[cfg_attr(feature = "clone", derive(Clone))]
32#[derive(Deserialize)]
33pub struct Zigbee03981 {
34    ///Link quality (signal strength)
35    pub linkquality: f64,
36    ///Controls the behavior when the device is powered on after power loss
37    pub power_on_behavior: Zigbee03981Poweronbehavior,
38    ///Zigbee herdsman description: "On/off state of the switch"
39    ///The string values get converted into boolean with: ON = true and OFF = false
40    #[serde(deserialize_with = "zigbee03981_state_deserializer")]
41    pub state: bool,
42    /// Optional last_seen type, set as a global zigbee2mqtt setting
43    pub last_seen: Option<LastSeen>,
44    /// Optional elapsed type
45    pub elapsed: Option<u64>,
46}
47/// Deserialize bool from String with custom value mapping
48fn zigbee03981_state_deserializer<'de, D>(deserializer: D) -> Result<bool, D::Error>
49where
50    D: Deserializer<'de>,
51{
52    match String::deserialize(deserializer)?.as_ref() {
53        "ON" => Ok(true),
54        "OFF" => Ok(false),
55        other => Err(de::Error::invalid_value(
56            Unexpected::Str(other),
57            &"Value expected was either ON or OFF",
58        )),
59    }
60}
61
62/// vimar:14592.0 [zigbee2mqtt link](https://www.zigbee2mqtt.io/devices/14592.0.html)
63///
64/// 
65#[cfg_attr(feature = "debug", derive(Debug))]
66#[cfg_attr(feature = "clone", derive(Clone))]
67#[derive(Deserialize)]
68pub struct Zigbee14592F0 {
69    ///Link quality (signal strength)
70    pub linkquality: f64,
71    ///Controls the behavior when the device is powered on after power loss
72    pub power_on_behavior: Zigbee14592F0Poweronbehavior,
73    ///Zigbee herdsman description: "On/off state of the switch"
74    ///The string values get converted into boolean with: ON = true and OFF = false
75    #[serde(deserialize_with = "zigbee14592f0_state_deserializer")]
76    pub state: bool,
77    /// Optional last_seen type, set as a global zigbee2mqtt setting
78    pub last_seen: Option<LastSeen>,
79    /// Optional elapsed type
80    pub elapsed: Option<u64>,
81}
82/// Deserialize bool from String with custom value mapping
83fn zigbee14592f0_state_deserializer<'de, D>(deserializer: D) -> Result<bool, D::Error>
84where
85    D: Deserializer<'de>,
86{
87    match String::deserialize(deserializer)?.as_ref() {
88        "ON" => Ok(true),
89        "OFF" => Ok(false),
90        other => Err(de::Error::invalid_value(
91            Unexpected::Str(other),
92            &"Value expected was either ON or OFF",
93        )),
94    }
95}
96
97/// vimar:14593 [zigbee2mqtt link](https://www.zigbee2mqtt.io/devices/14593.html)
98///
99/// 
100#[cfg_attr(feature = "debug", derive(Debug))]
101#[cfg_attr(feature = "clone", derive(Clone))]
102#[derive(Deserialize)]
103pub struct Zigbee14593 {
104    ///Link quality (signal strength)
105    pub linkquality: f64,
106    ///Instantaneous measured power
107    pub power: f64,
108    ///Zigbee herdsman description: "On/off state of the switch"
109    ///The string values get converted into boolean with: ON = true and OFF = false
110    #[serde(deserialize_with = "zigbee14593_state_deserializer")]
111    pub state: bool,
112    /// Optional last_seen type, set as a global zigbee2mqtt setting
113    pub last_seen: Option<LastSeen>,
114    /// Optional elapsed type
115    pub elapsed: Option<u64>,
116}
117/// Deserialize bool from String with custom value mapping
118fn zigbee14593_state_deserializer<'de, D>(deserializer: D) -> Result<bool, D::Error>
119where
120    D: Deserializer<'de>,
121{
122    match String::deserialize(deserializer)?.as_ref() {
123        "ON" => Ok(true),
124        "OFF" => Ok(false),
125        other => Err(de::Error::invalid_value(
126            Unexpected::Str(other),
127            &"Value expected was either ON or OFF",
128        )),
129    }
130}
131
132/// vimar:14594 [zigbee2mqtt link](https://www.zigbee2mqtt.io/devices/14594.html)
133///
134/// 
135#[cfg_attr(feature = "debug", derive(Debug))]
136#[cfg_attr(feature = "clone", derive(Clone))]
137#[derive(Deserialize)]
138pub struct Zigbee14594 {
139    ///Link quality (signal strength)
140    pub linkquality: f64,
141    ///Position of this cover
142    pub position: f64,
143    pub state: Zigbee14594State,
144    /// Optional last_seen type, set as a global zigbee2mqtt setting
145    pub last_seen: Option<LastSeen>,
146    /// Optional elapsed type
147    pub elapsed: Option<u64>,
148}
149#[cfg_attr(feature = "debug", derive(Debug))]
150#[cfg_attr(feature = "clone", derive(Clone))]
151#[derive(Deserialize, PartialEq)]
152pub enum Zigbee02973FbSystemmode {
153    #[serde(rename = "cool")]
154    Cool,
155    #[serde(rename = "heat")]
156    Heat,
157}
158#[cfg_attr(feature = "debug", derive(Debug))]
159#[cfg_attr(feature = "clone", derive(Clone))]
160#[derive(Deserialize, PartialEq)]
161pub enum Zigbee03981Poweronbehavior {
162    #[serde(rename = "off")]
163    Off,
164    #[serde(rename = "on")]
165    On,
166    #[serde(rename = "previous")]
167    Previous,
168    #[serde(rename = "toggle")]
169    Toggle,
170}
171#[cfg_attr(feature = "debug", derive(Debug))]
172#[cfg_attr(feature = "clone", derive(Clone))]
173#[derive(Deserialize, PartialEq)]
174pub enum Zigbee14592F0Poweronbehavior {
175    #[serde(rename = "off")]
176    Off,
177    #[serde(rename = "on")]
178    On,
179    #[serde(rename = "previous")]
180    Previous,
181    #[serde(rename = "toggle")]
182    Toggle,
183}
184#[cfg_attr(feature = "debug", derive(Debug))]
185#[cfg_attr(feature = "clone", derive(Clone))]
186#[derive(Deserialize, PartialEq)]
187pub enum Zigbee14594State {
188    #[serde(rename = "CLOSE")]
189    Close,
190    #[serde(rename = "OPEN")]
191    Open,
192    #[serde(rename = "STOP")]
193    Stop,
194}
195#[cfg(all(feature = "last_seen_epoch", feature = "last_seen_iso_8601"))]
196compile_error!{"Feature last_seen epoch and iso_8601 are mutually exclusive and cannot be enabled together.
197This was done because it is a global setting in zigbee2mqtt and therefor can't see a reason both would be enabled.
198If you have a any reason to have both ways enabled please submit an issue to https://gitlab.com/seam345/zigbee2mqtt-types/-/issues"}