tapo 0.9.0

Unofficial Tapo API Client. Works with TP-Link Tapo smart devices. Tested with light bulbs (L510, L520, L530, L535, L610, L630), light strips (L900, L920, L930), plugs (P100, P105, P110, P110M, P115), power strips (P300, P304M, P306, P316M), hubs (H100), switches (S200B, S200D, S210) and sensors (KE100, T100, T110, T300, T310, T315).
Documentation
use crate::error::{Error, TapoResponseError};
use crate::requests::{EmptyParams, TapoParams, TapoRequest};
use crate::responses::{T31XResult, TemperatureHumidityRecords, TemperatureHumidityRecordsRaw};

tapo_child_handler! {
    /// Handler for the [T310](https://www.tapo.com/en/search/?q=T310) and [T315](https://www.tapo.com/en/search/?q=T315) devices.
    T31XHandler(T31XResult),
}

impl T31XHandler {
    /// Returns *temperature and humidity records* from the last 24 hours at 15 minute intervals as [`TemperatureHumidityRecords`].
    pub async fn get_temperature_humidity_records(
        &self,
    ) -> Result<TemperatureHumidityRecords, Error> {
        let request =
            TapoRequest::GetTemperatureHumidityRecords(Box::new(TapoParams::new(EmptyParams)));

        let result = self
            .client
            .read()
            .await
            .control_child::<TemperatureHumidityRecordsRaw>(self.device_id.clone(), request)
            .await?
            .ok_or_else(|| Error::Tapo(TapoResponseError::EmptyResult))?;

        Ok(result.try_into()?)
    }
}