Skip to content

Commit

Permalink
Handle errors in passthrough test correctly (#327)
Browse files Browse the repository at this point in the history
Handle errors in passthrough test correctly

Addresses #288.

---------

Co-authored-by: Mihai Dinculescu <[email protected]>
  • Loading branch information
WhySoBad and mihai-dinculescu authored Dec 21, 2024
1 parent 7134e82 commit 0c3396f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@ file. This change log follows the conventions of
- The internal implementation of `H100Handler`'s `get_child_device_list` has been updated to fetch all pages, not just the first one.
- `H100Handler`'s `get_child_device_list_json` now includes a `start_index` parameter to fetch child devices starting from a specific index.

#### Fixed

- Resolved an issue that caused the passthrough protocol test to incorrectly indicate support when it was not actually supported. (thanks to @WhySoBad)

### Python

#### Changed

- The internal implementation of `H100Handler`'s `get_child_device_list` has been updated to fetch all pages, not just the first one.
- `H100Handler`'s `get_child_device_list_json` now includes a `start_index` parameter to fetch child devices starting from a specific index.

#### Fixed

- Resolved an issue that caused the passthrough protocol test to incorrectly indicate support when it was not actually supported. (thanks to @WhySoBad)

## [v0.8.0][v0.8.0] - 2024-12-07

This marks the first unified release of the Rust and Python libraries. Moving forward, both libraries will be released simultaneously and will share the same version number.
Expand Down
14 changes: 7 additions & 7 deletions tapo/src/api/protocol/discovery_protocol.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use log::debug;
use log::{debug, warn};
use reqwest::Client;

use crate::api::protocol::klap_protocol::KlapProtocol;
Expand Down Expand Up @@ -34,14 +34,14 @@ impl DiscoveryProtocol {
}

async fn is_passthrough_supported(&self, url: &str) -> Result<bool, Error> {
if let Err(Error::Tapo(TapoResponseError::Unknown(code))) = self.test_passthrough(url).await
{
if code == 1003 {
return Ok(false);
match self.test_passthrough(url).await {
Err(Error::Tapo(TapoResponseError::Unknown(code))) => Ok(code != 1003),
Err(err) => {
warn!("Passthrough protocol test error: {err:?}");
Err(err)
}
Ok(_) => Ok(true),
}

Ok(true)
}

async fn test_passthrough(&self, url: &str) -> Result<(), Error> {
Expand Down

0 comments on commit 0c3396f

Please sign in to comment.