Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle errors in passthrough test correctly #327

Merged
merged 2 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading