Skip to content

Commit

Permalink
Fix H100's get T310 & T315 child devices by id
Browse files Browse the repository at this point in the history
  • Loading branch information
mihai-dinculescu committed May 12, 2024
1 parent 896a66b commit cc53dab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion tapo/examples/tapo_h100.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,21 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
trigger_logs
);
}
ChildDeviceHubResult::T310(device) | ChildDeviceHubResult::T315(device) => {
ChildDeviceHubResult::T310(device) => {
let t31x = hub.t310(HubDevice::ByDeviceId(&device.device_id)).await?;
let temperature_humidity_records = t31x.get_temperature_humidity_records().await?;

info!(
"Found T31X child device with nickname: {}, id: {}, temperature: {} {:?}, humidity: {}%, 24-hour ago record: {:?}.",
device.nickname,
device.device_id,
device.current_temperature,
device.temperature_unit,
device.current_humidity,
temperature_humidity_records.records.first()
);
}
ChildDeviceHubResult::T315(device) => {
let t31x = hub.t315(HubDevice::ByDeviceId(&device.device_id)).await?;
let temperature_humidity_records = t31x.get_temperature_humidity_records().await?;

Expand Down
2 changes: 1 addition & 1 deletion tapo/src/api/hub_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ impl HubHandler {
/// # }
/// ```
pub async fn t315<'a>(&self, identifier: HubDevice<'a>) -> Result<T31XHandler, Error> {
let device_id = get_device_id!(self, identifier, ChildDeviceHubResult::T310);
let device_id = get_device_id!(self, identifier, ChildDeviceHubResult::T315);
Ok(T31XHandler::new(self, device_id))
}
}
Expand Down

0 comments on commit cc53dab

Please sign in to comment.