Skip to content

Commit

Permalink
Add support for the P304 power strip
Browse files Browse the repository at this point in the history
  • Loading branch information
mihai-dinculescu committed Oct 8, 2024
1 parent 1c70dea commit 79a4075
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 29 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ file. This change log follows the conventions of

## [Rust Unreleased][Unreleased]

### Added

- Added support for the P304 power strip.

## [Python Unreleased][Unreleased]

## [Rust v0.7.16][v0.7.16] - 2024-09-27
Expand All @@ -16,7 +20,7 @@ file. This change log follows the conventions of

### Fixed

- Fixed an issue that was preventing the color from being set properly to the L535 light bulbs.
- Fixed an issue that prevented the color from being set properly for the L535 light bulbs.

## [Python v0.5.1][py-v0.5.1] - 2024-09-27

Expand All @@ -26,7 +30,7 @@ file. This change log follows the conventions of

### Fixed

- Fixed an issue that was preventing the color from being set properly to the L535 light bulbs.
- Fixed an issue that prevented the color from being set properly for the L535 light bulbs.

## [Rust v0.7.15][v0.7.15] - 2024-09-18

Expand Down
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![PyPI][pypi_badge]][pypi]
[![Python][pypi_versions_badge]][pypi]
[![PyPI][pypi_downloads_badge]][pypi]\
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, P115, P300), hubs (H100), switches (S200B) and sensors (KE100, T100, T110, T300, T310, T315).
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, P115), power strips (P300, P304), hubs (H100), switches (S200B) and sensors (KE100, T100, T110, T300, T310, T315).

[license_badge]: https://img.shields.io/crates/l/tapo.svg
[license]: https://github.com/mihai-dinculescu/tapo/blob/main/LICENSE
Expand All @@ -28,27 +28,27 @@ Unofficial Tapo API Client. Works with TP-Link Tapo smart devices. Tested with l
✓ - Rust only\
✅ - Rust and Python

| Feature<br/><br/><br/> | GenericDevice<br/><br/><br/> | L510<br/>L520<br/>L610 | L530<br/>L535<br/>L630<br/> | L900<br/><br/><br/> | L920<br/>L930<br/><br/> | P100<br/>P105<br/><br/> | P110<br/>P115<br/><br/> | P300<br/><br/><br/> | H100<br/><br/><br/> |
| ------------------------------------ | :--------------------------: | :--------------------: | :-------------------------: | :-----------------: | :---------------------: | :---------------------: | :---------------------: | :-----------------: | :-----------------: |
| device_reset | | &#x2705; | &#x2705; | &check; | &check; | &#x2705; | &#x2705; | | |
| get_child_device_component_list_json | | | | | | | | &check; | &#x2705; |
| get_child_device_list | | | | | | | | &check; | &#x2705; |
| get_child_device_list_json | | | | | | | | &check; | &#x2705; |
| get_current_power | | | | | | | &#x2705; | | |
| get_device_info | &#x2705; | &#x2705; | &#x2705; | &check; | &check; | &#x2705; | &#x2705; | &check; | &#x2705; |
| get_device_info_json | &#x2705; | &#x2705; | &#x2705; | &check; | &check; | &#x2705; | &#x2705; | &check; | &#x2705; |
| get_device_usage | | &#x2705; | &#x2705; | &check; | &check; | &#x2705; | &#x2705; | | |
| get_energy_data | | | | | | | &#x2705; | | |
| get_energy_usage | | | | | | | &#x2705; | | |
| off | &#x2705; | &#x2705; | &#x2705; | &check; | &check; | &#x2705; | &#x2705; | | |
| on | &#x2705; | &#x2705; | &#x2705; | &check; | &check; | &#x2705; | &#x2705; | | |
| refresh_session | &#x2705; | &#x2705; | &#x2705; | &check; | &check; | &#x2705; | &#x2705; | &check; | &#x2705; |
| set_brightness | | &#x2705; | &#x2705; | &check; | &check; | | | | |
| set_color | | | &#x2705; | &check; | &check; | | | | |
| set_color_temperature | | | &#x2705; | &check; | &check; | | | | |
| set_hue_saturation | | | &#x2705; | &check; | &check; | | | | |
| set_lighting_effect | | | | | &check; | | | | |
| set() API \* | | | &#x2705; | &check; | &check; | | | | |
| Feature<br/><br/><br/> | GenericDevice<br/><br/><br/> | L510<br/>L520<br/>L610 | L530<br/>L535<br/>L630<br/> | L900<br/><br/><br/> | L920<br/>L930<br/><br/> | P100<br/>P105<br/><br/> | P110<br/>P115<br/><br/> | P300<br/>P304<br/><br/> | H100<br/><br/><br/> |
| ------------------------------------ | :--------------------------: | :--------------------: | :-------------------------: | :-----------------: | :---------------------: | :---------------------: | :---------------------: | :---------------------: | :-----------------: |
| device_reset | | &#x2705; | &#x2705; | &check; | &check; | &#x2705; | &#x2705; | | |
| get_child_device_component_list_json | | | | | | | | &check; | &#x2705; |
| get_child_device_list | | | | | | | | &check; | &#x2705; |
| get_child_device_list_json | | | | | | | | &check; | &#x2705; |
| get_current_power | | | | | | | &#x2705; | | |
| get_device_info | &#x2705; | &#x2705; | &#x2705; | &check; | &check; | &#x2705; | &#x2705; | &check; | &#x2705; |
| get_device_info_json | &#x2705; | &#x2705; | &#x2705; | &check; | &check; | &#x2705; | &#x2705; | &check; | &#x2705; |
| get_device_usage | | &#x2705; | &#x2705; | &check; | &check; | &#x2705; | &#x2705; | | |
| get_energy_data | | | | | | | &#x2705; | | |
| get_energy_usage | | | | | | | &#x2705; | | |
| off | &#x2705; | &#x2705; | &#x2705; | &check; | &check; | &#x2705; | &#x2705; | | |
| on | &#x2705; | &#x2705; | &#x2705; | &check; | &check; | &#x2705; | &#x2705; | | |
| refresh_session | &#x2705; | &#x2705; | &#x2705; | &check; | &check; | &#x2705; | &#x2705; | &check; | &#x2705; |
| set_brightness | | &#x2705; | &#x2705; | &check; | &check; | | | | |
| set_color | | | &#x2705; | &check; | &check; | | | | |
| set_color_temperature | | | &#x2705; | &check; | &check; | | | | |
| set_hue_saturation | | | &#x2705; | &check; | &check; | | | | |
| set_lighting_effect | | | | | &check; | | | | |
| set() API \* | | | &#x2705; | &check; | &check; | | | | |

