v0.14.21
This commit is contained in:
1 parent
ff4f2b60e7
commit
b7846c3b9f
87 files changed
+3783
-1418
No files matched your search
+70
-25
@@ -17,7 +17,6 @@ pub enum ConnectionStatus {
|
||||
Unknown,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct DeviceCapabilities {
|
||||
#[serde(default = "default_true")]
|
||||
@@ -36,32 +35,59 @@ pub struct DeviceCapabilities {
|
||||
pub vertical_swing: bool,
|
||||
#[serde(default = "default_true")]
|
||||
pub horizontal_swing: bool,
|
||||
#[serde(default)] pub turbo: bool,
|
||||
#[serde(default)] pub quiet: bool,
|
||||
#[serde(default)] pub sleep: bool,
|
||||
#[serde(default)] pub light: bool,
|
||||
#[serde(default)] pub health: bool,
|
||||
#[serde(default)] pub buzzer_control: bool,
|
||||
#[serde(default)] pub energy_meter: bool,
|
||||
#[serde(default)] pub compressor_frequency: bool,
|
||||
#[serde(default)]
|
||||
pub turbo: bool,
|
||||
#[serde(default)]
|
||||
pub quiet: bool,
|
||||
#[serde(default)]
|
||||
pub sleep: bool,
|
||||
#[serde(default)]
|
||||
pub light: bool,
|
||||
#[serde(default)]
|
||||
pub health: bool,
|
||||
#[serde(default)]
|
||||
pub buzzer_control: bool,
|
||||
#[serde(default)]
|
||||
pub energy_meter: bool,
|
||||
#[serde(default)]
|
||||
pub compressor_frequency: bool,
|
||||
}
|
||||
|
||||
impl Default for DeviceCapabilities {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
power: true, mode: true, fan_modes: default_fan_modes(),
|
||||
min_temperature: 8.0, max_temperature: 30.0, temperature_step: 1.0,
|
||||
vertical_swing: true, horizontal_swing: true, turbo: false, quiet: false,
|
||||
sleep: false, light: false, health: false, buzzer_control: false,
|
||||
energy_meter: false, compressor_frequency: false,
|
||||
power: true,
|
||||
mode: true,
|
||||
fan_modes: default_fan_modes(),
|
||||
min_temperature: 8.0,
|
||||
max_temperature: 30.0,
|
||||
temperature_step: 1.0,
|
||||
vertical_swing: true,
|
||||
horizontal_swing: true,
|
||||
turbo: false,
|
||||
quiet: false,
|
||||
sleep: false,
|
||||
light: false,
|
||||
health: false,
|
||||
buzzer_control: false,
|
||||
energy_meter: false,
|
||||
compressor_frequency: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn default_fan_modes() -> Vec<u8> { vec![0, 1, 2, 3, 4, 5] }
|
||||
fn default_min_temperature() -> f64 { 8.0 }
|
||||
fn default_max_temperature() -> f64 { 30.0 }
|
||||
fn default_temperature_step() -> f64 { 1.0 }
|
||||
fn default_fan_modes() -> Vec<u8> {
|
||||
vec![0, 1, 2, 3, 4, 5]
|
||||
}
|
||||
fn default_min_temperature() -> f64 {
|
||||
8.0
|
||||
}
|
||||
fn default_max_temperature() -> f64 {
|
||||
30.0
|
||||
}
|
||||
fn default_temperature_step() -> f64 {
|
||||
1.0
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Default)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
@@ -296,8 +322,13 @@ impl Device {
|
||||
communication_failures: 0,
|
||||
pending_command: false,
|
||||
capabilities: DeviceCapabilities {
|
||||
turbo: true, quiet: true, sleep: true, light: true, health: true,
|
||||
buzzer_control: true, ..DeviceCapabilities::default()
|
||||
turbo: true,
|
||||
quiet: true,
|
||||
sleep: true,
|
||||
light: true,
|
||||
health: true,
|
||||
buzzer_control: true,
|
||||
..DeviceCapabilities::default()
|
||||
},
|
||||
energy_source: EnergySourcePreference::Auto,
|
||||
ha_energy_entity_id: None,
|
||||
@@ -320,10 +351,16 @@ impl Device {
|
||||
self.capabilities.horizontal_swing = true;
|
||||
self.capabilities.temperature_step = 1.0;
|
||||
}
|
||||
self.capabilities.turbo = self.supports_turbo.unwrap_or(self.connection_type == ConnectionType::Local);
|
||||
self.capabilities.quiet = self.supports_quiet.unwrap_or(self.connection_type == ConnectionType::Local);
|
||||
self.capabilities.turbo = self
|
||||
.supports_turbo
|
||||
.unwrap_or(self.connection_type == ConnectionType::Local);
|
||||
self.capabilities.quiet = self
|
||||
.supports_quiet
|
||||
.unwrap_or(self.connection_type == ConnectionType::Local);
|
||||
self.capabilities.sleep = self.supports_sleep.unwrap_or(false);
|
||||
self.capabilities.light = self.supports_light.unwrap_or(self.connection_type == ConnectionType::Local);
|
||||
self.capabilities.light = self
|
||||
.supports_light
|
||||
.unwrap_or(self.connection_type == ConnectionType::Local);
|
||||
self.capabilities.health = self.supports_health.unwrap_or(false);
|
||||
self.capabilities.buzzer_control = self.supports_buzzer_control.unwrap_or(false);
|
||||
self.capabilities.energy_meter = self.supports_energy_meter.unwrap_or(false);
|
||||
@@ -391,8 +428,16 @@ impl DeviceCommand {
|
||||
.cloned(),
|
||||
target_temperature: self.target_temperature.filter(|value| {
|
||||
let step = device.capabilities.temperature_step.max(0.5);
|
||||
let requested = (value.clamp(device.capabilities.min_temperature, device.capabilities.max_temperature) / step).round();
|
||||
let current = (device.target_temperature.clamp(device.capabilities.min_temperature, device.capabilities.max_temperature) / step).round();
|
||||
let requested = (value.clamp(
|
||||
device.capabilities.min_temperature,
|
||||
device.capabilities.max_temperature,
|
||||
) / step)
|
||||
.round();
|
||||
let current = (device.target_temperature.clamp(
|
||||
device.capabilities.min_temperature,
|
||||
device.capabilities.max_temperature,
|
||||
) / step)
|
||||
.round();
|
||||
requested != current
|
||||
}),
|
||||
fan_speed: self
|
||||
|
||||
@@ -40,7 +40,6 @@ pub struct HaReading {
|
||||
pub temperature: f64,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct NetworkReading {
|
||||
pub id: i64,
|
||||
@@ -90,4 +89,3 @@ pub struct EnergyReading {
|
||||
#[serde(default)]
|
||||
pub reset_detected: bool,
|
||||
}
|
||||
|
||||
@@ -168,4 +168,3 @@ pub struct SettingsSnapshot {
|
||||
pub home_assistant: HomeAssistantSettingsView,
|
||||
pub debug: DebugSettings,
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user