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 serde::{Deserialize, Serialize};

use crate::responses::TapoResponseExt;
use crate::utils::ok_or_default;

/// Contains the time usage.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "python", pyo3::prelude::pyclass(from_py_object, get_all))]
pub struct DeviceUsageResult {
    /// Time usage in minutes.
    pub time_usage: UsageByPeriodResult,
}
impl TapoResponseExt for DeviceUsageResult {}

#[cfg(feature = "python")]
crate::impl_to_dict!(DeviceUsageResult);

/// Usage by period result for today, the past 7 days, and the past 30 days.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "python", pyo3::prelude::pyclass(from_py_object, get_all))]
pub struct UsageByPeriodResult {
    /// Today usage in minutes.
    #[serde(deserialize_with = "ok_or_default")]
    pub today: Option<u64>,
    /// Past 7 days usage in minutes.
    #[serde(deserialize_with = "ok_or_default")]
    pub past7: Option<u64>,
    /// Past 30 days usage in minutes.
    #[serde(deserialize_with = "ok_or_default")]
    pub past30: Option<u64>,
}

#[cfg(feature = "python")]
crate::impl_to_dict!(UsageByPeriodResult);