use serde::Deserialize;
use serde::de::Unexpected;
use serde::de;
use serde::Deserializer;
use zigbee2mqtt_types_base_types::LastSeen;
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "clone", derive(Clone))]
#[derive(Deserialize)]
pub struct Zigbee15090054 {
pub action: Zigbee15090054Action,
pub battery: f64,
pub linkquality: f64,
pub last_seen: Option<LastSeen>,
pub elapsed: Option<u64>,
}#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "clone", derive(Clone))]
#[derive(Deserialize)]
pub struct Zigbee8180981813 {
pub brightness: f64,
pub color_temp: f64,
pub color_temp_startup: f64,
pub linkquality: f64,
pub power_on_behavior: Zigbee8180981813Poweronbehavior,
#[serde(deserialize_with = "zigbee8180981813_state_deserializer")]
pub state: bool,
pub last_seen: Option<LastSeen>,
pub elapsed: Option<u64>,
}
fn zigbee8180981813_state_deserializer<'de, D>(deserializer: D) -> Result<bool, D::Error>
where
D: Deserializer<'de>,
{
match String::deserialize(deserializer)?.as_ref() {
"ON" => Ok(true),
"OFF" => Ok(false),
other => Err(de::Error::invalid_value(
Unexpected::Str(other),
&"Value expected was either ON or OFF",
)),
}
}
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "clone", derive(Clone))]
#[derive(Deserialize)]
pub struct Zigbee81809fba {
pub brightness: f64,
pub color_temp: f64,
pub color_temp_startup: f64,
pub linkquality: f64,
pub power_on_behavior: Zigbee81809fbaPoweronbehavior,
#[serde(deserialize_with = "zigbee81809fba_state_deserializer")]
pub state: bool,
pub last_seen: Option<LastSeen>,
pub elapsed: Option<u64>,
}
fn zigbee81809fba_state_deserializer<'de, D>(deserializer: D) -> Result<bool, D::Error>
where
D: Deserializer<'de>,
{
match String::deserialize(deserializer)?.as_ref() {
"ON" => Ok(true),
"OFF" => Ok(false),
other => Err(de::Error::invalid_value(
Unexpected::Str(other),
&"Value expected was either ON or OFF",
)),
}
}
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "clone", derive(Clone))]
#[derive(Deserialize)]
pub struct Zigbee81810 {
pub brightness: f64,
pub linkquality: f64,
pub power_on_behavior: Zigbee81810Poweronbehavior,
#[serde(deserialize_with = "zigbee81810_state_deserializer")]
pub state: bool,
pub last_seen: Option<LastSeen>,
pub elapsed: Option<u64>,
}
fn zigbee81810_state_deserializer<'de, D>(deserializer: D) -> Result<bool, D::Error>
where
D: Deserializer<'de>,
{
match String::deserialize(deserializer)?.as_ref() {
"ON" => Ok(true),
"OFF" => Ok(false),
other => Err(de::Error::invalid_value(
Unexpected::Str(other),
&"Value expected was either ON or OFF",
)),
}
}
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "clone", derive(Clone))]
#[derive(Deserialize)]
pub struct Zigbee81825 {
pub action: Zigbee81825Action,
pub linkquality: f64,
pub last_seen: Option<LastSeen>,
pub elapsed: Option<u64>,
}#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "clone", derive(Clone))]
#[derive(Deserialize)]
pub struct Zigbee81848 {
pub current: f64,
pub linkquality: f64,
pub power: f64,
#[serde(deserialize_with = "zigbee81848_state_deserializer")]
pub state: bool,
pub voltage: f64,
pub last_seen: Option<LastSeen>,
pub elapsed: Option<u64>,
}
fn zigbee81848_state_deserializer<'de, D>(deserializer: D) -> Result<bool, D::Error>
where
D: Deserializer<'de>,
{
match String::deserialize(deserializer)?.as_ref() {
"ON" => Ok(true),
"OFF" => Ok(false),
other => Err(de::Error::invalid_value(
Unexpected::Str(other),
&"Value expected was either ON or OFF",
)),
}
}
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "clone", derive(Clone))]
#[derive(Deserialize)]
pub struct Zigbee81849 {
pub brightness: f64,
pub linkquality: f64,
pub power_on_behavior: Zigbee81849Poweronbehavior,
#[serde(deserialize_with = "zigbee81849_state_deserializer")]
pub state: bool,
pub last_seen: Option<LastSeen>,
pub elapsed: Option<u64>,
}
fn zigbee81849_state_deserializer<'de, D>(deserializer: D) -> Result<bool, D::Error>
where
D: Deserializer<'de>,
{
match String::deserialize(deserializer)?.as_ref() {
"ON" => Ok(true),
"OFF" => Ok(false),
other => Err(de::Error::invalid_value(
Unexpected::Str(other),
&"Value expected was either ON or OFF",
)),
}
}
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "clone", derive(Clone))]
#[derive(Deserialize)]
pub struct Zigbee81855 {
pub brightness: f64,
pub linkquality: f64,
pub power_on_behavior: Zigbee81855Poweronbehavior,
#[serde(deserialize_with = "zigbee81855_state_deserializer")]
pub state: bool,
pub last_seen: Option<LastSeen>,
pub elapsed: Option<u64>,
}
fn zigbee81855_state_deserializer<'de, D>(deserializer: D) -> Result<bool, D::Error>
where
D: Deserializer<'de>,
{
match String::deserialize(deserializer)?.as_ref() {
"ON" => Ok(true),
"OFF" => Ok(false),
other => Err(de::Error::invalid_value(
Unexpected::Str(other),
&"Value expected was either ON or OFF",
)),
}
}
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "clone", derive(Clone))]
#[derive(Deserialize)]
pub struct Zigbee81863 {
pub brightness: f64,
pub color_temp: f64,
pub color_temp_startup: f64,
pub linkquality: f64,
pub power_on_behavior: Zigbee81863Poweronbehavior,
#[serde(deserialize_with = "zigbee81863_state_deserializer")]
pub state: bool,
pub last_seen: Option<LastSeen>,
pub elapsed: Option<u64>,
}
fn zigbee81863_state_deserializer<'de, D>(deserializer: D) -> Result<bool, D::Error>
where
D: Deserializer<'de>,
{
match String::deserialize(deserializer)?.as_ref() {
"ON" => Ok(true),
"OFF" => Ok(false),
other => Err(de::Error::invalid_value(
Unexpected::Str(other),
&"Value expected was either ON or OFF",
)),
}
}
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "clone", derive(Clone))]
#[derive(Deserialize)]
pub struct Zigbee81895 {
pub brightness: f64,
pub color_temp: f64,
pub color_temp_startup: f64,
pub linkquality: f64,
pub power_on_behavior: Zigbee81895Poweronbehavior,
#[serde(deserialize_with = "zigbee81895_state_deserializer")]
pub state: bool,
pub last_seen: Option<LastSeen>,
pub elapsed: Option<u64>,
}
fn zigbee81895_state_deserializer<'de, D>(deserializer: D) -> Result<bool, D::Error>
where
D: Deserializer<'de>,
{
match String::deserialize(deserializer)?.as_ref() {
"ON" => Ok(true),
"OFF" => Ok(false),
other => Err(de::Error::invalid_value(
Unexpected::Str(other),
&"Value expected was either ON or OFF",
)),
}
}
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "clone", derive(Clone))]
#[derive(Deserialize)]
pub struct ZigbeeBpu3 {
pub linkquality: f64,
pub power_on_behavior: ZigbeeBpu3Poweronbehavior,
#[serde(deserialize_with = "zigbeebpu3_state_deserializer")]
pub state: bool,
pub last_seen: Option<LastSeen>,
pub elapsed: Option<u64>,
}
fn zigbeebpu3_state_deserializer<'de, D>(deserializer: D) -> Result<bool, D::Error>
where
D: Deserializer<'de>,
{
match String::deserialize(deserializer)?.as_ref() {
"ON" => Ok(true),
"OFF" => Ok(false),
other => Err(de::Error::invalid_value(
Unexpected::Str(other),
&"Value expected was either ON or OFF",
)),
}
}
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "clone", derive(Clone))]
#[derive(Deserialize, PartialEq)]
pub enum Zigbee15090054Action {
#[serde(rename = "recall_253")]
Recall253,
#[serde(rename = "recall_254")]
Recall254,
#[serde(rename = "recall_255")]
Recall255,
#[serde(rename = "toggle")]
Toggle,
}
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "clone", derive(Clone))]
#[derive(Deserialize, PartialEq)]
pub enum Zigbee8180981813Poweronbehavior {
#[serde(rename = "off")]
Off,
#[serde(rename = "on")]
On,
#[serde(rename = "previous")]
Previous,
#[serde(rename = "toggle")]
Toggle,
}
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "clone", derive(Clone))]
#[derive(Deserialize, PartialEq)]
pub enum Zigbee81809fbaPoweronbehavior {
#[serde(rename = "off")]
Off,
#[serde(rename = "on")]
On,
#[serde(rename = "previous")]
Previous,
#[serde(rename = "toggle")]
Toggle,
}
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "clone", derive(Clone))]
#[derive(Deserialize, PartialEq)]
pub enum Zigbee81810Poweronbehavior {
#[serde(rename = "off")]
Off,
#[serde(rename = "on")]
On,
#[serde(rename = "previous")]
Previous,
#[serde(rename = "toggle")]
Toggle,
}
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "clone", derive(Clone))]
#[derive(Deserialize, PartialEq)]
pub enum Zigbee81825Action {
#[serde(rename = "down")]
Down,
#[serde(rename = "off")]
Off,
#[serde(rename = "on")]
On,
#[serde(rename = "up")]
Up,
}
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "clone", derive(Clone))]
#[derive(Deserialize, PartialEq)]
pub enum Zigbee81849Poweronbehavior {
#[serde(rename = "off")]
Off,
#[serde(rename = "on")]
On,
#[serde(rename = "previous")]
Previous,
#[serde(rename = "toggle")]
Toggle,
}
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "clone", derive(Clone))]
#[derive(Deserialize, PartialEq)]
pub enum Zigbee81855Poweronbehavior {
#[serde(rename = "off")]
Off,
#[serde(rename = "on")]
On,
#[serde(rename = "previous")]
Previous,
#[serde(rename = "toggle")]
Toggle,
}
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "clone", derive(Clone))]
#[derive(Deserialize, PartialEq)]
pub enum Zigbee81863Poweronbehavior {
#[serde(rename = "off")]
Off,
#[serde(rename = "on")]
On,
#[serde(rename = "previous")]
Previous,
#[serde(rename = "toggle")]
Toggle,
}
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "clone", derive(Clone))]
#[derive(Deserialize, PartialEq)]
pub enum Zigbee81895Poweronbehavior {
#[serde(rename = "off")]
Off,
#[serde(rename = "on")]
On,
#[serde(rename = "previous")]
Previous,
#[serde(rename = "toggle")]
Toggle,
}
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "clone", derive(Clone))]
#[derive(Deserialize, PartialEq)]
pub enum ZigbeeBpu3Poweronbehavior {
#[serde(rename = "off")]
Off,
#[serde(rename = "on")]
On,
#[serde(rename = "previous")]
Previous,
#[serde(rename = "toggle")]
Toggle,
}
#[cfg(all(feature = "last_seen_epoch", feature = "last_seen_iso_8601"))]
compile_error!{"Feature last_seen epoch and iso_8601 are mutually exclusive and cannot be enabled together.
This was done because it is a global setting in zigbee2mqtt and therefor can't see a reason both would be enabled.
If you have a any reason to have both ways enabled please submit an issue to https://gitlab.com/seam345/zigbee2mqtt-types/-/issues"}