zigbee2mqtt_types_vendor_netvox/
lib.rs1use serde::Deserialize;
2use serde::de::Unexpected;
3use serde::de;
4use serde::Deserializer;
5use zigbee2mqtt_types_base_types::LastSeen;
6#[cfg_attr(feature = "debug", derive(Debug))]
10#[cfg_attr(feature = "clone", derive(Clone))]
11#[derive(Deserialize)]
12pub struct ZigbeeZ809a {
13 pub current: f64,
15 pub linkquality: f64,
17 pub power: f64,
19 #[serde(deserialize_with = "zigbeez809a_state_deserializer")]
22 pub state: bool,
23 pub voltage: f64,
25 pub last_seen: Option<LastSeen>,
27 pub elapsed: Option<u64>,
29}
30fn zigbeez809a_state_deserializer<'de, D>(deserializer: D) -> Result<bool, D::Error>
32where
33 D: Deserializer<'de>,
34{
35 match String::deserialize(deserializer)?.as_ref() {
36 "ON" => Ok(true),
37 "OFF" => Ok(false),
38 other => Err(de::Error::invalid_value(
39 Unexpected::Str(other),
40 &"Value expected was either ON or OFF",
41 )),
42 }
43}
44
45#[cfg_attr(feature = "debug", derive(Debug))]
49#[cfg_attr(feature = "clone", derive(Clone))]
50#[derive(Deserialize)]
51pub struct ZigbeeZb02a {
52 pub action: ZigbeeZb02aAction,
54 pub linkquality: f64,
56 pub last_seen: Option<LastSeen>,
58 pub elapsed: Option<u64>,
60}
61#[cfg_attr(feature = "debug", derive(Debug))]
62#[cfg_attr(feature = "clone", derive(Clone))]
63#[derive(Deserialize, PartialEq)]
64pub enum ZigbeeZb02aAction {
65 #[serde(rename = "toggle")]
66 Toggle,
67}
68#[cfg(all(feature = "last_seen_epoch", feature = "last_seen_iso_8601"))]
69compile_error!{"Feature last_seen epoch and iso_8601 are mutually exclusive and cannot be enabled together.
70This was done because it is a global setting in zigbee2mqtt and therefor can't see a reason both would be enabled.
71If you have a any reason to have both ways enabled please submit an issue to https://gitlab.com/seam345/zigbee2mqtt-types/-/issues"}