\* The `set()` API allows multiple properties to be set in a single request.

Expand Down
2 changes: 1 addition & 1 deletion tapo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.7.16"
edition = "2021"
license = "MIT"
authors = ["Mihai Dinculescu <[email protected]>"]
description = "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, P115, P300), hubs (H100), switches (S200B) and sensors (KE100, T100, T110, T300, T310, T315)."
description = "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, P115), power strips (P300, P304), hubs (H100), switches (S200B) and sensors (KE100, T100, T110, T300, T310, T315)."
keywords = ["IOT", "tapo", "smart-home", "smart-bulb", "smart-plug"]
categories = ["hardware-support", "embedded", "development-tools"]
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion tapo/examples/tapo_p300.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// P300 Example
/// P300 and P304 Example
use std::{env, thread, time::Duration};

use log::{info, LevelFilter};
Expand Down
26 changes: 26 additions & 0 deletions tapo/src/api/api_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,32 @@ impl ApiClient {
Ok(PowerStripHandler::new(self))
}

/// Specializes the given [`ApiClient`] into an authenticated [`PowerStripHandler`].
///
/// # Arguments
///
/// * `ip_address` - the IP address of the device
///
/// # Example
///
/// ```rust,no_run
/// # use tapo::ApiClient;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let device = ApiClient::new("[email protected]", "tapo-password")
/// .p304("192.168.1.100")
/// .await?;
/// let child_device_list = device.get_child_device_list().await?;
/// println!("Child device list: {child_device_list:?}");
/// # Ok(())
/// # }
/// ```
pub async fn p304(mut self, ip_address: impl Into<String>) -> Result<PowerStripHandler, Error> {
self.login(ip_address).await?;

Ok(PowerStripHandler::new(self))
}

/// Specializes the given [`ApiClient`] into an authenticated [`PlugEnergyMonitoringHandler`].
///
/// # Arguments
Expand Down
3 changes: 2 additions & 1 deletion tapo/src/api/power_strip_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ use crate::responses::{
ChildDeviceListPowerStripResult, DeviceInfoPowerStripResult, PlugPowerStripResult,
};

/// Handler for the [P300](https://www.tapo.com/en/search/?q=P300) devices.
/// Handler for the [P300](https://www.tapo.com/en/search/?q=P300) and
/// [P304](https://www.tp-link.com/uk/search/?q=P304) devices.
pub struct PowerStripHandler {
client: Arc<RwLock<ApiClient>>,
}
Expand Down
2 changes: 1 addition & 1 deletion tapo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! Tapo API Client.
//!
//! Tested with light bulbs (L510, L520, L530, L535, L610, L630), light strips (L900, L920, L930),
//! plugs (P100, P105, P110, P115, P300), hubs (H100), switches (S200B) and sensors (KE100, T100, T110, T300, T310, T315).
//! plugs (P100, P105, P110, P115), power strips (P300, P304), hubs (H100), switches (S200B) and sensors (KE100, T100, T110, T300, T310, T315).
//!
//! # Example with L530
//! ```rust,no_run
Expand Down
2 changes: 1 addition & 1 deletion tapo/src/responses/device_info_result/power_strip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
use crate::error::Error;
use crate::responses::{decode_value, DecodableResultExt, TapoResponseExt};

/// Device info of Tapo H100. Superset of [`crate::responses::DeviceInfoGenericResult`].
/// Device info of Tapo P300 and P304. Superset of [`crate::responses::DeviceInfoGenericResult`].
#[derive(Debug, Clone, Serialize, Deserialize)]
#[allow(missing_docs)]
pub struct DeviceInfoPowerStripResult {
Expand Down

0 comments on commit 79a4075

Please sign in to comment.