Skip to content

Commit

Permalink
Add get_device_info_json to p300 child device
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal-Szczepaniak committed Apr 7, 2024
1 parent bd336d7 commit 4c92ab7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tapo/src/api/child_devices/p300_child_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ impl<'h> P300ChildHandler<'h> {
.map(|result| result.decode())?
}

/// Returns *device info* as [`serde_json::Value`].
/// It is not guaranteed to contain all the properties returned from the Tapo API.
pub async fn get_device_info_json(&self) -> Result<serde_json::Value, Error> {
let request = TapoRequest::GetDeviceInfo(TapoParams::new(EmptyParams));

self.power_strip_handler
.control_child::<serde_json::Value>(self.device_id.clone(), request)
.await?
.ok_or_else(|| Error::Tapo(TapoResponseError::EmptyResult))
}

/// Turns *on* the device.
pub async fn on(&self) -> Result<(), Error> {
let json = serde_json::to_value(GenericSetDeviceInfoParams::device_on(true)?)?;
Expand Down

0 comments on commit 4c92ab7

Please sign in to comment.