use serde::{Deserialize, Serialize};
use serde_repr::{Deserialize_repr, Serialize_repr};

#[derive(Debug, Serialize_repr, Deserialize_repr, Clone)]
#[repr(u8)]
pub enum Intensity {
    Low = 1,
    Medium = 2,
    High = 3,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ElectricHeating {
    /// Is electric heating running instead of heat pump
    pub running: bool,
    /// Indicate the current speed setting of the outdoor fan that helps to cool the compressor and condenser in the heat pump system
    #[serde(skip_serializing_if = "Option::is_none")]
    pub fan_speed: Option<Intensity>,
    /// Indicate electric heating intensity
    #[serde(skip_serializing_if = "Option::is_none")]
    pub intensity: Option<Intensity>,
    /// Indicate the status of the water circulation pump
    #[serde(skip_serializing_if = "Option::is_none")]
    pub water_pump_running: Option<bool>,
}

impl ElectricHeating {
    pub fn new(
        running: bool,
        fan_speed: Option<Intensity>,
        intensity: Option<Intensity>,
        water_pump_running: Option<bool>,
    ) -> Self {
        Self {
            running,
            fan_speed,
            intensity,
            water_pump_running,
        }
    }
}

impl Default for ElectricHeating {
    fn default() -> Self {
        Self::new(false, None, None, None)
    }
}
