switchbot_api2/api/
climate.rs1use anyhow::Result;
2use serde::Deserialize;
3
4use crate::{Dev, Device, SwitchBot};
5
6#[derive(Clone, Debug, Deserialize, PartialEq)]
8pub struct ClimateStatus {
9 pub temperature: f64,
11
12 pub humidity: f64,
14}
15
16impl SwitchBot {
17 pub async fn get_climate(&self, dev: &Device) -> Result<Option<ClimateStatus>> {
19 match dev.typ {
20 Dev::Hub2 | Dev::IOThermoHygrometer => Ok(Some(
21 self.get(&format!("v1.1/devices/{}/status", dev.id)).await?,
22 )),
23 Dev::Other(_) => Ok(None),
24 }
25 }
26}