Reworked air filter integration
This commit is contained in:
@@ -241,40 +241,3 @@ impl TryFrom<Bytes> for HueMessage {
|
||||
serde_json::from_slice(&bytes).or(Err(ParseError::InvalidPayload(bytes.clone())))
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Import this from the air_filter code itself instead of copying
|
||||
#[derive(PartialEq, Eq, Debug, Clone, Copy, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum AirFilterFanState {
|
||||
Off,
|
||||
Low,
|
||||
Medium,
|
||||
High,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Deserialize, Serialize)]
|
||||
pub struct SetAirFilterFanState {
|
||||
state: AirFilterFanState,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Debug, Clone, Copy, Deserialize, Serialize)]
|
||||
pub struct AirFilterState {
|
||||
pub state: AirFilterFanState,
|
||||
pub humidity: f32,
|
||||
pub temperature: f32,
|
||||
}
|
||||
|
||||
impl SetAirFilterFanState {
|
||||
pub fn new(state: AirFilterFanState) -> Self {
|
||||
Self { state }
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<Publish> for AirFilterState {
|
||||
type Error = ParseError;
|
||||
|
||||
fn try_from(message: Publish) -> Result<Self, Self::Error> {
|
||||
serde_json::from_slice(&message.payload)
|
||||
.or(Err(ParseError::InvalidPayload(message.payload.clone())))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user