This commit is contained in:
Mateusz Gruszczyński
2026-08-24 16:12:31 +02:00
parent 83f744e2cb
commit 66a5d6e5e9
22 changed files with 686 additions and 103 deletions
+55
View File
@@ -76,6 +76,29 @@ pub struct Device {
pub turbo: bool,
#[serde(default)]
pub light: bool,
/// Optional GREE feature states. Support is learned from status responses.
#[serde(default)]
pub air: bool,
#[serde(default)]
pub xfan: bool,
#[serde(default)]
pub health: bool,
#[serde(default)]
pub sleep: bool,
#[serde(default)]
pub supports_light: Option<bool>,
#[serde(default)]
pub supports_quiet: Option<bool>,
#[serde(default)]
pub supports_turbo: Option<bool>,
#[serde(default)]
pub supports_air: Option<bool>,
#[serde(default)]
pub supports_xfan: Option<bool>,
#[serde(default)]
pub supports_health: Option<bool>,
#[serde(default)]
pub supports_sleep: Option<bool>,
#[serde(default)]
pub current_temperature: Option<f64>,
#[serde(default)]
@@ -120,6 +143,17 @@ impl Device {
quiet: false,
turbo: false,
light: true,
air: false,
xfan: false,
health: false,
sleep: false,
supports_light: Some(true),
supports_quiet: Some(true),
supports_turbo: Some(true),
supports_air: Some(true),
supports_xfan: Some(true),
supports_health: Some(true),
supports_sleep: Some(true),
current_temperature: Some(26.0),
outdoor_temperature: Some(30.0),
temperature_sensor_offset: Some(false),
@@ -154,6 +188,10 @@ pub struct DeviceCommand {
pub quiet: Option<bool>,
pub turbo: Option<bool>,
pub light: Option<bool>,
pub air: Option<bool>,
pub xfan: Option<bool>,
pub health: Option<bool>,
pub sleep: Option<bool>,
}
impl DeviceCommand {
@@ -161,6 +199,7 @@ impl DeviceCommand {
self.power.is_none() && self.mode.is_none() && self.target_temperature.is_none()
&& self.fan_speed.is_none() && self.swing_vertical.is_none() && self.swing_horizontal.is_none()
&& self.quiet.is_none() && self.turbo.is_none() && self.light.is_none()
&& self.air.is_none() && self.xfan.is_none() && self.health.is_none() && self.sleep.is_none()
}
/// Return only fields that differ from the last known device state.
@@ -175,6 +214,10 @@ impl DeviceCommand {
quiet: self.quiet.filter(|value| *value != device.quiet),
turbo: self.turbo.filter(|value| *value != device.turbo),
light: self.light.filter(|value| *value != device.light),
air: self.air.filter(|value| *value != device.air),
xfan: self.xfan.filter(|value| *value != device.xfan),
health: self.health.filter(|value| *value != device.health),
sleep: self.sleep.filter(|value| *value != device.sleep),
}
}
@@ -188,6 +231,10 @@ impl DeviceCommand {
if let Some(v) = self.quiet { device.quiet = v; }
if let Some(v) = self.turbo { device.turbo = v; }
if let Some(v) = self.light { device.light = v; }
if let Some(v) = self.air { device.air = v; }
if let Some(v) = self.xfan { device.xfan = v; }
if let Some(v) = self.health { device.health = v; }
if let Some(v) = self.sleep { device.sleep = v; }
device.updated_at = Utc::now();
}
}
@@ -487,6 +534,9 @@ pub struct NightModeSettings {
/// Ask compatible GREE units to keep Quiet enabled during the whole night window.
#[serde(default = "default_true")]
pub force_quiet: bool,
/// Use the unit's native Sleep function during the night window when it is supported.
#[serde(default = "default_true")]
pub use_native_sleep: bool,
}
impl Default for NightModeSettings {
@@ -497,6 +547,7 @@ impl Default for NightModeSettings {
end_time: default_night_end(),
max_fan_speed: default_night_max_fan_speed(),
force_quiet: true,
use_native_sleep: true,
}
}
}
@@ -528,7 +579,11 @@ pub struct ZoneControlPlan {
pub device_id: String,
pub device_name: String,
pub enabled: bool,
/// Effective mode currently used by the controller.
pub mode: String,
/// Configured zone mode before house-mode inheritance is resolved.
pub configured_mode: String,
pub inherit_house_mode: bool,
pub preset: String,
pub current_temperature: Option<f64>,
pub target_temperature: Option<f64>,