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 Zigbee316gledrf {
pub brightness: f64,
pub linkquality: f64,
pub power_on_behavior: Zigbee316gledrfPoweronbehavior,
#[serde(deserialize_with = "zigbee316gledrf_state_deserializer")]
pub state: bool,
pub last_seen: Option<LastSeen>,
pub elapsed: Option<u64>,
}
fn zigbee316gledrf_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 Zigbee4523430 {
#[serde(deserialize_with = "zigbee4523430_child_lock_deserializer")]
pub child_lock: bool,
pub display_text: f64,
pub floor_temp: f64,
#[serde(deserialize_with = "zigbee4523430_frost_guard_deserializer")]
pub frost_guard: bool,
pub linkquality: f64,
pub load: f64,
pub local_temperature: f64,
pub local_temperature_calibration: f64,
pub max_floor_temp: f64,
pub mean_power: f64,
#[serde(deserialize_with = "zigbee4523430_night_switching_deserializer")]
pub night_switching: bool,
pub occupied_heating_setpoint: f64,
#[serde(deserialize_with = "zigbee4523430_regulator_mode_deserializer")]
pub regulator_mode: bool,
pub regulator_time: f64,
pub running_state: Zigbee4523430Runningstate,
pub sensor: Zigbee4523430Sensor,
pub system_mode: Zigbee4523430Systemmode,
pub last_seen: Option<LastSeen>,
pub elapsed: Option<u64>,
}
fn zigbee4523430_child_lock_deserializer<'de, D>(deserializer: D) -> Result<bool, D::Error>
where
D: Deserializer<'de>,
{
match String::deserialize(deserializer)?.as_ref() {
"lock" => Ok(true),
"unlock" => Ok(false),
other => Err(de::Error::invalid_value(
Unexpected::Str(other),
&"Value expected was either lock or unlock",
)),
}
}
fn zigbee4523430_frost_guard_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",
)),
}
}
fn zigbee4523430_night_switching_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",
)),
}
}
fn zigbee4523430_regulator_mode_deserializer<'de, D>(deserializer: D) -> Result<bool, D::Error>
where
D: Deserializer<'de>,
{
match String::deserialize(deserializer)?.as_ref() {
"regulator" => Ok(true),
"thermostat" => Ok(false),
other => Err(de::Error::invalid_value(
Unexpected::Str(other),
&"Value expected was either regulator or thermostat",
)),
}
}
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "clone", derive(Clone))]
#[derive(Deserialize)]
pub struct ZigbeeEko05806 {
pub action: ZigbeeEko05806Action,
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, PartialEq)]
pub enum Zigbee316gledrfPoweronbehavior {
#[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 Zigbee4523430Runningstate {
#[serde(rename = "heat")]
Heat,
#[serde(rename = "idle")]
Idle,
}
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "clone", derive(Clone))]
#[derive(Deserialize, PartialEq)]
pub enum Zigbee4523430Sensor {
#[serde(rename = "air")]
Air,
#[serde(rename = "floor")]
Floor,
#[serde(rename = "supervisor_floor")]
SupervisorFloor,
}
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "clone", derive(Clone))]
#[derive(Deserialize, PartialEq)]
pub enum Zigbee4523430Systemmode {
#[serde(rename = "heat")]
Heat,
#[serde(rename = "off")]
Off,
}
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "clone", derive(Clone))]
#[derive(Deserialize, PartialEq)]
pub enum ZigbeeEko05806Action {
#[serde(rename = "brightness_step_down")]
BrightnessStepDown,
#[serde(rename = "brightness_step_up")]
BrightnessStepUp,
#[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"}